Skip to content

hideSchemaDetailsFromClientErrors should trap coercion errors arising from query variable bindings #8086

@wabrit

Description

@wabrit

When issuing a query such as query { noSuchField }, and passing hideSchemaDetailsFromClientErrors: true to the ApolloServer constructor, the Apollo strips "did you mean" suggestions from the error response as expected.

However, when the error arises from a query variable coercion error, the "did you mean" suggestion is not stripped from the error message.

This can be worked around using a suitable error formatter, but the docs should at least highlight that the hideSchemaDetailsFromClientErrors setting does not apply to this case.

Example Scenario

  1. Create an ApolloServer with the hideSchemaDetailsFromClientErrors setting set to true
  2. Invoke a query e.g. query GetUser($filter: UserFilter!) { users(filter: $filter) { id } }
  3. Pass in variables { "filter": { "nam": "Bob" } } where the filter field nam is a mispelling of the true field UseFilter.name

The returned error message will be of the form

"$filter" got invalid value { nam: "Bob" }; Field "nam" is not defined by type "UserFilter". Did you mean "name"?

which contains the Did you mean schema hint; this is likely because the error is trapped during value coercion, and as a result:

  • Apollo’s validationDidStart() hook doesn’t get called with these errors
  • The internal ApolloServerPluginDisableSuggestions plugin never sees the error
  • The error passes through unmodified to the client

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions