有没有办法在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 ?? ));
}
}
答案 0 :(得分:0)
找到答案,将IHttpContextAccessor注入GetAccountQuery ctor中,然后像下面这样从httpcontext访问Cancellation令牌:
HttpContextAccessor.HttpContext.RequestAborted