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

Support "out_name" in input types #41

Closed
Cito opened this issue Jun 30, 2019 · 4 comments
Closed

Support "out_name" in input types #41

Cito opened this issue Jun 30, 2019 · 4 comments
Assignees
Labels
feature Feature request

Comments

@Cito
Copy link
Member

Cito commented Jun 30, 2019

GraphQL-Core supports an out_name for input types which is used by Graphene for passing parameters with transformed names to Python (because Python likes snake_case instead of camelCase).

GraphQL-Core-Next should support a similar functionality that can be used by Graphene.

@Cito
Copy link
Member Author

Cito commented Jun 30, 2019

This is now fully supported and works the same as in GraphQL-core.

@Cito Cito closed this as completed Jun 30, 2019
@Hellzed
Copy link

Hellzed commented Aug 17, 2019

Is there a way to use this feature with an SDL-first approach?
I'm using build_schema to get my schema from the SDL, in addition with resolver methods on my root_value, and I would prefer my resolvers to get snake cased arguments instead of camel case.

@Cito
Copy link
Member Author

Cito commented Sep 4, 2019

You will need to patch the schema setting the out_names to the input fields. Something like this will probably do:

from graphql.pyutils import camel_to_snake

for field_name, field in schema.query_type.fields.items():
    for arg_name, arg in field.args.items():
        arg.out_name = camel_to_snake(arg_name)

@Hellzed
Copy link

Hellzed commented Sep 4, 2019

Thanks for the tip, I'll try this ASAP!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants