Question about mutation in the documentation
See original GitHub issueIs your feature request related to a problem? Please describe. No. It is about a clarification that might be helpful about mutations in the documentation.
Describe the solution you’d like
In the documentation, here, in the QuestionMutation
class, there is a question
attribute. What does that actually mean ? It says that it defines the response and I don’t understand this.
In my code I’ve been able to do this :
My type :
class UserType(DjangoObjectType):
class Meta:
model = User
fields = (
'id',
'username',
'password',
'email',
'first_name',
'last_name',
'is_active',
'group_ids',
)
full_name = graphene.String() # Python property
full_identification = graphene.String() # Python property
My mutation :
class UpdateUser(graphene.Mutation):
# --------> I could comment these and no problem. Why ? <--------
# id = graphene.ID()
# username = graphene.String()
# email = graphene.String()
# first_name = graphene.String()
# last_name = graphene.String()
# is_active = graphene.Boolean()
class Arguments:
id = graphene.ID()
username = graphene.String()
email = graphene.String()
first_name = graphene.String()
last_name = graphene.String()
is_active = graphene.Boolean()
class Meta:
output = UserType
@login_required
def mutate(self, info, **kwargs):
user = get_object_or_404(User, id=kwargs['id'])
for attr, value in kwargs.items():
setattr(user, attr, value)
user.save()
return user
# I'm not returning explicit UserType, is it a problem ?
# I actually do it with the Meta class. I guess it is the same for this
and it works whereas I didn’t specify anything for the response attributes. And I don’t even return the same kind of thing. Can someone explain if I’m doing it wrong ?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
835 questions with answers in MUTATION | Science topic
1- Can i calculate probable no of mutation in each branch? · 2- Is there any tools available for that? · 3-I also...
Read more >Question about graphene-django mutation documentation
In the documentation, here, in the QuestionMutation class, there is a question attribute. What does that actually mean ?
Read more >Genetic Mutation | Learn Science at Scitable - Nature
The answer to this question is closely linked to the molecular details of how both DNA and the entire genome are organized. The...
Read more >Standard Mutation Nomenclature in Molecular Diagnostics
Standard mutation nomenclature based on coding DNA reference sequences and protein-level amino acid sequences requires prefixes “c.” and “p.,” respectively, as ...
Read more >DNA and Mutations - Understanding Evolution
by the Understanding Evolution team A mutation is a change in DNA, the hereditary material of life ... In this article, we will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you do not define an
output
type then you must define the return fields on your mutation itself. The example documentation does not define output but opts to return an instance of itself instead. Returning theuser
model instance works for you because it duck types toUserType
.From the code docs:
I see. Thanks for your advices !