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

Allow disabling case convertion #765

Merged
merged 1 commit into from
Oct 13, 2020
Merged

Allow disabling case convertion #765

merged 1 commit into from
Oct 13, 2020

Conversation

ip1981
Copy link
Contributor

@ip1981 ip1981 commented Sep 16, 2020

Add a new attribute rename which could be "none", "camelCase", "SCREAMING_SNAKE_CASE".
By default (when this attribute is not specified) the exiting rules apply: camelCase to structs, SCREAMING_SNAKE_CASE to enums.

Inspired by Serde & Structopts.

This does not change interfaces because I haven't figured how to do them yet.

Re #201.

@ip1981 ip1981 changed the title Allow disabling camelCase convertion Allow disabling case convertion Sep 16, 2020
Copy link
Member

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, this looks great! A couple of changes / suggestions:

  1. We'll need a couple of unit tests or integration tests to make sure this isn't broken in the future.
  2. I'd prefer to match the API from http://serde.rs. That is, rename in a field is for a specific name set verbatim and the ability to use a rename strategy at the top-level is on the object definition.

@ip1981
Copy link
Contributor Author

ip1981 commented Sep 17, 2020

I'm not sure I totally get the second point.

There are differences between juniper and serde:

  1. Juniper in fact uses only one-way renaming, even when decoding input objects. This is why there is no point in having an attribute like rename_all, for example.
  2. I am trying to keep existing behavior by default (camelCase for structs, SCREAMING_CASE for enums). That's why it is Option<RenameRule>.

Each struct member already can be renamed explicitly with the name attribute.

@ip1981
Copy link
Contributor Author

ip1981 commented Sep 17, 2020

I will add some tests for sure :)

@LegNeato
Copy link
Member

Ugh, sorry...read that way too fast and was fried from work. You're right, ignore #2 :-)

@ip1981
Copy link
Contributor Author

ip1981 commented Sep 27, 2020

Added some tests.

@LegNeato
Copy link
Member

LegNeato commented Oct 1, 2020

Thank you! I'll land this in a couple of days.

@mkpankov
Copy link

Hey! Any updates on this?

@LegNeato LegNeato merged commit c964fd8 into graphql-rust:master Oct 13, 2020
@tyranron tyranron mentioned this pull request Aug 11, 2021
6 tasks
@RDruon RDruon mentioned this pull request Feb 24, 2022
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

Successfully merging this pull request may close these issues.

3 participants