From b32f40beea9fa320ad7687c1ace4e05ecbe53e55 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Wed, 4 Nov 2026 14:13:05 +0200 Subject: [PATCH] docs: update production and migration guidance Move hideSuggestions usage into the production guide alongside the existing introspection guidance, including the different validate() argument positions on v15 and v16/v17. Remove hideSuggestions as a v17-only addition from the migration guides. Keep the actual maxErrors default difference: Infinity on v15 and 100 on v16. --- website/pages/docs/going-to-production.mdx | 34 ++++++++++++++++++++++ website/pages/upgrade-guides/v15-v16.mdx | 3 +- website/pages/upgrade-guides/v16-v17.mdx | 8 +---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/website/pages/docs/going-to-production.mdx b/website/pages/docs/going-to-production.mdx index 3cf9765bb2..00d3bff2dc 100644 --- a/website/pages/docs/going-to-production.mdx +++ b/website/pages/docs/going-to-production.mdx @@ -256,6 +256,40 @@ internal details in errors, and return errors in a format clients can interpret For more information on how GraphQL.js formats and processes errors, see [Understanding GraphQL.js Errors](./graphql-errors/). +### Disable error suggestions + +Error suggestions can be helpful during development, but may be unnecessary +in production. Disabling them may reduce your API's attack surface. + +You can disable suggestions in production, or only for unauthenticated users: + +```js +import { graphql } from 'graphql'; + +const result = await graphql({ + schema, + source, + hideSuggestions: isPublicRequest, +}); +``` + +The `hideSuggestions` option is available in v17, v16 (since v16.15.0), and +v15 (since v15.11.0). Suggestions remain enabled by default. + +When calling `validate()` and `execute()` separately, pass the option to +both. The options argument to `validate()` differs by release line: + +```js +// v16 and v17: options are the fourth argument. +validate(schema, document, undefined, { hideSuggestions: true }); + +// v15: options are the fifth argument, after the optional TypeInfo instance. +validate(schema, document, undefined, undefined, { hideSuggestions: true }); +``` + +Custom scalar and resolver error messages are unaffected. Configure schema +introspection separately; see [Control schema introspection](#control-schema-introspection). + ### Control what errors are exposed By default, GraphQL.js includes full error messages and stack traces. In production, you may want diff --git a/website/pages/upgrade-guides/v15-v16.mdx b/website/pages/upgrade-guides/v15-v16.mdx index 7e77392428..f19ef030e4 100644 --- a/website/pages/upgrade-guides/v15-v16.mdx +++ b/website/pages/upgrade-guides/v15-v16.mdx @@ -377,7 +377,8 @@ lowercase `Url` for compatibility, but the introspection field it requests is **Behavioral tightening.** `validate()` stops after 100 validation errors by default and appends an error that says validation was aborted. This prevents a -single invalid operation from producing unbounded diagnostic work. +single invalid operation from producing unbounded numbers of diagnostics. v15 +has no validation error-count limit by default (i.e. a default of `Infinity`). If a tool intentionally needs more errors, pass `maxErrors` in the validation options. diff --git a/website/pages/upgrade-guides/v16-v17.mdx b/website/pages/upgrade-guides/v16-v17.mdx index ee036366f1..f7a388ebc7 100644 --- a/website/pages/upgrade-guides/v16-v17.mdx +++ b/website/pages/upgrade-guides/v16-v17.mdx @@ -276,7 +276,7 @@ and bundler setup. **New stable API.** The high-level `graphql()` and `graphqlSync()` APIs still use the object-argument form from v16. In v17, that object can also carry -parser options, validation options, execution options, `hideSuggestions`, +parser options, validation options, execution options, `abortSignal`, hooks, and a custom harness. ```js @@ -285,7 +285,6 @@ const result = await graphql({ source, variableValues, operationName: 'Viewer', - hideSuggestions: true, abortSignal, }); ``` @@ -824,10 +823,6 @@ custom type tracking, compose your visitor with `visitWithTypeInfo()`. + const errors = validate(schema, document, rules, options); ``` -**New stable API.** `hideSuggestions` removes "Did you mean ..." suggestion -text from diagnostics. This is useful for public APIs that do not want to leak -schema shape through error messages. - **New stable API.** `KnownOperationTypesRule` validates that an operation's root type exists in the schema. For example, a `mutation` operation is invalid when the schema has no mutation root type. @@ -1022,7 +1017,6 @@ These v16 APIs still work in v17, but are deprecated for removal in v18: ### Optional v17 runtime and experimental features -- Use `hideSuggestions` when public diagnostics should omit schema suggestions. - Use `abortSignal` and `info.getAbortSignal()` when a host can propagate cancellation to downstream work. - Handle `AbortedGraphQLExecutionError` if your host needs access to partial