Update mutations.rst

I believe the `[1]` was ommitted from the `from_global_id` call as that method returns a tuple of type and id, of which we're only interested in the id here. Took me half a day to figure out why this code wasn't working today. See function def here: https://github.com/graphql-python/graphql-relay-py/blob/master/graphql_relay/node/node.py#L67
This commit is contained in:
Richard Sween 2019-06-05 19:43:51 -05:00 committed by GitHub
parent 0916e03cb3
commit fc49a50cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,7 +214,7 @@ You can use relay with mutations. A Relay mutation must inherit from
@classmethod
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.save()
return QuestionMutation(question=question)
@ -226,4 +226,4 @@ Relay ClientIDMutation accept a ``clientIDMutation`` argument.
This argument is also sent back to the client with the mutation result
(you do not have to do anything). For services that manage
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.