From fc49a50cc3bceda9ac578c1746de35e2422cf99d Mon Sep 17 00:00:00 2001 From: Richard Sween Date: Wed, 5 Jun 2019 19:43:51 -0500 Subject: [PATCH 1/2] 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 --- docs/mutations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/mutations.rst b/docs/mutations.rst index f6c6f14e8..15bef1d0e 100644 --- a/docs/mutations.rst +++ b/docs/mutations.rst @@ -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. \ No newline at end of file +allows you to match up a specific mutation with the response. From d06217d2033375d19ad0cdaf4b0afb74c0eba408 Mon Sep 17 00:00:00 2001 From: Richard Sween Date: Thu, 6 Jun 2019 13:53:16 -0500 Subject: [PATCH 2/2] Fix Mutations Relay example imports Per comment here: https://github.com/graphql-python/graphene-django/pull/657#issuecomment-499618785 --- docs/mutations.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/mutations.rst b/docs/mutations.rst index 15bef1d0e..661015171 100644 --- a/docs/mutations.rst +++ b/docs/mutations.rst @@ -199,7 +199,9 @@ You can use relay with mutations. A Relay mutation must inherit from .. 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 .queries import QuestionType