NET的GraphQL-取消令牌

时间:2019-11-11 00:27:18

标签: .net-core graphql

有没有办法在graphql端点中传递取消令牌?

public class GetAccountQuery : ObjectGraphType
{ public GetAccountQuery(IRolver resolver)
        {
            FieldAsync<UserType>(
                "GetAccount",
                arguments: new QueryArguments(
                    new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "userId" },
                resolve: async context => await resolver.ResolveAsync(context, pass in cancellation token ?? ));
        }
}

1 个答案:

答案 0 :(得分:0)

找到答案,将IHttpContextAccessor注入GetAccountQuery ctor中,然后像下面这样从httpcontext访问Cancellation令牌:

HttpContextAccessor.HttpContext.RequestAborted