Graphene: Snake case to camel case

Created on 23 Nov 2015  Â·  8Comments  Â·  Source: graphql-python/graphene

I didn't find a forced conversion to camelCase in the spec. Did I miss it? Or is graphene just opinionated on style standards. Will there be any way to opt out of this in the future?

work in progress ✨ enhancement

Most helpful comment

@millerjs this is now fixed.
Thanks to a new plugin structure you can even create some plugin for transform the name the way you want.

The current usage for disable the auto camelCase is:

schema = graphene.Schema(query=..., auto_camelcase=False)

Hope it helps! ;)

All 8 comments

It's convention. Generally you would want to use camel case in javascript world. But graphene keeps things snake cased in Python. If you want to use snake cased fields though you can explicitly specify a name.

Sent from my iPhone

On Nov 22, 2015, at 9:00 PM, Josh Miller [email protected] wrote:

I didn't find a forced conversion to camelCase in the spec. Did I miss it? Or is graphene just opinionated on style standards. Will there be any way to opt out of this in the future?

—
Reply to this email directly or view it on GitHub.

Hi @millerjs, thanks for asking!
I think path to go will be having _snake_cased_ fields converted to _camelCase_ by default, but adding the possibility for changing this via some global variable or graphene settings.
Will keep this issue open until graphene adds the ability of not camelCase if defined in settings.

:+1: This would be a great feature despite it's unconventionality.

@millerjs this is now fixed.
Thanks to a new plugin structure you can even create some plugin for transform the name the way you want.

The current usage for disable the auto camelCase is:

schema = graphene.Schema(query=..., auto_camelcase=False)

Hope it helps! ;)

Fantastic! thanks @syrusakbary

@millerjs this is now fixed.
Thanks to a new plugin structure you can even create some plugin for transform the name the way you want.

The current usage for disable the auto camelCase is:

schema = graphene.Schema(query=..., auto_camelcase=False)

Hope it helps! ;)

Hi @syrusakbary, I am using this thread for a question related to auto_camelcase, let me know if there is more appropriate forum to addresses this issue.

We are running into a requirement where not all clients of graphql api wants to use camelCase for interacting with the api (eg. non-javascript based internal services). So the question here is, if there is a way to dynamically pass a parameter to graphql api which determines if camelCase to snake_case conversion should happen or not on the server side. If not, is this a requirement on the future roadmap ? Appreciate your help.

i appreciate the opt out of defaulting to camel case! :-D

So, it's a cool feature, indeed. In the same time, I noticed that the keys of nested structures aren't been transformed.
How do you see, if that behavior will appear in graphene?

Was this page helpful?
0 / 5 - 0 ratings