GraphQL for .NET - cancellation token

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

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 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like