Khan / genqlient

a truly type-safe Go GraphQL client
MIT License
1.07k stars 107 forks source link

Add an option to handle enums with ugly casing #270

Closed benjaminjkraft closed 1 year ago

benjaminjkraft commented 1 year ago

There are a bunch of places in genqlient where we just kind of hope you don't have ridiculous casing conflicts in your schema. Apparently with enum values there are actual schemas that have this problem! Now we have an option to disable. I ended up putting it all under casing instead of in bindings so we can clearly document the list of algorithms we support, and so we can have an all_enums value if you're working with a schema with a lot of this; in the future we may want to add similar behavior for types/fields, add more possible algorithms (e.g. to make things unexported), etc.

I added tests for the new feature, although the way the tests are set up it wasn't convenient to do so for a schema where this is actually required. I also added a check for case conflicts that points you to this option. (I don't want to do it automatically for reasons described in the issue; mainly it just seemed a bit too magical.)

Fixes #265.

I have:

partounian commented 1 year ago

By chance will this feature be released soon?

Oh I guess I can use go run github.com/Khan/genqlient@main

benjaminjkraft commented 1 year ago

Yep, we usually let new features bake a bit before we cut a release in case folks run into bugs in the real world that aren't covered in our tests, but if you want them right away then you can just use the main branch!