feat!: add signal support#303
Conversation
|
I was just looking for a way to cancel requests with this lib and the changes in this PR will enable me to do just that. Thanks, @arnaudbzn! |
|
@jasonkuhrt Node.js supports According to the README, we should not have to fully support v12. |
v12 is not officially supported so the impact should be minimal.
@jasonkuhrt , I've removed the Node v12 from the test matrix, everything should be green 🚦 |
|
@arnaudbzn Are there simple instructions for how Node 12 users can polyfill themselves? If so let's add that to our REDAME? |
Actually |
This reverts commit 7b37a45.
to support Node.js version < 14.17.0
|
@jasonkuhrt An |
|
Looking forward to using this. Can this be released? |
@jasonkuhrt Thank you for the merge 🙂 |
|
I'll cut a preview release today. Unfortunately the automation for that is still failing. |
@jasonkuhrt Thank you Jason, any update about the release? |
|
Preview went out 10 days ago, I can cut a stable today I guess. |
@jasonkuhrt Have you planned a release this week? Thks. |
|
@arnaudbzn we cut one last week, there's a problem with the release tool so no activity on the git repo about that. But it is on npm now. |
That's great! thank you Jason. |
|
Hey, Is it documented anywhere how to actually use this? const companiesQuery = useQuery({
queryKey: ["companies", "search", deferredSearchInput],
queryFn: ({ signal }) =>
// How to use signal with request?
graphqlClient.request(companiesQueryDocument, {
query: deferredSearchInput,
}),
enabled: Boolean(deferredSearchInput),
});Update: it should be used like this const companiesQuery = useQuery({
queryKey: ["companies", "search", deferredSearchInput],
queryFn: ({ signal }) =>
graphqlClient.request({
document: companiesQueryDocument,
variables: { query: deferredSearchInput },
signal,
}),
enabled: Boolean(deferredSearchInput),
}); |
Add a new
signalrequest option torequest,rawRequestandbatchRequestsGraphQL Client methods.New GraphQL Client
request,rawRequestandbatchRequestsmethod overloads with a singleoptionsobject argument.The
signaldefined as a function argument overrides the signal defined in theGraphQLClientconstructor.This feature will add more flexibility and it will allow GraphQL Code Gen React Query plugin to support
signaland request cancellation with graphql-request.Related issue: #182
Also included in this PR:
yarn test:coverage.