Skip to content

Commit b274a60

Browse files
authored
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.
1 parent 0a54094 commit b274a60

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

graphene/types/mutation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ class Mutation(ObjectType):
2929
3030
.. code:: python
3131
32-
from graphene import Mutation, ObjectType, String, Boolean, Field
32+
import graphene
3333
34-
class CreatePerson(Mutation):
34+
class CreatePerson(graphene.Mutation):
3535
class Arguments:
36-
name = String()
36+
name = graphene.String()
3737
38-
ok = Boolean()
39-
person = Field(Person)
38+
ok = graphene.Boolean()
39+
person = graphene.Field(Person)
4040
4141
def mutate(parent, info, name):
4242
person = Person(name=name)
4343
ok = True
4444
return CreatePerson(person=person, ok=ok)
4545
46-
class Mutation(ObjectType):
46+
class Mutation(graphene.ObjectType):
4747
create_person = CreatePerson.Field()
4848
4949
Meta class options (optional):

0 commit comments

Comments
 (0)