Adds GraphQL support to your Django project.
Install the integration with:
pip install graphql-server[django]
Use the GraphQLView from graphql_server.django.
from django.urls import path
from graphql_server.django import GraphQLView
from schema import schema
urlpatterns = [
path("graphql/", GraphQLView.as_view(schema=schema, graphiql=True)),
]CORS
Enable CORS with
django-cors-headers.
schemagraphiqlgraphql_ideallow_queries_via_getmultipart_uploads_enabled
You can also subclass GraphQLView and overwrite get_root_value(self, request) to have a dynamic root value per request.
class UserRootValue(GraphQLView):
def get_root_value(self, request):
return request.userSee CONTRIBUTING.md