Apollo GraphQL Knowledge Patch
Use this skill when work involves recent Apollo Client, Apollo Server, Apollo Router, or Apollo Connectors behavior. Identify the product and installed version first, then read only the relevant topic reference.
Reference index
| Reference |
Topics |
| client-data-and-cache.md |
Query and mutation lifecycles, fragments, cache writes, local state, mocks, refetch events |
| client-migration.md |
Client 4 migration, packages, links, errors, RxJS, incremental delivery, SSR, modern typing |
| router-caching-and-traffic.md |
Backpressure, traffic shaping, persisted queries, Redis, response/entity caches, subscriptions |
| router-connectors-and-extensions.md |
Connector schemas and transport, coprocessors, Rhai, Rust plugins |
| router-execution-and-delivery.md |
Query planning, demand control, response validation, error paths, deferred delivery |
| router-migration-and-security.md |
Router upgrades, configuration, JWT, CORS, HTTP hardening, deployment, reloads |
| router-observability.md |
Metrics, selectors, spans, errors, exporters, cardinality, sampling |
| server.md |
Server 5 runtime, integrations, proxying, incremental protocols, execution limits, HTTP hardening |
Apply this patch
- Determine whether the task concerns Client, Server, Router, Connectors, or an integration between them.
- Read the project's manifest and lockfile to identify exact product versions before applying version-gated advice.
- For upgrades, preserve the intermediate migrations described below and in the product reference; do not jump straight to renamed configuration.
- For Router changes, check security, traffic, and telemetry defaults together because one upgrade can affect status codes, load shedding, and dashboards.
- For incremental delivery, align the Client handler, Server GraphQL.js alpha, and
Accept protocol exactly.
- Preserve explicit compatibility overrides unless the task authorizes their removal.
Breaking changes and required migrations
Apollo Client 4
- Add the
rxjs peer dependency.
- Import React APIs from
@apollo/client/react and MockedProvider from @apollo/client/testing/react.
- Use only public entry points; remove direct
.js and .cjs imports.
- Run
@apollo/client-codemod-migrate-3-to-4, then inspect every change rather than assuming the codemod covers custom links and local state.
- Replace constructor
uri, headers, and credentials with an explicit HttpLink supplied as link.
- Move client name/version under
clientAwareness, connectToDevTools under devtools.enabled, and rename disableNetworkFetches to prioritizeCacheValues.
- Replace render-prop components, HOCs, and
ApolloConsumer with hooks and useApolloClient.
- Replace
zen-observable operators with RxJS pipe operators. Wrap ObservableQuery in from() when an RxJS Observable is required.
- Replace
ObservableQuery.setOptions() with reobserve() and result() with firstValueFrom(from(query)).
- Replace removed
ApolloError and split error properties with the unified error value and class guards.
- Use
operation.setContext() because getContext() is frozen; read the cache from operation.client.cache.
- Opt into
@client resolution with LocalState, and implement fragmentMatches in custom caches.
Read client-migration.md before changing public imports, link composition, error handling, SSR, incremental handlers, or result types.
Apollo Server 5
- Upgrade to Node.js 20+ and
graphql 16.11+; ensure consumers support ES2023.
- Install
@as-integrations/express4 or @as-integrations/express5; middleware is no longer exported from @apollo/server/express4.
- Treat
startStandaloneServer as a Node HTTP integration, not embedded Express.
- Account for built-in
fetch in usage reporting, schema reporting, and subscription callbacks; old global-agent settings no longer proxy those calls.
- Expect invalid variable coercion to return HTTP 400 unless the temporary compatibility option disables it.
- Remove landing-page
precomputedNonce.
- Add DOM libraries explicitly to integration-test TypeScript projects that rely on them.
Read server.md for the required GraphQL.js alpha/protocol pairing, legacy executor setup, coercion and validation limits, and standalone request hardening.
Apollo Router 2
- Materialize cross-major YAML upgrades with
router config upgrade; Router does not apply them during major-version startup.
- Replace the removed
--schema flag with router config schema.
- Update context keys to their
apollo::... names in plugins, Rhai, coprocessors, and telemetry selectors.
- Convert endpoint
:name parameters to {name} and use named braced wildcards.
- Prefix body selector paths used for header propagation with
$.
- Replace removed remote-supergraph polling with an explicit download-to-local-file workflow when hot reload is required.
- Expect busy Router instances to reject rather than queue work; rollout monitoring must include 503/504 responses and CPU.
- Move deprecated Router metrics and exporters to OpenTelemetry equivalents before upgrading dashboards.
Read router-migration-and-security.md and router-observability.md before a major upgrade.
Apollo Client quick reference
Query and mutation lifecycle
- Prefer
useSuspenseFragment when a Suspense boundary should own incomplete-fragment loading.
- Do not add new
useQuery or useLazyQuery onCompleted/onError logic; those callbacks are deprecated.
- In
updateQuery, use second-argument previousData only when complete is true; return undefined to skip.
- Catch errors thrown by
useMutation onCompleted through the returned promise.
- Replace
useMutation.ignoreResults with client.mutate() when component result state is unwanted.
- Treat multipart query deduplication as lasting through the final chunk.
Client 4 result behavior
- Branch on
dataState (empty, partial, streaming, complete) instead of inferring completeness from data alone.
- Remember
notifyOnNetworkStatusChange defaults to true and unobserved queries are not tracked for active/all refetches.
- Put
variables and context on useLazyQuery's execute call; option changes alone do not execute.
- Network and GraphQL failures obey
errorPolicy; observable query failures normally arrive through next, not the observer's error callback.
fetchMore defaults its own error policy to none, changes variable merging when a replacement query is supplied, and rejects cache-only use.
- Subscription observables are lazy and restartable; default subscription deduplication means a late subscriber misses the connection's initial value.
Client type precision
- Declare runtime
defaultOptions under ApolloClient.DeclareDefaultOptions when types must reflect them.
- Choose
TypeOverrides.signatureStyle: "modern" for document-inferred, default-aware APIs; use classic only as a migration bridge.
- Keep multi-client default declarations narrow because optional declarations also admit the runtime default.
- Error-policy-aware types specialize
client.query, mutations, lazy execute, refetch, and fetchMore results.
Read client-data-and-cache.md for fragments, local fields, cache write extensions, partial arrays, mocks, and RefetchEventManager.
Apollo Server quick reference
Incremental delivery
- Initial Server 5 incremental delivery is pinned to GraphQL.js alpha.2 and the 2022-08-24 defer protocol.
- Server 5.1 moves to GraphQL.js alpha.9 and protocol v0.2.
- From Server 5.2, legacy protocol support requires both
@yaacovcr/transform and an explicit legacyExperimentalExecuteIncrementally function.
- Match the client handler to the server protocol: an incorrect handler may reject or merge chunks incorrectly.
Standalone hardening
- Standalone accepts only UTF-8, UTF-16 LE/BE, and UTF-32 LE/BE request bodies.
- Standalone rejects a GET request carrying a non-JSON
Content-Type; a headerless request remains subject to CSRF-preflight requirements.
Apollo Router quick reference
Security and HTTP behavior
- Keep introspection depth protection enabled unless a specific valid query requires otherwise.
- Treat invalid CORS as a startup error and configure per-origin policies explicitly.
- Configure JWT issuers and audiences as lists; validate string/array claim types and use per-JWKS
allow_missing_exp only deliberately.
- Apply root authorization directives to individual fields when policy must remain subgraph-local.
- Expect strict input-object variable validation and GET content-type enforcement on current releases.
- Configure recursive-selection and downstream body-size limits rather than relying on unlimited input or response sizes.
- Header masking is active by default and spans logs, telemetry, coprocessors, and trace forwarding; copied body/context secrets need separate handling.
Caching and traffic
- Use GA
response_cache, not the earlier preview namespace.
- Put response-cache TTL on the subgraph entry; subgraph
Cache-Control: max-age overrides configured fallback TTL.
- Treat
no-store and no-cache differently: the former can serve old data but forbids storage, while the latter needs unsupported revalidation before serving.
- Plan for cache-key regeneration after schema, entity-key, or expiry algorithm changes.
- Flush a Redis namespace when re-enabling an invalidation index that must cover entries written while disabled.
- Current capacity/rate-limit rejection is HTTP 503; do not retain alerts built around the brief 429 behavior.
- Set
ignore_auth_context for subscription deduplication only when streams are truly non-personalized.
Read router-caching-and-traffic.md before changing Redis topology, cache invalidation, rate limits, subscriptions, or connection settings.
Connectors and extensions
- Current default Connector resolution uses v0.3; explicitly linked v0.2 schemas remain unchanged.
- In v0.4, primitive object-property values are literals; qualify data lookups explicitly.
- Use the separate
connect-migrate CLI to classify v0.4 rewrites and manual cases.
- Replace
connectors.subgraphs with connectors.sources and remove the deprecated v0.4 preview flag.
- Use stage-specific coprocessor URLs and selective response bodies when only part of a payload may leave the Router.
- In Rust plugins, emit metrics through the Router OpenTelemetry meter provider and update the one-time cloned service lifecycle.
Read router-connectors-and-extensions.md for Connector content types, mapping syntax, TLS, coprocessor stages, Rhai behavior, and Rust API replacements.
Execution and demand control
- Use query-planning cancellation
measure mode before enforce; memory ceilings have platform/build constraints.
- Per-subgraph demand limits null only the skipped subgraph values while other work continues.
- Current actual-cost calculation includes intermediate subgraph work unless
response_shape is selected.
- Enable result-coercion errors when clients should receive schema/value mismatches, including missing merged fields.
- Preserve entity-key and
__typename dependencies when reasoning about deferred plan reduction.
Read router-execution-and-delivery.md for exact planning, cost, response, and error-path behavior.
Telemetry
- Generic
OTEL_EXPORTER_OTLP_*_ENDPOINT variables now prevent Router startup; remove inherited values and configure exporters in Router YAML.
- Use
response_errors and its aggregate selectors instead of capturing entire response bodies where possible.
- Size histogram buckets to cover configured timeouts; defaults stop at 10 seconds.
- Set cardinality limits knowingly, monitor the overflow metric, and remember overflow collapses into an
otel_metric_overflow series.
- A view without explicit aggregation preserves a counter or gauge's native aggregation.
- Exporter-specific sampling cannot exceed the common trace sampler.
http_client attributes attach to http_request and do not support conditions or static selectors.
Read router-observability.md before editing dashboards, selectors, custom instruments, exporters, or trace sampling.
1---2name: apollo-graphql-knowledge-patch-23description: Apollo GraphQL4license: MIT5---678# Apollo GraphQL Knowledge Patch910Use this skill when work involves recent Apollo Client, Apollo Server, Apollo Router, or Apollo Connectors behavior. Identify the product and installed version first, then read only the relevant topic reference.1112## Reference index1314| Reference | Topics |15| --- | --- |16| [client-data-and-cache.md](references/client-data-and-cache.md) | Query and mutation lifecycles, fragments, cache writes, local state, mocks, refetch events |17| [client-migration.md](references/client-migration.md) | Client 4 migration, packages, links, errors, RxJS, incremental delivery, SSR, modern typing |18| [router-caching-and-traffic.md](references/router-caching-and-traffic.md) | Backpressure, traffic shaping, persisted queries, Redis, response/entity caches, subscriptions |19| [router-connectors-and-extensions.md](references/router-connectors-and-extensions.md) | Connector schemas and transport, coprocessors, Rhai, Rust plugins |20| [router-execution-and-delivery.md](references/router-execution-and-delivery.md) | Query planning, demand control, response validation, error paths, deferred delivery |21| [router-migration-and-security.md](references/router-migration-and-security.md) | Router upgrades, configuration, JWT, CORS, HTTP hardening, deployment, reloads |22| [router-observability.md](references/router-observability.md) | Metrics, selectors, spans, errors, exporters, cardinality, sampling |23| [server.md](references/server.md) | Server 5 runtime, integrations, proxying, incremental protocols, execution limits, HTTP hardening |2425## Apply this patch26271. Determine whether the task concerns Client, Server, Router, Connectors, or an integration between them.282. Read the project's manifest and lockfile to identify exact product versions before applying version-gated advice.293. For upgrades, preserve the intermediate migrations described below and in the product reference; do not jump straight to renamed configuration.304. For Router changes, check security, traffic, and telemetry defaults together because one upgrade can affect status codes, load shedding, and dashboards.315. For incremental delivery, align the Client handler, Server GraphQL.js alpha, and `Accept` protocol exactly.326. Preserve explicit compatibility overrides unless the task authorizes their removal.3334## Breaking changes and required migrations3536### Apollo Client 43738- Add the `rxjs` peer dependency.39- Import React APIs from `@apollo/client/react` and `MockedProvider` from `@apollo/client/testing/react`.40- Use only public entry points; remove direct `.js` and `.cjs` imports.41- Run `@apollo/client-codemod-migrate-3-to-4`, then inspect every change rather than assuming the codemod covers custom links and local state.42- Replace constructor `uri`, `headers`, and `credentials` with an explicit `HttpLink` supplied as `link`.43- Move client name/version under `clientAwareness`, `connectToDevTools` under `devtools.enabled`, and rename `disableNetworkFetches` to `prioritizeCacheValues`.44- Replace render-prop components, HOCs, and `ApolloConsumer` with hooks and `useApolloClient`.45- Replace `zen-observable` operators with RxJS `pipe` operators. Wrap `ObservableQuery` in `from()` when an RxJS `Observable` is required.46- Replace `ObservableQuery.setOptions()` with `reobserve()` and `result()` with `firstValueFrom(from(query))`.47- Replace removed `ApolloError` and split error properties with the unified `error` value and class guards.48- Use `operation.setContext()` because `getContext()` is frozen; read the cache from `operation.client.cache`.49- Opt into `@client` resolution with `LocalState`, and implement `fragmentMatches` in custom caches.5051Read [client-migration.md](references/client-migration.md) before changing public imports, link composition, error handling, SSR, incremental handlers, or result types.5253### Apollo Server 55455- Upgrade to Node.js 20+ and `graphql` 16.11+; ensure consumers support ES2023.56- Install `@as-integrations/express4` or `@as-integrations/express5`; middleware is no longer exported from `@apollo/server/express4`.57- Treat `startStandaloneServer` as a Node HTTP integration, not embedded Express.58- Account for built-in `fetch` in usage reporting, schema reporting, and subscription callbacks; old `global-agent` settings no longer proxy those calls.59- Expect invalid variable coercion to return HTTP 400 unless the temporary compatibility option disables it.60- Remove landing-page `precomputedNonce`.61- Add DOM libraries explicitly to integration-test TypeScript projects that rely on them.6263Read [server.md](references/server.md) for the required GraphQL.js alpha/protocol pairing, legacy executor setup, coercion and validation limits, and standalone request hardening.6465### Apollo Router 26667- Materialize cross-major YAML upgrades with `router config upgrade`; Router does not apply them during major-version startup.68- Replace the removed `--schema` flag with `router config schema`.69- Update context keys to their `apollo::...` names in plugins, Rhai, coprocessors, and telemetry selectors.70- Convert endpoint `:name` parameters to `{name}` and use named braced wildcards.71- Prefix body selector paths used for header propagation with `$`.72- Replace removed remote-supergraph polling with an explicit download-to-local-file workflow when hot reload is required.73- Expect busy Router instances to reject rather than queue work; rollout monitoring must include 503/504 responses and CPU.74- Move deprecated Router metrics and exporters to OpenTelemetry equivalents before upgrading dashboards.7576Read [router-migration-and-security.md](references/router-migration-and-security.md) and [router-observability.md](references/router-observability.md) before a major upgrade.7778## Apollo Client quick reference7980### Query and mutation lifecycle8182- Prefer `useSuspenseFragment` when a Suspense boundary should own incomplete-fragment loading.83- Do not add new `useQuery` or `useLazyQuery` `onCompleted`/`onError` logic; those callbacks are deprecated.84- In `updateQuery`, use second-argument `previousData` only when `complete` is true; return `undefined` to skip.85- Catch errors thrown by `useMutation` `onCompleted` through the returned promise.86- Replace `useMutation.ignoreResults` with `client.mutate()` when component result state is unwanted.87- Treat multipart query deduplication as lasting through the final chunk.8889### Client 4 result behavior9091- Branch on `dataState` (`empty`, `partial`, `streaming`, `complete`) instead of inferring completeness from `data` alone.92- Remember `notifyOnNetworkStatusChange` defaults to true and unobserved queries are not tracked for active/all refetches.93- Put `variables` and `context` on `useLazyQuery`'s execute call; option changes alone do not execute.94- Network and GraphQL failures obey `errorPolicy`; observable query failures normally arrive through `next`, not the observer's error callback.95- `fetchMore` defaults its own error policy to `none`, changes variable merging when a replacement query is supplied, and rejects `cache-only` use.96- Subscription observables are lazy and restartable; default subscription deduplication means a late subscriber misses the connection's initial value.9798### Client type precision99100- Declare runtime `defaultOptions` under `ApolloClient.DeclareDefaultOptions` when types must reflect them.101- Choose `TypeOverrides.signatureStyle: "modern"` for document-inferred, default-aware APIs; use `classic` only as a migration bridge.102- Keep multi-client default declarations narrow because optional declarations also admit the runtime default.103- Error-policy-aware types specialize `client.query`, mutations, lazy execute, `refetch`, and `fetchMore` results.104105Read [client-data-and-cache.md](references/client-data-and-cache.md) for fragments, local fields, cache write extensions, partial arrays, mocks, and `RefetchEventManager`.106107## Apollo Server quick reference108109### Incremental delivery110111- Initial Server 5 incremental delivery is pinned to GraphQL.js alpha.2 and the 2022-08-24 defer protocol.112- Server 5.1 moves to GraphQL.js alpha.9 and protocol v0.2.113- From Server 5.2, legacy protocol support requires both `@yaacovcr/transform` and an explicit `legacyExperimentalExecuteIncrementally` function.114- Match the client handler to the server protocol: an incorrect handler may reject or merge chunks incorrectly.115116### Standalone hardening117118- Standalone accepts only UTF-8, UTF-16 LE/BE, and UTF-32 LE/BE request bodies.119- Standalone rejects a GET request carrying a non-JSON `Content-Type`; a headerless request remains subject to CSRF-preflight requirements.120121## Apollo Router quick reference122123### Security and HTTP behavior124125- Keep introspection depth protection enabled unless a specific valid query requires otherwise.126- Treat invalid CORS as a startup error and configure per-origin policies explicitly.127- Configure JWT issuers and audiences as lists; validate string/array claim types and use per-JWKS `allow_missing_exp` only deliberately.128- Apply root authorization directives to individual fields when policy must remain subgraph-local.129- Expect strict input-object variable validation and GET content-type enforcement on current releases.130- Configure recursive-selection and downstream body-size limits rather than relying on unlimited input or response sizes.131- Header masking is active by default and spans logs, telemetry, coprocessors, and trace forwarding; copied body/context secrets need separate handling.132133### Caching and traffic134135- Use GA `response_cache`, not the earlier preview namespace.136- Put response-cache TTL on the subgraph entry; subgraph `Cache-Control: max-age` overrides configured fallback TTL.137- Treat `no-store` and `no-cache` differently: the former can serve old data but forbids storage, while the latter needs unsupported revalidation before serving.138- Plan for cache-key regeneration after schema, entity-key, or expiry algorithm changes.139- Flush a Redis namespace when re-enabling an invalidation index that must cover entries written while disabled.140- Current capacity/rate-limit rejection is HTTP 503; do not retain alerts built around the brief 429 behavior.141- Set `ignore_auth_context` for subscription deduplication only when streams are truly non-personalized.142143Read [router-caching-and-traffic.md](references/router-caching-and-traffic.md) before changing Redis topology, cache invalidation, rate limits, subscriptions, or connection settings.144145### Connectors and extensions146147- Current default Connector resolution uses v0.3; explicitly linked v0.2 schemas remain unchanged.148- In v0.4, primitive object-property values are literals; qualify data lookups explicitly.149- Use the separate `connect-migrate` CLI to classify v0.4 rewrites and manual cases.150- Replace `connectors.subgraphs` with `connectors.sources` and remove the deprecated v0.4 preview flag.151- Use stage-specific coprocessor URLs and selective response bodies when only part of a payload may leave the Router.152- In Rust plugins, emit metrics through the Router OpenTelemetry meter provider and update the one-time cloned service lifecycle.153154Read [router-connectors-and-extensions.md](references/router-connectors-and-extensions.md) for Connector content types, mapping syntax, TLS, coprocessor stages, Rhai behavior, and Rust API replacements.155156### Execution and demand control157158- Use query-planning cancellation `measure` mode before `enforce`; memory ceilings have platform/build constraints.159- Per-subgraph demand limits null only the skipped subgraph values while other work continues.160- Current actual-cost calculation includes intermediate subgraph work unless `response_shape` is selected.161- Enable result-coercion errors when clients should receive schema/value mismatches, including missing merged fields.162- Preserve entity-key and `__typename` dependencies when reasoning about deferred plan reduction.163164Read [router-execution-and-delivery.md](references/router-execution-and-delivery.md) for exact planning, cost, response, and error-path behavior.165166### Telemetry167168- Generic `OTEL_EXPORTER_OTLP_*_ENDPOINT` variables now prevent Router startup; remove inherited values and configure exporters in Router YAML.169- Use `response_errors` and its aggregate selectors instead of capturing entire response bodies where possible.170- Size histogram buckets to cover configured timeouts; defaults stop at 10 seconds.171- Set cardinality limits knowingly, monitor the overflow metric, and remember overflow collapses into an `otel_metric_overflow` series.172- A view without explicit aggregation preserves a counter or gauge's native aggregation.173- Exporter-specific sampling cannot exceed the common trace sampler.174- `http_client` attributes attach to `http_request` and do not support conditions or static selectors.175176Read [router-observability.md](references/router-observability.md) before editing dashboards, selectors, custom instruments, exporters, or trace sampling.