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

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

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest