This release is a pre-release and may not be stable for production use.
graphene-file-upload is a drop in replacement for the the GraphQL view in Graphene for Django, and for Flask-Graphql. It supports multi-part file uploads that adhere to the Multipart Request Spec.
Installation:
pip install graphene-file-upload
Usage
To add an upload type to your mutation, import and use Upload. Upload is a scalar type.
from graphene_file_upload.scalars import Upload
class UploadMutation(graphene.Mutation):
class Arguments:
file = Upload(required=True)
success = graphene.Boolean()
def mutate(self, info, file, **kwargs):
# do something with your file
return UploadMutation(success=True)
Django Integration:
To use, import the view, then add to your list of urls (replace previous GraphQL view).
from graphene_file_upload.django import FileUploadGraphQLView
urlpatterns = [
url(r'^graphql', FileUploadGraphQLView.as_view(graphiql=True)),
]
Flask Integration:
Note that flask-graphql version <2.0 is not supported. At the time of writing this README, you must install flask-graphql with pip install --pre flask-graphql
Simply import the modified view and create a new url rule on your app:
from graphene_file_upload.flask import FileUploadGraphQLView
app.add_url_rule(
'/graphql',
view_func=FileUploadGraphQLView.as_view(
...
)
)
Testing:
TO-DO, still need to write tests for Django and Flask views.
Packaging for PyPi:
Build the distribution.
python3 setup.py sdist bdist_wheel
Upload to PyPi test servers.
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Upload to PyPi production servers.
twine upload dist/*
Release files for graphene-file-upload 1.0.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graphene_file_upload-1.0.0a2.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graphene_file_upload-1.0.0a2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / graphene_file_upload-1.0.0a2.tar.gz
| Download URL | graphene_file_upload-1.0.0a2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
779bfc8aba1f66af0274e1ce28ead3b47d336e5fef94734eb2055ea4cc93ed85
|
|
BLAKE2b-256 checksum How to use checksums |
e93bdbe70d8f57a822ba63c47d82e76fed13c9e08d448647b4e1bb34b26dc4d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / graphene_file_upload-1.0.0a2-py3-none-any.whl
| Download URL | graphene_file_upload-1.0.0a2-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3144e66137d66ead4f67e093c63349ca5f5d216e92d8891bdd755a8c0987e504
|
|
BLAKE2b-256 checksum How to use checksums |
7454fb85c9e2b88cf372b2e642b11a5cce128d96547126895a302d29181adb74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |