Graphql For. Net - Cancellation Token
Is There a Way to Pass Cancellation Token in Graphql Endpoint? Public Class Getaccountquery: Objectgraphtype { Public Getaccountquery(Irolver Resolver) {...
is there a way to pass cancellation token in graphql endpoint?
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 Answer
found the answer, inject the IHttpContextAccessor into the GetAccountQuery ctor and then access the Cancellation token from the httpcontext like so:
HttpContextAccessor.HttpContext.RequestAborted