mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
|
History
|
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| .gitignore | ||
| eslint.config.js | ||
| index.html | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| vite.config.ts | ||
TanStack Solid 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(id)withqueryOptions, keyed by['posts', 'list']and['posts', 'detail', id].src/services/posts/api.tssends GraphQL queries withrequestandgqlfromgraphql-requestto the GraphQLZero API.src/index.tsxpasses these options touseQueryin thePostsandPostcomponents and shows "Background Updating..." whileisFetchingistrue.- The
Postslist callsqueryClient.getQueryData(postsQueries.detail(post.id).queryKey)to style links whose detail is already cached.
To run this example:
npm installnpm run dev