examples/preact/basic-graphql-request
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Preact Query Basic GraphQL Request Example#
The basic posts example, fetching from a GraphQL API with graphql-request.
How it works#
src/services/posts/queries.tsdefinespostsQueries.list()andpostsQueries.detail(postId),queryOptionsfactories keyed by['posts', 'list']and['posts', 'detail', postId].src/services/posts/api.tssendsgqlqueries withrequestfromgraphql-requestto the GraphQLZero API.- In
src/index.tsx,PostsandPostpass the factories touseQuery.PostscallsqueryClient.getQueryData(postsQueries.detail(post.id).queryKey)to show posts that are already cached in bold green.
To run this example:
npm installnpm run dev