Skip to content

Weird error when running mutations with invalid inputs #69

@adamors

Description

@adamors

Hey, I've encountered a bug when running mutations and providing an invalid input.

Given the following schema

type Query {
  hello: String
}

input AddFavoriteFoodInput {
  id: ID!
  comment: String!
  foodNames: [String!]!
}

type Mutation {
  addFavoriteFood(input: AddFavoriteFoodInput!): Boolean!
}

if you run the mutation

mutation AddFavoriteFood($input: AddFavoriteFoodInput!) {
  addFavoriteFood(input: $input)
}

with variables

{
  "input": {
    "id": "123",
    "comment": "Hello",
    "foodNames": [
      "Pizza",
      "Apple",
       null,
      "Pineapple"
    ]
  }
}

the expected error message is:

"Variable \"$input\" got invalid value null at \"input.foodNames[2]\";
Expected non-nullable type \"String!\" not to be null."

However with GraphQL Complexity enabled, this turns into

"Argument \"input\" of required type \"AddFavoriteFoodInput!\" was provided the
variable \"$input\" which was not provided a runtime value."

Here's a repo reproducing the issue: https://github.com/adamors/graphql-complexity-bug

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