Repository navigation
Releases
v2.16.5
🐛 Fixes
Cache debugger and private queries gauge report what the response cache did (PR #10436)
The cache debugger now reports shouldStore: false when the response cache did not store the data:
- requests for a query the router has marked as private when no
private_idis configured, because those requests skip the cache; - responses and entities with GraphQL errors, and root-field responses with no data.
shouldStore is the cache's decision to store an entry. It does not confirm that the write to Redis succeeded.
The apollo.router.response_cache.private_queries.lru.size gauge now also counts queries marked as private by entity fetches, so its value can rise after upgrading.
By @BrynCooke in #10436
Keep @deprecated on fields an interface does not declare (PR #10460)
The federation 3 compatibility upgrade strips @deprecated from an implementing field when the matching interface field is not deprecated, because the GraphQL September 2025 spec disallows it. It applied that check to every field on the implementing type, so fields the interface does not declare also lost their @deprecated, and composition emitted a spurious DEPRECATED_IMPLEMENTING_FIELD_WITHOUT_INTERFACE hint.
Only fields the interface declares without @deprecated are now stripped.
interface Node { id: ID! }
type User implements Node {
id: ID!
# previously lost its @deprecated during composition
name: String @deprecated(reason: "use displayName")
}By @tninesling in #10460
Error responses no longer turn off response caching for a query
With response caching enabled, the router keeps a list of subgraph queries that return private data. Without private_id, requests for a query on that list skip the cache. Before this fix, any response with Cache-Control: private put its query on the list, including error responses. Many frameworks send private on errors, so one failed request could turn off caching for that query, for every variable value, until the entry was evicted or the router restarted.
Now a response marks its query as private only if it succeeded and its Cache-Control header allows storing (no no-store, and a TTL above zero). A subgraph response succeeds when it has a 2xx status and no GraphQL errors. This applies to root fields and entities.
By @BrynCooke in #10437
Include the mutation base cost in demand control actual cost
Demand control adds a base cost of 10 to the estimated cost of every mutation, but the actual cost did not include it. Every mutation reported a constant cost.delta of 10 even when list size estimates were exact. The actual cost now includes the same base cost.
By @tninesling in #10521
Fix CONNECTORS_CANNOT_RESOLVE_KEY and router startup failure when a connector reads $this through ->first
A field-level @connect on an entity that read a $this value through ->first (for example queryParams: "id: $this.tagIds->first") failed composition with CONNECTORS_CANNOT_RESOLVE_KEY. With a supergraph composed by an older version, the router refused to start with An internal error has occurred, please report this bug to Apollo. Details: error creating resolvable key.
The cause was in how connectors work out which $this fields an entity key needs. ->first was recorded as a read of list index 0, so the synthesized key came out as tagIds { "0" }, which is not a valid field set. List indexes are no longer recorded, so the key is now tagIds, the same as for ->last or a plain $this.tagIds. Schemas like this now compose and the router starts.
Reading fields from the first element of a list of objects, such as $this.items->first.id or $this.items->first { id }, also composes now, with the key items { id }. This never composed in earlier versions. A bare $this.items->first on a list of objects is still rejected with CONNECTORS_CANNOT_RESOLVE_KEY, the same as a bare $this.items, because the key needs to select fields from the objects.
When a connector's key still can't be built, the error now names the connector and includes the field set errors, instead of only saying error creating resolvable key.
Fetch @requires fields only when the requiring field is selected
When a field with @requires was under @skip/@include and shared its entity fetch with an unconditional sibling field, the planner correctly fetched the required fields only under that condition, but listed them unconditionally in the requires inputs of the entity fetch. When the condition did not hold at runtime, the required fields were absent, the entity representation was invalid, and the entity fetch was skipped for that entity, so the unconditional sibling field silently came back as null. When the required fields were nullable, the representation was instead sent with them set to null, which some subgraphs reject.
For example, given a subgraph like this, where weight is resolved by another subgraph:
type Product @key(fields: "id") {
id: ID!
inStock: Boolean
weight: Int! @external
shippingEstimate: Int @requires(fields: "weight")
}this query returned "inStock": null whenever $withShipping was false, even though inStock isn't conditional:
query Product($withShipping: Boolean!) {
product {
inStock
shippingEstimate @include(if: $withShipping)
}
}The inline fragments of a fetch node's requires can now carry @skip/@include conditions (serialized as a conditions list on the fragment), and the router evaluates them when building entity representations: a fragment excluded by its conditions contributes nothing to the representation. Fetches shared between conditional and unconditional fields stay merged, so this does not add subgraph requests.
The same mechanism also preserves conditions on the entity fetch following a @requires when two sibling selections carry opposite conditions on the same variable (for example ... @include(if: $v) and ... @skip(if: $v)): those conditions were previously dropped from that fetch, so the subgraph was asked for fields the client had excluded, with the union of both @requires field sets as inputs. And when every selection leading to a @requires field is conditional, the entity fetch following it is now wrapped in the corresponding Skip/Include node instead of being executed unconditionally.
By @sachindshinde in #10566
Fix connect/v0.4 routing entity resolution through a non-entity Query connector
Under connect/v0.4, when a @key entity had both a type-level reference-resolver @connect (mapping from $this) and a separate Query field @connect returning that same type (mapping from $args, with entity unset), connector expansion copied the entity's declared @key onto the Query-field connector's generated subgraph as resolvable. That gave the query planner a second, spurious entity path, so it could resolve entity references through the Query-field connector — where $args is empty during entity resolution — sending a request with the query parameters stripped and surfacing an upstream error (e.g. a 400 reported as CONNECTOR_FETCH).
connect/v0.3 was never affected, so bumping only the @link from v0.3 to v0.4 could break a previously working schema. Expansion now only copies keys for @interfaceObject types, and always as resolvable: false, matching the v0.3 behavior.
Reduce memory use and repeated work during query graph construction (PR #10358)
Dense federated query graphs, including connector-expanded schemas, could reserve excessive memory and repeatedly filter identical outgoing edges during graph construction. This increased the cost of schema composition and query planner initialization.
Root-resolution and subgraph-entry transitions now reuse the final filtered followups for each destination. Filtered key followup vectors grow with the surviving edges instead of reserving space for every candidate. Transitions that retain all candidates keep exact-size preallocation, avoiding excess capacity on wide graphs.
Followup edge membership and ordering are preserved, and no configuration changes are required.
Allow nested object literals in requestless connectors (PR #10394)
A @connect directive with no http: (a virtual connector) failed composition with REQUESTLESS_SELECTION_USES_REQUEST_DATA when its selection contained a nested object literal, such as price: { amount: 1395, currencyCode: "USD" }, even though it reads nothing from a response. These selections now compose as expected. Selections that do read the response body, like price { amount } or a bare $, are still rejected.
Restore structured JSON for valuable event fields in JSON logs (PR #10482)
Event fields recorded with tracing::field::valuable are written as nested JSON objects again by the JSON log formatter, instead of flat Debug strings.
A router built with --cfg tracing_unstable — for example alongside a native Rust plugin that logs a #[derive(Valuable)] struct — used to render such a field as structured JSON:
"log": { "client_id": "abc", "entitlements": { "bypass": true } }Since the JS...
v2.19.0
🚀 Features
Response caching for Apollo Connectors
Response caching now applies to Apollo Connectors, not just GraphQL subgraph fetches. Connector (REST/HTTP) responses can be cached in Redis and reused across requests, driven by the same Cache-Control semantics as the existing subgraph feature. Configure it under a new response_cache.connector block, keyed by connector source (subgraph_name.source_name):
response_cache:
enabled: true
connector:
all:
enabled: true
ttl: 60s
redis:
urls: ["redis://..."]
sources:
products.ecom_api:
ttl: 5mBehavior mirrors subgraph response caching:
- TTL comes from the upstream
Cache-Controlheader (max-age/s-maxage, adjusted forAge), falling back to the configuredttlwhen the REST API sends noCache-Controlheader. That fallback governs the router's own storage only: a response with noCache-Controlheader contributesno-storeto the client-facingCache-Controlheader, so the router never advertises a lifetime to clients or CDNs that the API did not ask for.ttlis therefore required configuration wherever connector caching is enabled with Redis. - Cache-key request headers are explicit and required. Because a connector calls your REST API directly, the router cannot infer which request headers change the API's response, so you declare them with
cache_key_headers(onconnector.all, per source, or both). Only listed headers partition cache entries; an empty list is a valid "no header partitions the cache" choice; and the router refuses to start if a storage-backed, enabled source has no resolved value. Omitting a header your API varies on shares one caller's cached response with another (a data-disclosure risk); listing a header that doesn't affect the response needlessly fragments the cache — so list exactly the headers whose values change the response. See Connector cache-key headers. - Per-user caching via
private_idwhen a response isCache-Control: private. - Invalidation through the existing
/invalidationendpoint. Connector entries are addressed withsources(forcache_tagrequests) or theconnector/type-with-sourcekinds, and are authorized by the connector source's own shared key — separately from subgraph invalidation. - Not cached: mutations and client-batched GraphQL requests.
Customization on a cache hit. Connector root fields are cached at the connector HTTP request level, so a coprocessor's ConnectorRequest/ConnectorResponse stages still run when a root field is served from cache. A cached response is replayed as an ordinary connector response, carrying the status the API returned when the entry was stored along with its cache-control headers, so a coprocessor does not need to distinguish a cache hit from a live call; response headers other than cache-control are not stored and so are absent on a hit. Connector entity fetches are cached above the point where one GraphQL fetch fans out into HTTP requests, so a fully cached entity fetch runs no connector coprocessor stages at all, and no connector-level telemetry, header propagation, traffic shaping or request limits. Rhai has no connector hook in either case. See Response Cache Customization.
Connector and subgraph caching can share a Redis instance without collision: connector cache keys and their invalidation indexes are namespaced separately from subgraph entries.
Off by default; existing deployments see no behavior change. In particular, a config that sets only response_cache.connector (a connectors-only deployment) does not implicitly enable subgraph-side caching.
By @andrewmcgivery, @TylerBloom, @briannafugate408 and @benjamn in #9171
Add the ->withWarning and ->withError mapping methods for connectors
Connector mappings can now flag a suspect value without failing the field. Both methods pass their input through unchanged:
->withWarning("...")records a diagnostic for the mapping author, visible in the connectors debugger and theconnector_response_mapping_problemstelemetry selector. It never reaches clients.->withError("...")(or->withError({ message, extensions })) reports an error to the client in the response'sextensions.connectorErrorsarray, alongside the data. It is counted by theapollo.router.graphql_errormetric.
availability: stock_code->match(
["A", "IN_STOCK"],
[@, @->withError("Unrecognized stock code")]
)Declared errors follow the include_subgraph_errors setting for the connector's subgraph, so they are redacted by default. See Connectors error handling for details.
By @benjamn in #10050 and @dariuszkuc in #10160
Report how often subgraph query deduplication shares a response (PR #10391)
Subgraphs with traffic_shaping deduplicate_query enabled now report apollo.router.subgraph_deduplication.requests. It counts each subgraph request that reaches query deduplication once. Its apollo.router.subgraph_deduplication.outcome attribute says what happened to the request:
leader: the request was sent, and any identical requests in flight at the same time reused its response.follower: the request reused the response of an identical in-flight request.bypassed_batch: the request is a query that is part of a batch, so it wasn't eligible.bypassed_operation: the request is a mutation or subscription, so it wasn't eligible, whether or not it is batched.
Each count also has a subgraph.name attribute.
Use the counter to see how much of your subgraph traffic deduplication actually saves. The metric is reported to your configured metrics exporters and to GraphOS. Subgraphs without query deduplication don't report it.
By @rohan-b99 in #10391
Promote connector_request_service to the public plugin interface (PR #10049)
connector_request_service is now available on the public PluginUnstable trait, so a custom Rust plugin can wrap the service that makes individual connector HTTP requests. It receives the boxed service and the @source name, matching the shape of subgraph_service:
fn connector_request_service(
&self,
service: connector::request_service::BoxService,
source_name: String,
) -> connector::request_service::BoxService {
// wrap `service` to inspect or rewrite the outgoing request
service
}apollo_router::services::connector::request_service is public along with what a plugin needs to read and change. One GraphQL operation can produce many connector requests, so this service runs once per outbound HTTP request rather than once per operation.
On the request:
Request.transport_requestcarries the underlyinghttp::Request, so a plugin can read and rewrite the URI, method, headers and body.Request.supergraph_request()returns the router request that produced this connector call, for reading.Request.contextis readable and writable for request-scoped state.Request::into_error_response(message, code, extensions)fails a connector request without making it, for cases like circuit breaking on an upstream the plugin knows to be unhealthy.
On the response:
Response.contextis readable and writable.Response.transport_outcomeexposes the raw transport outcome, naming each state it can be in:Response(the call was made over HTTP and the upstream responded — the only state carrying a status and headers),MappingOnly(a mapping-only connector, which has no transport at all), orError(the call was attempted and failed at the transport level).Response::data()/set_data()andResponse::error()/set_error_message()/set_error_code()read and change what is returned to the client.
Two things are worth knowing when moving a customization between a coprocessor and a plugin:
- The coprocessor
ConnectorRequeststage cannot change the HTTP method; a plugin can. - Changing
Response.transport_outcomedoes not recompute the mapped response, so telemetry will report the transport outcome you set while the client receives the unchanged mapped data. Change both, or neither.
The coprocessor ConnectorRequest and ConnectorResponse stages already covered this, and still do. The difference is that this runs in process, without a round trip per connector request.
By @andrewmcgivery in #10049
🐛 Fixes
Fix Helm Service rendering a duplicate port when the health check listener shares the main port (PR #10020)
When router.configuration.health_check.listen is configured on the same port as service.port, the chart rendered two Service port entries with the same (port, protocol) pair. Kubernetes rejects that on a fresh apply:
Service "apollo-router" is invalid: spec.ports[1]: Duplicate value:
{"Name":"","Protocol":"TCP","AppProtocol":null,"Port":22216,"TargetPort":0,"NodePort":0}
The health port entry is now only rendered when it differs from service.port. In the co-located case the health endpoint stays reachable through the main http port; the default split setup (health check on 8088) renders exactly as be...
v2.16.5-rc.1
2.16.5-rc.1
v2.16.5-rc.0
2.16.5-rc.0
v2.19.0-rc.0
2.19.0-rc.0
v3.0.0-preview.0
3.0.0-preview.0
v2.18.0
🚀 Features
Add max_reconnect_attempts and reconnect_delay configuration for subscription WebSocket reconnection
Adds two new fields to the subscription configuration block that allow the router to automatically reconnect a dropped WebSocket subscription to a subgraph.
max_reconnect_attempts— how many times to retry a dropped connection (default:0, no reconnection)reconnect_delay— how long to wait before each reconnection attempt (default:1s)
subscription:
enabled: true
mode:
passthrough:
all:
path: /subscriptions
max_reconnect_attempts: 5 # retry up to 5 times on connection drop
reconnect_delay: 2s # wait 2 seconds between each attemptWhen the WebSocket connection to a subgraph drops and reconnection is configured, the router re-establishes the connection transparently — client subscriptions remain open during the reconnect window and resume receiving events once the connection is restored. After all retry attempts are exhausted the router forwards the final transport error to the client and terminates the subscription.
Reconnection only applies to WebSocket passthrough mode. Callback-mode subscriptions are unaffected.
Independently of whether reconnection is enabled, a subgraph WebSocket that ends without a protocol-level complete now always surfaces a transport error to subscribed clients. Previously this was inconsistent — an abnormal close or read failure forwarded an error, but a connection that ended with no close frame terminated the client subscription silently.
Two behaviors worth noting when enabling reconnection:
max_reconnect_attemptsis a per-disconnect budget, not a lifetime total: the budget refreshes after a connection stays stable and then drops, so a long-lived subscription may reconnect more thanmax_reconnect_attemptstimes overall. Usemax_lifetimefor a hard ceiling.- Reconnection reuses the
connectionParams(including any propagatedAuthorizationtoken) captured when the subscription started. Subgraphs requiring short-lived per-connection credentials may reject a reconnect after the original token expires. AWS SigV4 request signing is re-applied per attempt with freshly resolved credentials.
By @BobaFetters in #9302
Reuse condition planning cache during query planning and satisfiability validation (PR #9740)
Router query planning and composition satisfiability validation have optimizations that cache the results of planning a "condition" (e.g. the fields of an @key or @requires). However, when this condition planning happened recursively, this resulted in new caches being constructed instead of reusing the existing cache. This behavior inhibited the reuse of previous condition planning work, increasing planning/validation time significantly in some circumstances. This code has now been changed to reuse the existing cache.
By @sachindshinde in #9740
response_cache can now emit a Cache-Tag header for CDN-side purging (Issue #9481)
If you cache router responses at a CDN or reverse proxy in front of the router, the CDN previously had no way to know what to purge when your underlying data changed — Cache-Control only governs freshness (TTL), not invalidation. A new opt-in response_cache.cdn_invalidation block closes that gap: the router emits a response header carrying the same invalidation labels it already uses for active invalidation against its own Redis cache, so you can purge your CDN's edge cache using the CDN's own tag-based purge API.
response_cache:
enabled: true
cdn_invalidation:
enabled: true
subgraph:
all:
enabled: true
redis:
urls: ["redis://..."]The header's value is a delimited list of labels drawn from the same sources already used for Redis invalidation (@cacheTag directives and the apolloCacheTags/apolloEntityCacheTags response extensions) — no schema changes required if you've already set those up. Each label is one of three tiers, coarsest to finest:
subgraph-{name}— every subgraph touched by the response.type-{subgraph}-{type}— every distinct(subgraph, GraphQL type)pair touched.- the exact tag value from
@cacheTag/the extensions, unchanged.
All three tiers are always sent together (subject to the size limit below), so you can escalate from purging a single fine-grained tag up to an entire subgraph's cached data if you're not confident a narrower purge fully propagated across every CDN edge location.
This is independent of the router's Redis-backed invalidation indexes: you don't need Redis response caching enabled, and you don't need the cache_tag invalidation index on, for the header to work correctly — including on a cache hit, since the labels needed to rebuild the header are persisted alongside the cached entry.
Configuration:
response_cache:
cdn_invalidation:
enabled: true
header_name: "Cache-Tag" # e.g. "Surrogate-Key" for Fastly
header_delimiter: "," # e.g. " " for Fastly
max_bytes: 16384 # matches Cloudflare's default Cache-Tag limit
experimental_on_overflow: truncate # "truncate" | "drop"When a response's full label set would exceed max_bytes, the router packs the header coarsest-first and drops whatever doesn't fit, finest-grained first — so an oversized response still gets a usable header rather than none at all. That default (truncate) favors availability over precision: the response still gets cached at the CDN, just with a coarser invalidation surface than it ideally would have.
For cases where that tradeoff isn't acceptable — where caching data you can't fully invalidate by its intended fine-grained tag is worse than not caching it at all — set experimental_on_overflow: drop. This omits the header entirely whenever truncation would otherwise occur, so you can pair it with a CDN-side rule that forces cache bypass on a missing header, guaranteeing you never end up with cached data whose purge surface is narrower than what your invalidation logic expects. It's marked experimental because it's a deliberate, opt-in safety valve rather than the router's default posture, and its shape may still change.
With response_cache.debug: true, the cache debugger now also shows the labels behind each cache entry and, per response, the Cache-Tag header's outcome, value, untruncated size, and whether it was actually emitted. Three new metrics (cdn_tag_header.outcome, cdn_tag_header.untruncated_size, cdn_tag_header.error) track header emission, truncation, and errors.
Off by default; existing deployments see no behavior change.
By @aaronArinder in #9811
connect/v0.4 is no longer a preview spec version
connect/v0.4 (and the -> method shape checking, ? optional chaining, and unified object/selection literal syntax it enables) is no longer treated as a preview version of the Connect spec. Subgraphs can @link to connect/v0.4 without any opt-in, and composition now uses connect/v0.4 as the default version stamped into the supergraph when a subgraph doesn't explicitly declare a connect spec version.
connect/v0.5 is added as a new preview spec version, gated behind the connectors.preview_connect_v0_5 opt-in in router.yaml (see the accompanying changeset).
By @briannafugate408 in #9839
Update rhai scripting engine to v1.25.x (PR #9527)
The bundled Rhai scripting engine has been updated from ~1.23.6 to ~1.25.0 (including the patch 1.25.1).
Notable changes in this range that may affect router scripts:
stdwebsupport removed (1.24.0): Thestdwebfeature flag is gone; WASM targets now useweb-timeinstead of the unmaintainedinstantcrate. This is unlikely to affect typical router Rhai scripts.- String methods
split/split_revare nowpure: They can be called onconststrings without error. \${...}escape in multi-line literal strings: You can now write\${...}in a multi-line literal string to produce the literal text${...}instead of triggering interpolation.index_offallback for string arguments: When no matching script function is registered,index_ofnow falls back to value comparison for string arguments.
No changes to the router's Rhai API surface are expected. If your scripts relied on the old stdweb feature or specific sort behavior on non-totally-ordered arrays (which previously could panic), review your scripts before upgrading.
Add is_deferred subgraph telemetry selector (PR #9262)
A new is_deferred: true selector is now available on the subgraph service of the telemetry instrumentation config. It returns true when the current subgraph fetch is part of the deferred portion of an @defer query plan, and false for primary (non-deferred) fetches.
This lets you split subgraph metrics like http.client.request.duration between primary and deferred fetches — useful for seeing whether deferred fetches contribute disproportionately to tail latency on @defer-adopting operations:
telemetry:
instrumentation:
instruments:
subgraph:
http.client.request.duration:
attributes:
phase:
is_deferred: trueProduces two series: `http_client_request_durat...
v2.16.4
🐛 Fixes
Accept @defer labels reused via fragment spreads (PR #10193)
The duplicate @defer(label:) check from the GHSA-gr6h-4wpf-xp52 fix ran after fragment expansion, rejecting valid operations where a fragment containing a labeled @defer is spread more than once. The incremental delivery specification defines label uniqueness over the document as written, where such a label occurs only once; clients like Relay derive defer labels from fragment names and rely on this.
Label uniqueness is now validated on the document, before fragment expansion, still rejecting the operations behind the original security advisory. Operations that reuse a labeled @defer via fragment spreads plan and execute correctly: one incremental response per spread position, each carrying the user-provided label and distinguished by its path.
Example query that was rejected but now is correctly processed
{
currentUser { ...UserFragment }
otherUser { ...UserFragment }
}
fragment UserFragment on User {
id
... @defer(label: "UserFragmentLabel") {
name
}
}By @tninesling in #10193
v2.16.4-rc.0
2.16.4-rc.0
v2.18.0-rc.0
2.18.0-rc.0