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

Improve error message for snake case vs camel case in queries #1953

Open
holic opened this issue Nov 9, 2018 · 1 comment
Open

Improve error message for snake case vs camel case in queries #1953

holic opened this issue Nov 9, 2018 · 1 comment
Assignees

Comments

@holic
Copy link

@holic holic commented Nov 9, 2018

For a Ruby GraphQL schema defined like

class Person < GraphQL::Schema::Object
  field :username, String, null: false
  field :first_name, String, null: false
end

And a query like:

query {
  people {
    username
    first_name
  }
}

I get an error like this:

Field 'first_name' doesn't exist on type 'Person'

Since we know that we have a field defined with first_name, but expect it to be queried like firstName, is it possible to improve the error message to point to/suggest the correct field name? As someone new to GraphQL and graphql-ruby, this had me stuck for a non-trivial amount of time wondering what I did wrong!

An improvement might look like:

Field 'first_name' doesn't exist on type 'Person'. Did you mean `firstName`?
@rmosolgo

This comment has been minimized.

Copy link
Owner

@rmosolgo rmosolgo commented Nov 9, 2018

That would be awesome! I wonder if we could leverage the did-you-mean support that ships with Ruby (https://github.com/yuki24/did_you_mean)

@daemonsy daemonsy self-assigned this Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.