Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misleading validation error message in selections under a String #916

Open
Geal opened this issue Sep 26, 2024 · 1 comment
Open

misleading validation error message in selections under a String #916

Geal opened this issue Sep 26, 2024 · 1 comment

Comments

@Geal
Copy link
Contributor

Geal commented Sep 26, 2024

Found when testing something else: apollographql/router#6035 (comment)

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?

goto-bus-stop added a commit that referenced this issue Sep 26, 2024
It also reports this, which doesn't make sense:
```
Error: interface, union and object types must have a subselection set
   ╭─[0119_nested_subselection_issue_916.graphql:8:17]
   │
 8 │ query Invalid { me { name { reviews { body } } } }
   │                 ────────────────┬───────────────
   │                                 ╰───────────────── `Query.me` is an object type `User` and must select fields
───╯
```
@goto-bus-stop
Copy link
Member

Repro in #917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants