Skip to content

Provide nicer validation errors? #160

@eapache

Description

@eapache

@rmosolgo cc @dylanahsmith @lreeves

Right now if I run a mutation with invalid input (e.g. from a custom scalar definition):

mutation {
  doTheThing(input: { myField: "someInvalidValue" }) {
    myField
  }
}

I'll get back:

{
  "errors": [
    {
      "message": "Argument 'input' on Field 'doTheThing' has an invalid value",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },
    {
      "message": "Argument 'myField' on InputObject 'DoTheThingInput' has an invalid value",
      "locations": [
        {
          "line": 2,
          "column": 21
        }
      ]
    }
  ]
}

There are two things that would be nice here:

  • The first error complaining about input is, as far as I can tell, entirely redundant and occurs because the input for myField is invalid. It would be good if this was not returned since we already have a more precise error for myField.
  • If the error for myField also returned fields: [String!] in the form ["doTheThing", "input", "myField"] for callers to be able to easily (and programatically) determine which field was malformed.

I'm willing to work on this but a quick dive into argument_literals_are_compatible.rb didn't make either change look easy so I thought I'd ask for opinions and maybe hints first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions