Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Apollo Graphql Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-apollo-graphql-knowledge-patch)
---
name: apollo-graphql-knowledge-patch
description: Apollo GraphQL
version: null
license: MIT
metadata:
author: Nevaberry
---
# Apollo GraphQL Compatibility
Load this skill when migrating, configuring, or debugging Apollo Client,
Apollo Router, or Apollo Server. The references contain API changes,
configuration examples, and behavior needed for compatibility work.
## Reference index
| Reference | Topics |
| --- | --- |
| [Client migration](references/client-migration.md) | Removed APIs, imports, errors, links, HTTP transport, incremental handlers, typing, local state, testing, SSR |
| [Client data and cache](references/client-data-and-cache.md) | Fragments, query results, refetching, lazy queries, pagination, mutations, subscriptions, cache policies, custom scalars |
| [Router migration and security](references/router-migration-and-security.md) | Configuration upgrades, endpoints, CORS, JWT, authorization, validation, header masking, deployment |
| [Router caching and traffic](references/router-caching-and-traffic.md) | Response and entity caches, Redis, invalidation, limits, subscriptions, reloads, persisted queries |
| [Router Connectors and extensions](references/router-connectors-and-extensions.md) | Connector specifications and mappings, coprocessors, context keys, Rhai, Rust plugins |
| [Router execution and delivery](references/router-execution-and-delivery.md) | Query planning, demand control, operation limits, result coercion, error paths, deferred responses |
| [Router observability](references/router-observability.md) | Metric migration, exporters, sampling, selectors, logs, traces, reporting, resource diagnostics |
| [Server](references/server.md) | Runtime migration, integrations, proxies, HTTP, validation, incremental delivery, plugins, caches, landing pages |
## Breaking changes and deprecations
### Client construction and imports
Move top-level client `name` and `version` to `clientAwareness: { name, version }`.
Replace `connectToDevTools: true` with `devtools: { enabled: true }`.
Remove `typeDefs` from the client constructor and install `LocalState` for
`@client` fields, including fields backed by cache policies.
Drop `canonizeResults` from query and cache options when upgrading to 4.0;
equal result objects can now have different references.
The migration codemod requires Node.js support for loading ES modules through
`require()`. Run TypeScript and TSX parsers separately:
```sh
npx @apollo/client-codemod-migrate-3-to-4 --parser ts --extensions ts src
npx @apollo/client-codemod-migrate-3-to-4 --parser tsx --extensions tsx src
```
Imports redirected to `@apollo/client/v4-migration` carry migration instructions
in their type declarations and throw if used at runtime.
For generated operations, generate typed documents and pass them directly to
library hooks, for example `useQuery(GetItemDocument)` from `@apollo/client/react`.
Hooks from `@graphql-codegen/typescript-react-apollo` omit overloads needed for
v4's more precise typing.
### Client errors, observables, and links
Operation results use one `error` field; `ApolloError` is removed.
Use `CombinedGraphQLErrors.is(error)` or `CombinedProtocolErrors.is(error)` before
reading the matching class's `error.errors`. Read ordinary network errors directly.
Network failures follow `errorPolicy`: `"none"` rejects, `"all"` resolves with
`result.error`, and `"ignore"` suppresses the error. Resolved network failures
have `data: undefined`. Watched queries deliver errors through `next(result)`
and stay subscribed so they can recover on refetch.
Replace `ServerError.result` with `JSON.parse(error.bodyText)` when response JSON
is needed; handle parse failures because the response may contain non-JSON text.
`ObservableQuery` supports `subscribe` and `pipe` but no longer extends `Observable`;
use `from(observableQuery)` from `rxjs` for helpers requiring an RxJS observable.
When replacing `setContext` with `SetContextLink`, swap callback arguments to
`(prevContext, operation)`. The codemod leaves this change to you.
### Client query lifecycle
`notifyOnNetworkStatusChange` defaults to `true`. Pass `variables` and `context`
to the lazy query's `execute({ variables, context })`; configure `fetchPolicy`
on `useLazyQuery`. Calling `execute()` during render throws.
Unmounting aborts an in-flight lazy query with `AbortError` unless its promise
was retained. Starting another execution rejects the earlier execution with
`AbortError` unless it was retained. The hook result reflects only the most
recent execution, even if an earlier retained promise later resolves.
```ts
const pending = execute({ variables: { id } }).retain();
const result = await pending;
```
`fetchMore` defaults its own `errorPolicy` to `"none"`; pass `errorPolicy: "all"`
to `fetchMore` itself if it should accept partial data alongside errors.
The deprecated `ignoreResults` mutation option can be replaced by getting the
client through `useApolloClient()` and calling `client.mutate` directly when
component result-state synchronization is unwanted.
### Router configuration and telemetry migration
Router 2 no longer applies major-version configuration migrations at startup.
Preview and write upgrades explicitly; replace `--schema` with `router config schema`.
```bash
router config upgrade --diff router.yaml
router config upgrade router.yaml > router.next.yaml
mv router.next.yaml router.yaml
router config schema
```
Minor-version YAML migrations within the same major version are automatic.
From 2.13.0, remove `OTEL_EXPORTER_OTLP_ENDPOINT`,
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, and `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`;
configure endpoints in Router YAML because these environment variables prevent startup.
Use `http.server.request.duration` and `http.client.request.duration` in place
of the removed request counters and timers; use histogram counts for totals.
The observability reference contains the individual metric and selector mappings.
### Router cache, context, and Connector deprecations
Use top-level `response_cache` in place of `preview_response_cache`.
The preview entity-cache plugin warns at startup and will be removed in 3.0;
switch to `apollo.response_cache` with only one cache plugin enabled at a time.
Rename `connectors.subgraphs` to `connectors.sources` and
`persisted_queries.experimental_local_manifests` to `persisted_queries.local_manifests`.
Remove `traffic_shaping.deduplicate_variables`; variable deduplication is always enabled.
`context: deprecated` now warns at startup; migrate coprocessors to `context: all`
or a selective list of current context keys.
Router request limits move under `limits.router`, including
`limits.router.http2_max_headers_list_bytes`.
### Server runtime, integrations, and HTTP behavior
Before upgrading to Server 5, use Node.js 20.0.0 or later and `graphql` at least 16.11.0.
Move Express 4 middleware to `@as-integrations/express4`; use
`@as-integrations/express5` for Express 5. Both packages also work with Server 4.
Reporting and subscription callback plugins default to built-in Node.js `fetch`,
so update proxy settings specific to `node-fetch`.
`startStandaloneServer` uses Node's HTTP server directly; use `expressMiddleware`
if you depend on Express-specific behavior such as automatic `ETag` headers.
Variable coercion errors return HTTP 400 by default. Set
`status400ForVariableCoercionErrors: false` to preserve Server 4's HTTP 200 response.
Starting in Server 4.6.0, setting it to `true` lets clients and monitoring test
HTTP 400 behavior before upgrading; the option is planned for removal in a future major.
From Server 5.5.0, standalone GraphQL GET requests with a `Content-Type` other
than `application/json` receive HTTP 415; content-type parameters are allowed.
With default CSRF prevention, GET requests without `Content-Type` require a
non-empty `X-Apollo-Operation-Name` or `Apollo-Require-Preflight` header.
## Frequently used features and behavior
### Fragment reads, refetching, and cache updates
Use `useSuspenseFragment` to suspend until all requested fragment fields are
available in the cache. Pass `variables` when the fragment has required variables.
An array passed as `from` to `useFragment`, `useSuspenseFragment`, or
`client.watchFragment` returns a `data` array in the same order.
In `ObservableQuery.updateQuery`, use the callback's second-argument
`complete` and `previousData`; the deprecated first argument can contain partial data.
Returning `undefined` skips the update.
A `RefetchEventManager` with registered sources can refetch active queries on
window focus or network reconnect. `refetchOn` accepts a boolean, a predicate,
or an event map; per-query maps inherit watch-query defaults for omitted events.
### Incremental delivery
Configure `Defer20220824Handler` for the legacy `@defer` wire format and for Router.
Use `GraphQL17Alpha9Handler` with servers implementing the GraphQL.js 17 alpha 9
wire format. A query using `@stream` throws if no incremental handler is configured.
During deferred delivery, queries report `NetworkStatus.streaming` and keep
`loading: true`; `dataState === "streaming"` identifies the phase with some data available.
Custom multipart `fetch` implementations must provide a WHATWG `ReadableStream`
as `Response.body`; closing before the final multipart boundary produces an error.
Server 5.1.0 uses `graphql@17.0.0-alpha.9` and
`Accept: multipart/mixed; incrementalSpec=v0.2` for incremental delivery.
From Server 5.2.0, legacy `deferSpec=20220824` requests require passing
`legacyExecuteIncrementally` from `@yaacovcr/transform` as
`legacyExperimentalExecuteIncrementally` to `ApolloServer`.
### Client type inference
Declare `errorPolicy` and `returnPartialData` defaults through
`ApolloClient.DeclareDefaultOptions` when setting them in `defaultOptions`.
A required declared property opts into modern signatures and requires the
corresponding constructor default. Optional-only declarations retain classic
signatures by default. Set `TypeOverrides.signatureStyle` to `"modern"` to opt in
without a required default. Modern signatures reject explicit type arguments.
### Router response caching and traffic controls
Response caching can store subgraph root-field fetches and individual entity
representations in Redis, using subgraph `Cache-Control` TTLs. Cache tags support
targeted invalidation. Each enabled subgraph cache needs Redis settings at startup.
For response and entity caches, `no-store` permits hits and prevents writes;
`no-cache` bypasses lookups and permits writes.
From 2.13.0, Router and subgraph rate-limit or buffer-capacity rejections return HTTP 503.
Set `subscription.max_lifetime` to close subscriptions after a fixed duration;
omitting it leaves lifetime unlimited.
### Router security, mapping, and demand control
Sensitive headers are masked by default in logs, telemetry, coprocessor debug
logs, and hosted traces. Values copied into a coprocessor body or context remain
visible in its debug logs. Header selector `redact: allow` emits a raw value;
`redact: mask` forces masking.
Linking a subgraph to `connect/v0.4` suffices to enable that spec. When upgrading
mappings that read quoted input keys, prefix those keys with `$.` because primitive
tokens after a colon produce literals. Use `connect-migrate analyze` to compare mappings.
Per-subgraph demand control in `enforce` mode can skip an over-limit subgraph
while continuing the rest of the operation when the global limit passes.
### Server validation limits
Use `executionOptions.maxCoercionErrors` to cap variable-coercion errors and
`validationOptions.maxErrors` to cap document-validation errors.
`maxRecursiveSelections` caps selections after fragment expansion and is off by default;
`true` selects 10,000,000, or pass a numeric limit.
Only use `dangerouslyDisableValidation` when another trusted layer has already
validated every operation against the same schema.