Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to rename relationship? #1485

Answered by elyas-hedayat
hyusetiawan asked this question in Q&A
Discussion options

by default graphene django would generate the name of the relationship, using this pattern, Set like userSet is it possible to change this to just user? or define it manually somehow?

You must be logged in to vote

I think your question related to models layer more than graphene django
you can set related_name for your fk fileds or m2m

Replies: 1 comment 2 replies

Comment options

I think your question related to models layer more than graphene django
you can set related_name for your fk fileds or m2m

You must be logged in to vote
2 replies
Comment options

this will change the generated django model level, what I am asking is how to change specifically the auto generated graphql field by graphene. Using related name will unfortunately change the django model set name as well, is it possible to just specifically change the generated graphql field?

The only way I can think of is to manually create a graphql field in the model and create the resolve_* but it seems to be too much boiler plate :/

Comment options

Yes, you are correct that you'd need to do it more manually if not specifying a related name at the model level. There is no built-in functionality for changing the relation (or field) names at the schema level.

Answer selected by firaskafri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /