Lib for adding file upload functionality to GraphQL mutations in Graphene Django
Project description
graphene-file-upload is a drop in replacement for the the GraphQL view in Graphene for Django. It supports multi-part file uploads that adhere to the Multipart Request Spec (https://github.com/jaydenseric/graphql-multipart-request-spec).
Installation:
pip install graphene-file-upload
Usage:
To use, import the view, then add to your list of urls (replace previous GraphQL view).
from graphene_file_upload import ModifiedGraphQLView
urlpatterns = [
url(r'^graphql', ModifiedGraphQLView.as_view(graphiql=True)),
]
To add an upload type to your mutation, import and use Upload. Upload is a scalar type.
from graphene_file_upload import Upload
class UploadMutation(graphene.Mutation):
class Arguments:
file = Upload(required=True)
success = graphene.Boolean()
def mutate(self, info, file, **kwargs):
# file parameter is key to uploaded file in FILES from context
uploaded_file = info.context.FILES.get(file)
# do something with your file
return UploadMutation(success=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for graphene_file_upload-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aed0a9702eccda0750403b58e837b2631357457c7f4d793724d9930c1bb997a1 |
|
MD5 | eab360c5966dab96862b0adbf535ce5e |
|
BLAKE2b-256 | 193b1412fe4e7056cb76ace96b4a2b27360e65d8e1dbdcd98ba972098a518289 |
Close
Hashes for graphene_file_upload-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 804af6c43296f87ebc4999cc0b7d7e01fea36fc6af9c344bed9341bb61006692 |
|
MD5 | cd93cfdf0fff244bdb2acde0e0d04cfa |
|
BLAKE2b-256 | 0c6f0891c501c701f8f645386f0c397b7692be795d93fa30648f88403865c4d5 |