Merge pull request #657 from sweenr/patch-1

Update mutations.rst
This commit is contained in:
Paul Hallett 2019-06-07 09:06:09 +01:00 committed by GitHub
commit bad8e13282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,7 +199,9 @@ You can use relay with mutations. A Relay mutation must inherit from
.. code:: python .. code:: python
import graphene import relay, DjangoObjectType import graphene
from graphene import relay
from graphene_django import DjangoObjectType
from graphql_relay import from_global_id from graphql_relay import from_global_id
from .queries import QuestionType from .queries import QuestionType
@ -214,7 +216,7 @@ You can use relay with mutations. A Relay mutation must inherit from
@classmethod @classmethod
def mutate_and_get_payload(cls, root, info, text, id): def mutate_and_get_payload(cls, root, info, text, id):
question = Question.objects.get(pk=from_global_id(id)) question = Question.objects.get(pk=from_global_id(id)[1])
question.text = text question.text = text
question.save() question.save()
return QuestionMutation(question=question) return QuestionMutation(question=question)
@ -226,4 +228,4 @@ Relay ClientIDMutation accept a ``clientIDMutation`` argument.
This argument is also sent back to the client with the mutation result This argument is also sent back to the client with the mutation result
(you do not have to do anything). For services that manage (you do not have to do anything). For services that manage
a pool of many GraphQL requests in bulk, the ``clientIDMutation`` a pool of many GraphQL requests in bulk, the ``clientIDMutation``
allows you to match up a specific mutation with the response. allows you to match up a specific mutation with the response.