Description
Hi there,
The documentation on Mutations is a little confusing about the arguments the mutate
method of a Mutation
receives. Two examples list the method as:
# https://github.com/allardhoeve/graphene/blame/abff3d75/docs/types/mutations.rst#L22
class Something(Mutation):
def mutate(self, info, *args):
pass
This is actually incorrect, as the mutate
method is always a @staticmethod
, because the resolver is unbound here in graphene/types/mutation.py.
This is documented further on as:
# https://github.com/allardhoeve/graphene/blame/abff3d75a39/docs/types/mutations.rst#L107
class CreatePerson(graphene.Mutation):
...
@staticmethod
def mutate(root, info, person_data=None):
pass
I would like to document this better in this part of the documentation, because it has caused me a lot of time to figure this out and would like to spare other that effort.
Can you elaborate on when root
is set and what it will contain? I've only seen cases where root
is None
.
Also, can you elaborate on why you chose to make the resolver method mutate
a static method by default? It being a static method makes it hard to implement inheritance between Mutation
classes.
Finally, how would I go about having a resolver method that is NOT a static method if I wanted to? The code suggests I could use Meta
attributes to do so, but the documentation does not tell me how. I would like to add that to the documentation.
Edit: The resolvers always being a staticmethod
is documented here, but you have to first know that def mutate
is considered a resolver and also you'd have to really remember that.
Thanks