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

Ability to disable auto-camelcasing per field #3479

Closed
magicmark opened this issue Apr 30, 2024 · 3 comments
Closed

Ability to disable auto-camelcasing per field #3479

magicmark opened this issue Apr 30, 2024 · 3 comments

Comments

@magicmark
Copy link
Contributor

magicmark commented Apr 30, 2024

Let's say I want to keep auto-camelcasing enabled for my whole service except for a couple of fields

e.g. maybe i have a translations service and want to write schema/query like this:

query {
  getTranslations(string: "Hello world") {
    en_US
    fr_FR
  }
}

Ideally, I could write resolvers like this

@strawberry.type
class Translations:
    @strawberry.field(disable_auto_camelcase=True)
    def en_US(self) -> str: ...

    @strawberry.field(disable_auto_camelcase=True)
    def fr_FR(self) -> str: ...

or maybe even for a whole type?

@strawberry.type(disable_auto_camelcase=True)
class Translations:
    @strawberry.field
    def en_US(self) -> str: ...

    @strawberry.field
    def fr_FR(self) -> str: ...

Thanks!

Feature Request Type

[x] Alteration (enhancement/optimization) of existing feature(s)

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@jacobmoshipco
Copy link

It looks like the name=... parameter takes priority over auto camel-casing, so this should work:

@strawberry.type
class Translations:
    @strawberry.field(name="en_US")
    def en_US(self) -> str: ...

    @strawberry.field(name="fr_FR")
    def fr_FR(self) -> str: ...

I'm unsure if there's a unit test for this use-case.

@patrick91
Copy link
Member

I was going to suggest that, but I wonder if @magicmark would prefer to avoid the duplication?

@magicmark
Copy link
Contributor Author

This works for me. Thanks!

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