Skip to content

Some variable-related errors should be BAD_USER_INPUT rather than INTERNAL_SERVER_ERROR #5353

@glasser

Description

@glasser

The function coerceVariableValues in https://github.com/graphql/graphql-js/blob/main/src/execution/values.ts can throw several errors if the provided variable values aren't good. These are all bad user input, not server bugs, so Apollo Server should throw them as UserInputError rather than internal server errors. Unfortunately graphql-js doesn't give a great way of differentiating these errors from errors in server code and so we treat them like internal server errors.

In #5091 we fixed one of these errors (Variable "$${varName}" got invalid value) to throw UserInputError but other errors like Variable "$${varName}" of required type "${varTypeStr}" was not provided and Variable "$${varName}" of non-null type "${varTypeStr}" must not be null still show up as internal server errors. See #3498 (comment) for a codesandbox that demonstrates both issues. We should make them both into UserInputError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    📚 good-first-issueIssues that are more approachable for first-time contributors.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions