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

Closed
holic opened this issue Nov 9, 2018 · 2 comments
Closed

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

holic opened this issue Nov 9, 2018 · 2 comments
Assignees

Comments

@holic
Copy link

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
Copy link
Owner

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
@rmosolgo
Copy link
Owner

I wish I had time to work on this improvement, but I don't :'( I'm going to close this because I don't plan to work on it, but if someone wants to submit an improvement, I'd be glad to review it!

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

3 participants