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:
belkka 2021-10-11 23:46:13 +03:00 committed by GitHub
parent 0a54094f59
commit b274a607f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,21 +29,21 @@ class Mutation(ObjectType):
.. code:: python
from graphene import Mutation, ObjectType, String, Boolean, Field
import graphene
class CreatePerson(Mutation):
class CreatePerson(graphene.Mutation):
class Arguments:
name = String()
name = graphene.String()
ok = Boolean()
person = Field(Person)
ok = graphene.Boolean()
person = graphene.Field(Person)
def mutate(parent, info, name):
person = Person(name=name)
ok = True
return CreatePerson(person=person, ok=ok)
class Mutation(ObjectType):
class Mutation(graphene.ObjectType):
create_person = CreatePerson.Field()
Meta class options (optional):