Help us improve
Share bugs, ideas, or general feedback.
From apollo-skills
Guide for building React applications with Apollo Client 4.x. Covers setup, GraphQL queries/mutations with hooks, caching policies, reactive variables, and troubleshooting.
npx claudepluginhub apollographql/skills --plugin apollo-skillsHow this skill is triggered — by the user, by Claude, or both
Slash command
/apollo-skills:apollo-clientThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Version 4.x brings improved caching, better TypeScript support, and React 19 compatibility.
references/caching.mdreferences/error-handling.mdreferences/fragments.mdreferences/integration-client.mdreferences/integration-nextjs.mdreferences/integration-react-router.mdreferences/integration-tanstack-start.mdreferences/mutations.mdreferences/queries.mdreferences/state-management.mdreferences/suspense-hooks.mdreferences/troubleshooting.mdreferences/typescript-codegen.mdImplements Apollo Client patterns for GraphQL queries, mutations, cache management, and local state in React applications.
Guides structuring GraphQL client code with fragment co-location, normalized cache configuration, and optimistic updates for responsive UIs in React/Vue/Svelte apps.
Guides GraphQL schema design, resolvers, DataLoader for N+1 prevention, federation, subscriptions, and Apollo/urql clients. Use for efficient APIs with complex data relationships.
Share bugs, ideas, or general feedback.
Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Version 4.x brings improved caching, better TypeScript support, and React 19 compatibility.
Choose the integration guide that matches your application setup:
Each guide includes installation steps, configuration, and framework-specific patterns optimized for that environment.
import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client/react";
const GET_USER = gql`
query GetUser($id: ID!) {
user(id: $id) {
id
name
}
}
`;
function UserProfile({ userId }: { userId: string }) {
const { loading, error, data, dataState } = useQuery(GET_USER, {
variables: { id: userId },
});
if (loading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
// TypeScript note: for stricter type narrowing, you can also check `dataState === "complete"` before accessing data
return <div>{data?.user.name}</div>;
}
import { gql } from "@apollo/client";
import { useMutation } from "@apollo/client/react";
const CREATE_USER = gql`
mutation CreateUser($input: CreateUserInput!) {
createUser(input: $input) {
id
name
}
}
`;
function CreateUserForm() {
const [createUser, { loading, error }] = useMutation(CREATE_USER);
const handleSubmit = async (name: string) => {
await createUser({ variables: { input: { name } } });
};
return <button onClick={() => handleSubmit("John")}>Create User</button>;
}
import { Suspense } from "react";
import { useSuspenseQuery } from "@apollo/client/react";
function UserProfile({ userId }: { userId: string }) {
const { data } = useSuspenseQuery(GET_USER, {
variables: { id: userId },
});
return <div>{data.user.name}</div>;
}
function App() {
return (
<Suspense fallback={<p>Loading user...</p>}>
<UserProfile userId="1" />
</Suspense>
);
}
Detailed documentation for specific topics:
useFragment or useSuspenseFragment in all non-page-components. Use @defer to allow slow fields below the fold to stream in later and avoid blocking the page load.loading and error states in UI when using non-suspenseful hooks (useQuery, useLazyQuery). When using Suspense hooks (useSuspenseQuery, useBackgroundQuery), React handles this through <Suspense> boundaries and error boundaries.fetchPolicy to control cache behavior per queryrefetchQueries sparingly (prefer letting the cache update automatically)keyFields for types without id fieldkeyFields: false for types that don't include an identifier and are meant to group related fields under the parenttypePolicies for pagination and computed fieldsfetchPolicy per use case@defer for incremental delivery of deferred query parts, and @stream for streaming list fields (@stream available in Apollo Client 4.1+)useSuspenseQuery, useBackgroundQuery) in modern applications for better loading state handling and code simplicityApolloProvideruseSuspenseQuery, useBackgroundQuery) in modern applications for better DXcache-first for read-heavy data, network-only for real-time data