.net core .NET的GraphQL-取消令牌
有没有办法在graphql端点中传递取消令牌.net core .NET的GraphQL-取消令牌,.net-core,graphql,.net Core,Graphql,有没有办法在graphql端点中传递取消令牌 public class GetAccountQuery : ObjectGraphType { public GetAccountQuery(IRolver resolver) { FieldAsync<UserType>( "GetAccount", arguments: new QueryArguments(
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 ?? ));
}
}
公共类GetAccountQuery:ObjectGraphType
{公共GetAccountQuery(IRolver解析器)
{
FieldAsync(
“GetAccount”,
参数:新的QueryArguments(
新的QueryArgument{Name=“userId”},
resolve:async context=>Wait resolver.ResolveAsync(上下文,传入取消令牌??);
}
}
找到答案,将IHttpContextAccessor注入GetAccountQuery ctor,然后从httpcontext访问取消令牌,如下所示:
HttpContextAccessor.HttpContext.RequestAborted
您是否尝试过使用订阅并取消它?它适用于Apollo,但未尝试使用.Net。