Minimal, hooks-based GraphQL client for React (v8.2.0, stable, maintained). Provides `useQuery`, `useMutation`, and `GraphQLProvider` with zero extra dependencies beyond React 17/18/19. Smaller bundle than Apollo Client (~3KB gzipped vs 30KB+), no cache or schema introspection by default. Ideal for lightweight React applications. Ships TypeScript definitions. Released under MIT. Current cadence: minor releases every few months.
npm install graphql-hooksNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up GraphQLProvider with a client, then uses useQuery to fetch posts.
If you relied on default caching, switch to graphql-hooks-memcache or implement custom cache.
new GraphQLClient({ url, headers: { ... } }) instead of new GraphQLClient(url, headers).Use onError: (err, query, variables) => console.error(err) instead.
Force refetch by providing a key prop that changes when you want to refetch, or call refetch from the returned object.
Wrap the component tree with <GraphQLProvider client={client}>.Use ES6 import syntax: import { GraphQLClient } from 'graphql-hooks'.Ensure all components using hooks are children of <GraphQLProvider>.