apollo-rs icon indicating copy to clipboard operation
apollo-rs copied to clipboard

misleading validation error message in selections under a String

Open Geal opened this issue 1 year ago • 1 comments

Found when testing something else: https://github.com/apollographql/router/pull/6035#discussion_r1768865666

With the query query Invalid { me { name { reviews { body } } } } where name is a String, we get the following errors:

{
  "errors":[
    {
      "message":"Field \"me\" of type \"Query\" must have a selection of subfields. Did you mean \"me { ... }\"?",
      "locations":[{"line":1,"column":17}],
      "extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},
    {
       "message":"Field \"name\" must not have a selection since type \"String\" has no subfields",
       "locations":[{"line":1,"column":22}],
       "extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}
    }
  ]
}

The second error is expected, but why would we get the first one? Is that because the compiler considers the entire name selection invalid, removes it from its view, and then the me selection appears empty?

Geal avatar Sep 26 '24 09:09 Geal

Repro in https://github.com/apollographql/apollo-rs/pull/917

goto-bus-stop avatar Sep 26 '24 12:09 goto-bus-stop