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

CamelCase vs snake_case (again) #4918

Open
danlo opened this issue Apr 17, 2024 · 1 comment
Open

CamelCase vs snake_case (again) #4918

danlo opened this issue Apr 17, 2024 · 1 comment

Comments

@danlo
Copy link

danlo commented Apr 17, 2024

Is your feature request related to a problem? Please describe.

I'm constantly caught between switching between camelCase and snake_case as addressed in these previous issues:

Describe the solution you'd like

if content comes in snake_case then displaying a warning "did you mean..." snakeCase would be great. #4563

Describe alternatives you've considered

none.

Additional context

I know this is re-opening a previous issue, however, I think enough programmers screw up often enough that a few minutes from everyone's time adds up to be a lot of time.

Would you please reconsider working on #4563 as this would save many people a little bit of time and greatly improve progarmmer expierence.

Regards,

-daniel

@rmosolgo
Copy link
Owner

Hey, thanks for the suggestion. I'm open to it, it looks like DidYouMean has a handy direct-use API: https://github.com/ruby/did_you_mean?tab=readme-ov-file#using-the-didyoumeanspellchecker

Want to give it a shot? Here's where the "field doesn't exist on type" error is created:

add_error(GraphQL::StaticValidation::FieldsAreDefinedOnTypeError.new(
"Field '#{node.name}' doesn't exist on type '#{parent_type.graphql_name}'",
nodes: node,
field: node.name,
type: parent_type.graphql_name

You can get the options for field names using:

visible_fields = context.warden.fields(parent_type) # filter out any hidden fields 
possible_field_names = visible_fields.map(&:graphql_names)

I expect that plenty of existing tests will fail -- and pass after they're updated to contain "did you mean ..." ✨

Let me know what you think!

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