Added documentation on how to accept files in a mutation

This commit is contained in:
BossGrand 2017-02-06 11:40:04 -08:00
parent a3c3be26f4
commit 1232ff3ee1

View File

@ -27,3 +27,29 @@ subclass of ``relay.ClientIDMutation``.
ship = create_ship(ship_name, faction_id) ship = create_ship(ship_name, faction_id)
faction = get_faction(faction_id) faction = get_faction(faction_id)
return IntroduceShip(ship=ship, faction=faction) 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)