React Query Client Preset #9571
0-don
started this conversation in
Docs Discussions
Replies: 1 comment
-
Pretty sure the docs don't event have valid typescript.. Doesnt include any info about doing mutations |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just wanted to share my react query client configuration because I couldnt find anything in the docs
React Query Client Configuration with GraphQL Codegen
This configuration provides custom hooks for handling GraphQL requests using React Query and GraphQL Codegen.
Functions and Hooks
getKey(document)
: Returns the name of the first definition in the GraphQL document.useGqlQuery(document, variables, options)
: A wrapper arounduseQuery
from React Query for GraphQL queries.useGqlMutation(document, options)
: A wrapper arounduseMutation
from React Query for GraphQL mutations.useGqlInfinite(document, variables, options)
: A wrapper arounduseInfiniteQuery
from React Query for infinite loading of GraphQL data.customFetcher(document, variables, options, withHeaders)
: Fetches data from the GraphQL server. Throws an error if the server returns any errors.Parameters
document
: A GraphQL document.variables
: Variables for the GraphQL request (optional).options
: Options for the React Query hook or headers for the fetch request (optional).withHeaders
: A flag indicating whether to return the headers with the data (optional, default isfalse
).Usage
Use the custom hooks in your components as you would use the standard React Query hooks, passing in your GraphQL documents and any necessary variables or options.
Beta Was this translation helpful? Give feedback.
All reactions