Major Changes
-
#8252
c74f669Thanks @glasser! - In order to use the cache control plugin, you must add a definition of the@cacheControldirective to your schema. Thescopeargument in the suggested directive definition used to be optional; the cache control plugin interprets an unspecifiedscopeasPUBLIC. This default turns out to be surprising.In Apollo Server 6, we now suggest that you define the
scopeargument as required (scope: CacheControlScope!). By default, the cache control plugin (which is installed by default) will throw an error on startup if your schema defines a@cacheControldirective which does not match the suggested definition, including a non-nullscope. You can disable this validation by installingApolloServerPluginCacheControl({ validateDirectiveDefinition: false })in your server'spluginsarray. -
#8248
3eb55bdThanks @glasser! - Remove thestatus400ForVariableCoercionErrorsconstructor option. Variable coercion errors always receive a 400 status code (the default since Apollo Server 5); setting the option tofalseis no longer supported. -
#8272
66bd442Thanks @glasser! - Previously, this published package contained copies compiled both as ECMAScript modules (ESM) and as CommonJS. It is now published only as ESM, without a CommonJS build. All supported versions of Node.js allow you torequire()ESM code from CommonJS code.Even though Node.js's own module loader should be able to use this module from CommonJS code without configuration changes, other ways of running code might need small adjustments. Specifically, some configurations of Jest and TypeScript may need changes; see the migration guide for details.
While Apollo Server v6.0.0 is ESM-only, it does not yet depend on any other ESM-only package at runtime. (This will make it easier to change our minds and return to publishing CommonJS builds if this change was premature.) However, we may choose to start depending on ESM-only packages in a future minor release.
-
#8246
89486b2Thanks @glasser! - Require GraphQL.js v17. Thegraphqlpeer dependency is now^17.1.0; Apollo Server 6 does not support GraphQL.js v16 (nor does it support pre-release versions of GraphQL.js v17, as Apollo Server 5 did experimentally). Before upgrading, read the GraphQL.js v16 to v17 upgrade guide for changes to GraphQL.js itself.Incremental delivery (
@deferand@stream) now works natively without needing to install an alpha version of GraphQL.js. Clients must request incremental delivery with theaccept: multipart/mixed; incrementalSpec=v0.2HTTP header.Other packages that peer-depend on
graphqlmust also accept v17; in particular, use@apollo/gatewayv2.14.5 or later and@apollo/subgraphv2.16.0 or later. -
#8250
39fe133Thanks @glasser! - ThehideSchemaDetailsFromClientErrorsconstructor option is removed, because GraphQL.js 17 now supports the same functionality natively. Replacenew ApolloServer({ hideSchemaDetailsFromClientErrors: true })withnew ApolloServer({validationOptions: { hideSuggestions: true }}). Apollo Server will forward this flag to the GraphQL.js execution phase as well, so it now covers all "Did you mean ...?" suggestions GraphQL.js generates: previouslyhideSchemaDetailsFromClientErrorsonly removed suggestions from validation errors (for example, a query selecting an unknown field), buthideSuggestionsalso removes them from variable coercion errors (#8086), for example a misspelled input object field or enum value provided via variables. -
#8247
069d645Thanks @glasser! - Remove support for the legacy incremental delivery format (accept: multipart/mixed; deferSpec=20220824), along with thelegacyExperimentalExecuteIncrementallyconstructor option. Operations that use@deferor@streamfrom clients that only accept that format now receive a406 Not Acceptableerror; clients should sendaccept: multipart/mixed; incrementalSpec=v0.2instead.The
GraphQLExperimental*Alpha2andGraphQLExperimental*Alpha9types are no longer exported from@apollo/server.GraphQLResponseBodyand thewillSendSubsequentPayloadplugin hook now use theFormattedInitialIncrementalExecutionResultandFormattedSubsequentIncrementalExecutionResulttypes exported fromgraphql(which have the same shape as the removedAlpha9types).GraphQLResponseBody'ssubsequentResultsis now theAsyncGeneratorthatgraphqlreturns (FormattedExperimentalIncrementalExecutionResults['subsequentResults']) rather than a plainAsyncIterable, so you can callreturn()on it. -
#8244
0976350Thanks @glasser! - Drop support for Node.js v20, which reached end-of-life on April 30, 2026. Apollo Server 6 requires Node.js v22.18.0 or later (engines.node: ">=22.18").Apollo Server 6 also adopts a new policy for Node.js support: once a Node.js major version reaches end-of-life, Apollo Server may drop support for it with a minor release rather than a major release. Such a change will be called out in the changelog. This policy only applies to Node.js versions, not other dependencies.
Apollo Server is now compiled with TypeScript's
es2024target and lib (every supported Node.js version implements ES2024).
Minor Changes
-
#8251
7bafc03Thanks @glasser! - Requests can now carry anAbortSignal. Web framework integrations can optionally include one inHTTPGraphQLRequest, and plugins can set or replacerequestContext.request.http.signalinrequestDidStart(for example, to combine the integration's signal withAbortSignal.timeout()). If a signal is present, Apollo Server checks it at several points while processing the request (such as before parsing, validation, and execution) and forwards it to GraphQL.js execution. Execution as a whole will stop early if the signal fires, and individual resolvers can access it viainfo.getAbortSignal()if they want to abort their own work. If the signal fires, requests will end with a new error code,REQUEST_ABORTED(for an incremental delivery response whose initial payload has already been sent, each still-pending deferred fragment or stream completes with that error).startStandaloneServerprovides anAbortSignaland fires it if the client disconnects before the response is finished. -
#8253
b9b39e6Thanks @glasser! - WhenincludeStacktraceInErrorResponsesis enabled (the default outside production), thestacktraceextension now includes the stack traces of the error's wholecausechain, not only the error's own. After the error's own trace, each cause's trace follows, introduced by aCaused by:line. (As a special case, a cause whose stack is identical to its parent's is skipped;GraphQLErrors created with the deprecatedoriginalErroroption instead of the standardcauseoption have this effect, and as ofgraphql@17.1.0, this includes errors thrown in resolvers.) So an error thrown in a context function now shows both where Apollo Server wrapped it and where it was thrown, and errors created withnew Error(message, { cause })show their causes.Relatedly, Apollo Server now builds the
GraphQLErrors it creates (for parse, validation and variable-coercion failures, context-function and plugin errors, and request cancellation) with the standard JScauseoption rather than with the GraphQL.js-specific now-deprecatedoriginalError. This does not affectGraphQLErrors produced bygraphql-jsitself, such as theGraphQLErrorthat wraps errors thrown within resolvers. On the error objects themselves, as seen by plugins (didEncounterErrors) andformatError, thestackof such a wrapping error now points at where Apollo Server wrapped it; the original error's stack can be found onerror.cause.stack(as well aserror.originalError.stack).