mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-26 03:23:55 +03:00
Avoid ambiguity in graphene.Mutation docstring
The code example in docstring starts with `from graphene import Mutation` and defines a `class Mutation` later. This definition would shadow previously imported name and (which is more important) confuses a reader about usage of this class — one need to keep in mind that previous usage of `Mutation` is imported from graphene and have not been overridden yet. This PR changes an import-from statement to an import statement, so `graphene.Mutation` is used explicitly. This approach is consistent with other code examples in docs (e. g. https://docs.graphene-python.org/en/v2.1.9/types/mutations/). Another option is to change name of example class Mutation to something more clear (maybe SchemaMutation or RootMutation), but I'm not sure what name to choose. Only docstring is updated, no code changes.
This commit is contained in:
parent
0a54094f59
commit
b274a607f4
|
@ -29,21 +29,21 @@ class Mutation(ObjectType):
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from graphene import Mutation, ObjectType, String, Boolean, Field
|
import graphene
|
||||||
|
|
||||||
class CreatePerson(Mutation):
|
class CreatePerson(graphene.Mutation):
|
||||||
class Arguments:
|
class Arguments:
|
||||||
name = String()
|
name = graphene.String()
|
||||||
|
|
||||||
ok = Boolean()
|
ok = graphene.Boolean()
|
||||||
person = Field(Person)
|
person = graphene.Field(Person)
|
||||||
|
|
||||||
def mutate(parent, info, name):
|
def mutate(parent, info, name):
|
||||||
person = Person(name=name)
|
person = Person(name=name)
|
||||||
ok = True
|
ok = True
|
||||||
return CreatePerson(person=person, ok=ok)
|
return CreatePerson(person=person, ok=ok)
|
||||||
|
|
||||||
class Mutation(ObjectType):
|
class Mutation(graphene.ObjectType):
|
||||||
create_person = CreatePerson.Field()
|
create_person = CreatePerson.Field()
|
||||||
|
|
||||||
Meta class options (optional):
|
Meta class options (optional):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user