0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/examples/solid/basic-graphql-request
History 2026-11-13 10:57:29 +09:00
..
public docs(examples): use the TanStack Query emblem as the favicon in every example (#12578) 2026-11-12 13:33:29 +09:00
src docs(examples): use the TanStack Query emblem as the favicon in every example (#12578) 2026-11-12 13:33:29 +09:00
.gitignore docs(examples): use each framework's template '.gitignore' in every example (#12592) 2026-11-13 10:57:29 +09:00
eslint.config.js chore(examples/*/eslint.config): use 'flat/recommended-strict' from '@tanstack/eslint-plugin-query' (#12385) 2026-10-26 02:55:51 +09:00
index.html docs(examples): unify page titles to 'TanStack <Framework> Query <Name> Example' and remove scaffold leftovers (#12580) 2026-11-12 14:54:59 +09:00
package.json ci: Version Packages (#12543) 2026-11-07 00:00:45 +01:00
README.md docs(examples): rewrite the READMEs, add the framework or router to example titles, and rename examples to '<feature>-<framework>' (#12583) 2026-11-12 16:58:15 +09:00
tsconfig.json chore(examples/*/tsconfig): include '*.config.ts' and '*.config.js' like the packages (#12408) 2026-10-27 09:11:08 +09:00
vite.config.ts ci(examples): test examples in CI (#6813) 2024-02-03 15:53:29 +11:00

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.ts defines postsQueries.list() and postsQueries.detail(id) with queryOptions, keyed by ['posts', 'list'] and ['posts', 'detail', id].
  • src/services/posts/api.ts sends GraphQL queries with request and gql from graphql-request to the GraphQLZero API.
  • src/index.tsx passes these options to useQuery in the Posts and Post components and shows "Background Updating..." while isFetching is true.
  • The Posts list calls queryClient.getQueryData(postsQueries.detail(post.id).queryKey) to style links whose detail is already cached.

To run this example:

  • npm install
  • npm run dev