mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-08 23:50:38 +03:00
Update mutations.rst
This commit is contained in:
parent
17f6a45a47
commit
5acd04aa93
|
@ -85,9 +85,9 @@ We should receive:
|
||||||
|
|
||||||
InputFields and InputObjectTypes
|
InputFields and InputObjectTypes
|
||||||
----------------------------------
|
----------------------------------
|
||||||
InputFields are used in mutations to allow nested input data for mutations
|
InputFields are used in mutations to allow nested input data for mutations.
|
||||||
|
|
||||||
To use an InputField you define an InputObjectType that specifies the structure of your input data
|
To use an InputField you define an InputObjectType that specifies the structure of your input data:
|
||||||
|
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
@ -112,7 +112,7 @@ To use an InputField you define an InputObjectType that specifies the structure
|
||||||
return CreatePerson(person=person)
|
return CreatePerson(person=person)
|
||||||
|
|
||||||
|
|
||||||
Note that **name** and **age** are part of **person_data** now
|
Note that **name** and **age** are part of **person_data** now.
|
||||||
|
|
||||||
Using the above mutation your new query would look like this:
|
Using the above mutation your new query would look like this:
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ Using the above mutation your new query would look like this:
|
||||||
}
|
}
|
||||||
|
|
||||||
InputObjectTypes can also be fields of InputObjectTypes allowing you to have
|
InputObjectTypes can also be fields of InputObjectTypes allowing you to have
|
||||||
as complex of input data as you need
|
as complex of input data as you need:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ To return an existing ObjectType instead of a mutation-specific type, set the **
|
||||||
def mutate(root, info, name):
|
def mutate(root, info, name):
|
||||||
return Person(name=name)
|
return Person(name=name)
|
||||||
|
|
||||||
Then, if we query (``schema.execute(query_str)``) the following:
|
Then, if we query (``schema.execute(query_str)``) with the following:
|
||||||
|
|
||||||
.. code::
|
.. code::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user