You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hide "did you mean" suggestions via internal plugin to avoid leaking schema information (#7916)
It was previously discussed (see:
#3919) to wait for
graphql/graphql-js#2247 to close, however,
that issue has not moved in years and in the mean time libraries and
frameworks seem to have opted for implementing their own solutions (E.g.
https://github.com/Escape-Technologies/graphql-armor/blob/main/packages/plugins/block-field-suggestions/src/index.ts).
This should be a very low impact change that achieves the goal that
would also be easy enough to rip out if this gets properly implemented
in graphql-js later.
Adds `hideSchemaDetailsFromClientErrors` option to ApolloServer to allow
hiding of these suggestions.
Before: `Cannot query field "helloo" on type "Query". Did you mean
"hello"?`
After: `Cannot query field "helloo" on type "Query".`
Fixes#3919
Add `hideSchemaDetailsFromClientErrors` option to ApolloServer to allow hiding 'did you mean' suggestions from validation errors.
6
+
7
+
Even with introspection disabled, it is possible to "fuzzy test" a graph manually or with automated tools to try to determine the shape of your schema. This is accomplished by taking advantage of the default behavior where a misspelt field in an operation
8
+
will be met with a validation error that includes a helpful "did you mean" as part of the error text.
9
+
10
+
For example, with this option set to `true`, an error would read `Cannot query field "help" on type "Query".` whereas with this option set to `false` it would read `Cannot query field "help" on type "Query". Did you mean "hello"?`.
11
+
12
+
We recommend enabling this option in production to avoid leaking information about your schema to malicious actors.
13
+
14
+
To enable, set this option to `true` in your `ApolloServer` options:
Copy file name to clipboardExpand all lines: docs/source/api/apollo-server.mdx
+23
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,29 @@ The default value is `true`, **unless** the `NODE_ENV` environment variable is s
149
149
</tr>
150
150
151
151
<tr>
152
+
153
+
<tr>
154
+
<td>
155
+
156
+
###### `hideSchemaDetailsFromClientErrors`
157
+
158
+
`boolean`
159
+
160
+
</td>
161
+
162
+
<td>
163
+
164
+
If `true`, Apollo Server will strip out "did you mean" suggestions when an operation fails validation.
165
+
166
+
For example, with this option set to `true`, an error would read `Cannot query field "help" on type "Query".` whereas with this option set to `false` it would read `Cannot query field "help" on type "Query". Did you mean "hello"?`.
167
+
168
+
The default value is `false` but we recommend enabling this option in production to avoid leaking information about your schema.
0 commit comments