Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cancel): add graphql-request example #2948

Merged

Conversation

arnaudbzn
Copy link
Contributor

It is possible to set an AbortSignal in the GraphQLClient constructor.

const query = useQuery('todos', ({ signal }) => {
  const client = new GraphQLClient(endpoint, {
    signal,
  });
  return client.request(query, variables)
})

But unfortunately, it is not possible to define a signal per request:
jasonkuhrt/graphql-request#182

It means that the GraphQL Code Gen React Query plugin cannot support a signal for the moment with graphql-request 😔

The solution is to:

  • PR graphql-request to support a signal per request
  • PR GraphQL Code Gen React Query Plugin to send the signal to the graphql-request request.

@vercel
Copy link

vercel bot commented Nov 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tanstack/react-query/B5Jar7gZ5ncF4xtaYntyXaioa2Um
✅ Preview: https://react-query-git-fork-arnaudbzn-docs-query-cance-5d3533-tanstack.vercel.app

@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #2948 (26a8cb8) into master (c1ae82b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2948   +/-   ##
=======================================
  Coverage   96.40%   96.40%           
=======================================
  Files          45       45           
  Lines        2227     2227           
  Branches      637      637           
=======================================
  Hits         2147     2147           
  Misses         77       77           
  Partials        3        3           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1ae82b...26a8cb8. Read the comment docs.

@TkDodo
Copy link
Collaborator

TkDodo commented Nov 15, 2021

thank you. do you know if there are other graphql fetching libs that would support it right now? Like maybe @urql/core?

@arnaudbzn
Copy link
Contributor Author

New graphq-request PR to support a signal argument in the request function:
jasonkuhrt/graphql-request#303

@arnaudbzn
Copy link
Contributor Author

arnaudbzn commented Nov 15, 2021

thank you. do you know if there are other graphql fetching libs that would support it right now? Like maybe @urql/core?

I have not found in the urql docs and code how to set a signal.
I may not use urql as a graphql fetcher for React Query, graphql-request is super lean and does the job.
I'm not aware of other basic graphql fetchers.

@TkDodo
Copy link
Collaborator

TkDodo commented Nov 15, 2021

oh wow, you already PR'ed to graphql-request 🚀

should we wait with this docs until it lands, or should we merge this doc PR right away?

@arnaudbzn
Copy link
Contributor Author

oh wow, you already PR'ed to graphql-request 🚀

should we wait with this docs until it lands, or should we merge this doc PR right away?

😁
We can merge now because it is useful to know the current possibilities with graphql-request and I've no visibility on when the PR will be merged... 🐌

I'll update the doc when the graphql-request PR will be merged in another RQ PR.

@TkDodo TkDodo merged commit 1dc4186 into TanStack:master Nov 15, 2021
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.33.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants