I'd like to add GraphQL subscriptions to a backend GraphQL API. Can I debug subscriptions with the graphene_django
builtin GraphiQL?
# <django-project>/settings.py
...
from graphene_django.views import GraphQLView
urlpatterns = [
...,
url(r'^graphql$', GraphQLView.as_view(graphiql=True)),
...,
]
According to graphene-subscriptions/issues/1 it seems like it's possible to create a custom GraphQLCustomCoreBackend
class GraphQLCustomCoreBackend(GraphQLCoreBackend):
def __init__(self, executor=None):
# type: (Optional[Any]) -> None
super().__init__(executor)
self.execute_params['allow_subscriptions'] = True
and include it with
# <django-project>/urls.py
url_paths = [
...,
path('graphql/', csrf_exempt(CustomGraphQLView.as_view(graphiql=True, backend=GraphQLCustomCoreBackend())), name='graphql'),
...,
]
to override the default one. However not tested yet.