mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-25 11:03:58 +03:00
Added documentation on how to accept files in a mutation
This commit is contained in:
parent
a3c3be26f4
commit
1232ff3ee1
|
@ -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)
|
Loading…
Reference in New Issue
Block a user