From 1232ff3ee1e4006a262be5e50664f44c6e635200 Mon Sep 17 00:00:00 2001 From: BossGrand Date: Mon, 6 Feb 2017 11:40:04 -0800 Subject: [PATCH 1/3] Added documentation on how to accept files in a mutation --- docs/relay/mutations.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/relay/mutations.rst b/docs/relay/mutations.rst index c10b2e29..16dc9084 100644 --- a/docs/relay/mutations.rst +++ b/docs/relay/mutations.rst @@ -27,3 +27,29 @@ subclass of ``relay.ClientIDMutation``. ship = create_ship(ship_name, faction_id) faction = get_faction(faction_id) return IntroduceShip(ship=ship, faction=faction) + + + +Accepting Files +------------- + +Mutations can also accept files, they will be in the context varibale + +.. code:: python + + class UploadFile(graphene.ClientIDMutation): + class Input: + pass + # nothing needed for uploading file + + # your return fields + success = graphene.String() + + @classmethod + def mutate_and_get_payload(cls, input, context, info): + files = context.FILES + print(files) + + # do something with files + + return UploadFile(success=True) \ No newline at end of file From b9d3abee3166b71a6a56302e1c0cac554230b8ea Mon Sep 17 00:00:00 2001 From: BossGrand Date: Mon, 6 Feb 2017 17:14:07 -0800 Subject: [PATCH 2/3] fixed a few documentation bugs there was a warning of header underline not being long enough and code type graphql was being used intead of json --- docs/types/mutations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/types/mutations.rst b/docs/types/mutations.rst index 9095ab58..1155f1e8 100644 --- a/docs/types/mutations.rst +++ b/docs/types/mutations.rst @@ -78,7 +78,7 @@ We should receive: } InputFields and InputObjectTypes ----------------------- +---------------------------------- 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 @@ -114,7 +114,7 @@ Note that **name** and **age** are part of **person_data** now Using the above mutation your new query would look like this: -.. code:: graphql +.. code:: json mutation myFirstMutation { createPerson(personData: {name:"Peter", age: 24}) { From 0ed4050bb63e1a338e88e9176f197bebe327769e Mon Sep 17 00:00:00 2001 From: Charles Haro Date: Mon, 6 Feb 2017 17:19:02 -0800 Subject: [PATCH 3/3] fixed typo --- docs/relay/mutations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/relay/mutations.rst b/docs/relay/mutations.rst index 16dc9084..48185e3f 100644 --- a/docs/relay/mutations.rst +++ b/docs/relay/mutations.rst @@ -33,7 +33,7 @@ subclass of ``relay.ClientIDMutation``. Accepting Files ------------- -Mutations can also accept files, they will be in the context varibale +Mutations can also accept files, they will be in the context variable. .. code:: python @@ -52,4 +52,4 @@ Mutations can also accept files, they will be in the context varibale # do something with files - return UploadFile(success=True) \ No newline at end of file + return UploadFile(success=True)