mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Define abstract Mutation.mutate() method
Add default implementation of Mutation.mutate() that raises NotImplementedError. This makes code more clear and also improves work of auto-completion tools (e. g. in IDE). They usually guess if user is overriding a class method and suggest to complete method name/arguments.
This commit is contained in:
parent
5fb7b54377
commit
a97d3d3321
|
@ -104,9 +104,7 @@ class Mutation(ObjectType):
|
||||||
)
|
)
|
||||||
arguments = props(input_class) if input_class else {}
|
arguments = props(input_class) if input_class else {}
|
||||||
if not resolver:
|
if not resolver:
|
||||||
mutate = getattr(cls, "mutate", None)
|
resolver = get_unbound_function(cls.mutate)
|
||||||
assert mutate, "All mutations must define a mutate method in it"
|
|
||||||
resolver = get_unbound_function(mutate)
|
|
||||||
if _meta.fields:
|
if _meta.fields:
|
||||||
_meta.fields.update(fields)
|
_meta.fields.update(fields)
|
||||||
else:
|
else:
|
||||||
|
@ -118,6 +116,10 @@ class Mutation(ObjectType):
|
||||||
|
|
||||||
super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def mutate(cls, parent, info, **kwargs):
|
||||||
|
raise NotImplementedError("All mutations must define a mutate method in it")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Field(
|
def Field(
|
||||||
cls, name=None, description=None, deprecation_reason=None, required=False
|
cls, name=None, description=None, deprecation_reason=None, required=False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user