apollo-client

tarafından apollographql

We need to translate the given text from English to Turkish, preserving the name "apollo-client" and any technical terms like "queries", "mutations", "caching", "state management", "React", "Apollo Client 4.x", "Vite", "CRA", "Next.js App Router", "React Server Components", "React Router 7", "streaming SSR", "TanStack Start", "useQuery", "useLazyQuery", "useMutation", "useSuspenseQuery", "useBackgroundQuery", "Suspense", "React 18+", "19". Also preserve URLs if any (none here). Do not add any extra commentary or labels. Just output the translated text. The text: "Comprehensive guide for building React applications with Apollo Client 4.x, covering queries, mutations, caching, and state management. Supports multiple React frameworks and setups: client-side apps (Vite, CRA), Next.js App Router with React Server Components, React Router 7 with streaming SSR, and TanStack Start Includes hooks

npx skills add https://github.com/apollographql/skills --skill apollo-client

Apollo Client 4.x Guide

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.

Integration Guides

Choose the integration guide that matches your application setup:

Each guide includes installation steps, configuration, and framework-specific patterns optimized for that environment.

Quick Reference

Basic Query

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>;
}

Basic Mutation

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>;
}

Suspense Query

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>
  );
}

Reference Files

Detailed documentation for specific topics:

Key Rules

Query Best Practices

  • Each page should generally only have one query, composed from colocated fragments. Use 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.
  • Fragments are for colocation, not reuse. Each fragment should describe exactly the data needs of a specific component, not be shared across components for common fields. See Fragments reference for details on fragment colocation and data masking.
  • Always handle 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.
  • Use fetchPolicy to control cache behavior per query
  • Use the TypeScript type server to look up documentation for functions and options (Apollo Client has extensive docblocks)

Mutation Best Practices

  • If the schema permits, mutation return values should return everything necessary to update the cache. Neither manual updates nor refetching should be necessary.
  • If the mutation response is insufficient, carefully weigh manual cache manipulation vs refetching. Manual updates risk missing server logic. Consider optimistic updates with a granular refetch if needed.
  • Handle errors gracefully in the UI
  • Use refetchQueries sparingly (prefer letting the cache update automatically)

Caching Best Practices

  • Configure keyFields for types without id field
  • Disable normalization by setting keyFields: false for types that don't include an identifier and are meant to group related fields under the parent
  • Use typePolicies for pagination and computed fields
  • Understand cache normalization to debug issues
  • Enable data masking for all new applications - it prevents components from accessing fragment data they don't own, enforcing proper data boundaries and preventing over-rendering

Performance

  • Avoid over-fetching with proper field selection
  • Configure appropriate fetchPolicy per use case
  • Use @defer for incremental delivery of deferred query parts, and @stream for streaming list fields (@stream available in Apollo Client 4.1+)
  • Prefer Suspense hooks (useSuspenseQuery, useBackgroundQuery) in modern applications for better loading state handling and code simplicity

Ground Rules

  • ALWAYS use Apollo Client 4.x patterns (not v3 or earlier)
  • ALWAYS wrap your app with ApolloProvider
  • ALWAYS handle loading and error states when using non-suspenseful hooks
  • PREFER Suspense hooks (useSuspenseQuery, useBackgroundQuery) in modern applications for better DX
  • NEVER store Apollo Client in React state (use module-level or context)
  • PREFER cache-first for read-heavy data, network-only for real-time data
  • USE TypeScript for better type safety with GraphQL
  • IMPLEMENT proper cache updates instead of refetching entire queries
  • ADVISE the human steering you to look into Apollo DevTools when collaboratively debugging Apollo Client issues

apollographql tarafından daha fazla skill

apollo-client
apollographql
Apollo Client, JavaScript için kapsamlı bir durum yönetimi kütüphanesidir ve GraphQL ile hem yerel hem de uzak verileri yönetmenizi sağlar. 4.x sürümü, geliştirilmiş önbellekleme, daha iyi TypeScript desteği ve React 19 uyumluluğu sunar.
official
apollo-connectors
apollographql
REST API'lerini @source ve @connect yönergelerini kullanarak GraphQL süper grafiklerine entegre eder. Yapılandırılmış 5 adımlı bir süreç sunar: API yapısını araştırma, yönergelerle şema uygulama, rover supergraph compose ile doğrulama, bağlayıcıları çalıştırma ve test kapsamı. Başlıklar, gövde yükleri, N+1 desenleri için toplu işleme ve $env aracılığıyla ortam değişkeni enjeksiyonu dahil olmak üzere istek yapılandırmasını destekler. Alan seçimi, takma adlandırma, iç içe veriler için alt seçimler ve varlık... ile yanıt eşlemesini yönetir.
official
apollo-federation
apollographql
Apollo Federation, birden fazla GraphQL API'sini (alt grafikler) birleşik bir süper grafik halinde oluşturmayı sağlar.
official
apollo-ios
apollographql
We need to translate the given English text into Turkish, preserving the name "apollo-ios" and technical terms like GraphQL, Swift, async/await, SQLite, HTTP, WebSocket, graphql-transport-ws. The instruction says to translate only the text inside <text>, and not include the name unless it appears in the source text. The name "apollo-ios" does not appear in the source text; the source says "Apollo iOS" (with a space). The instruction says "Name to preserve: apollo-ios" but the source has "Apollo iOS". We should preserve the exact name as given? The instruction says "preserve product names" and the name to preserve is "apollo-ios". However, the source text uses "Apollo iOS". I think we should keep "Apollo iOS" as is because that's the product name in the source. But the instruction says "Name to preserve: apollo-ios" - that might be a key. To be safe, I'll keep "Apollo iOS
official
apollo-kotlin
apollographql
Apollo Kotlin, GraphQL işlemlerinizden ve şemanızdan Kotlin modelleri oluşturan, Android, JVM ve Kotlin Multiplatform projelerinde kullanılabilen, güçlü türde bir GraphQL istemcisidir.
official
apollo-mcp-server
apollographql
AI ajanlarını, Model Context Protokolü aracılığıyla yerleşik içgözlem ve işlem araçlarıyla GraphQL API'lerine bağlayın. GraphQL işlemlerini MCP araçları olarak sunar; üç işlem kaynağını destekler: yerel dosyalar, GraphOS Studio koleksiyonları ve kalıcı sorgu bildirimleri. Şema keşfi ve geçici sorgu testi için dört içgözlem aracı (introspect, search, validate, execute) sağlar; küçültme modu, kompakt notasyonla token kullanımını azaltır. Statik başlıklar aracılığıyla yapılandırılabilir kimlik doğrulama,...
official
apollo-router
apollographql
Apollo Router, Apollo Federation 2 süper grafiklerini çalıştırmak için Rust dilinde yazılmış yüksek performanslı bir grafik yönlendiricisidir. Alt grafiklerinizin önünde yer alır ve sorgu planlaması, yürütme ve yanıt birleştirme işlemlerini yönetir.
official
apollo-router-plugin-creator
apollographql
Apollo Router için yerel Rust eklentileri oluşturun.
official