jasonkuhrt / graphql-request

Minimal GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`client.request()` does not take a `signal` option as shown in examples

pthorsson opened this issue · comments

{
const abortController = new AbortController()
const client = new GraphQLClient(endpoint)
const document = gql`
{
Movie(title: "Inception") {
releaseDate
actors {
name
}
}
}
`
const _requesting = client.request({
document,
signal: abortController.signal,
})
abortController.abort()
}

According to the examples for request cancellation we can use the signal option to cancel an active request. This is possible when using the standalone request function. However the request function exposed in the instance of the GraphQLClient does not have that possibility it shows in the example it seems. The first argument of that function is of type RequestDocument | TypedDocumentNode<T> and not an options object.

Should the client.request() have this possibility, or is the example perhaps wrong?

Edit: typos

Thanks for the report, either the docs will be updated or this will be turned into a feature request. I'll do the latter if the task is easy, which I suspect it will be.

It is an overloaded function and does accept an options object. Check again, feel free to post into Q&A for help.

excludeOperationName,
...fetchOptions
} = this.requestConfig