Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions website/pages/docs/going-to-production.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion website/pages/upgrade-guides/v15-v16.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 1 addition & 7 deletions website/pages/upgrade-guides/v16-v17.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -285,7 +285,6 @@ const result = await graphql({
source,
variableValues,
operationName: 'Viewer',
hideSuggestions: true,
abortSignal,
});
```
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading