Skip to content

Commit 1232ff3

Browse files
committed
Added documentation on how to accept files in a mutation
1 parent a3c3be2 commit 1232ff3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/relay/mutations.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,29 @@ subclass of ``relay.ClientIDMutation``.
2727
ship = create_ship(ship_name, faction_id)
2828
faction = get_faction(faction_id)
2929
return IntroduceShip(ship=ship, faction=faction)
30+
31+
32+
33+
Accepting Files
34+
-------------
35+
36+
Mutations can also accept files, they will be in the context varibale
37+
38+
.. code:: python
39+
40+
class UploadFile(graphene.ClientIDMutation):
41+
class Input:
42+
pass
43+
# nothing needed for uploading file
44+
45+
# your return fields
46+
success = graphene.String()
47+
48+
@classmethod
49+
def mutate_and_get_payload(cls, input, context, info):
50+
files = context.FILES
51+
print(files)
52+
53+
# do something with files
54+
55+
return UploadFile(success=True)

0 commit comments

Comments
 (0)