Boilerplate Serverless implementation of GraphQL server in Python using Ariadne
- Schema-first approach
- Implemented in Python
- Serverless
- Hosting on Azure Cloud
- Modular
- Support for WSGI and ASGI
- Lightweight
- Test-driven Development
- Active Azure cloud account
- Local development environment setup for Azure functions using Python
- Clone the repo,
git clone https://github.com/vizeit/GraphQLServer-Ariadne-AzureFunc.git
- Install ariadne
pip install ariadne
-
Go to __init__.py
-
Import GraphQL class from either WSGI or ASGI module of Ariadne
from ariadne.wsgi import GraphQL
or
from ariadne.asgi import GraphQL
- Import WsgiMiddleware or AsgiMiddleware class from azure.functions module
from azure.functions import WsgiMiddleware
or
from azure.functions import AsgiMiddleware
- Return WsgiMiddleware or AsgiMiddleware object from the main function w.r.t. your import in 3 and 4 above
return WsgiMiddleware(app).handle(req, context)
or
return AsgiMiddleware(app).handle(req, context)
-
Define GraphQL schema under Schemas folder
-
Write GraphQL resolvers for the schema in resolvers.py
-
Add the unit tests under tests folder. Run the unit tests after any changes,
python -m unittest -v tests/*.py