graphene-django-subscriptions icon indicating copy to clipboard operation
graphene-django-subscriptions copied to clipboard

Subscriptions are not allowed.

Open masarliev opened this issue 7 years ago • 7 comments

I followed the example and I got Subscriptions are not allowed. You will need to either use the subscribe function or pass allow_subscriptions=True What am I missing?

masarliev avatar Oct 04 '18 13:10 masarliev

Hi @masarliev, you must make sure that the graphql url of your project defines it using the view graphene_django_extras.views.ExtraGraphQLView, something like that

 from graphene_django_extras.views import ExtraGraphQLView

urlpatterns = [
# .....
 url(r'^graphql', ExtraGraphQLView.as_view(graphiql=True, schema=schema), name='graphql'),
]

Please can you please let me know if the error was corrected. Right now I am working on an update of this module and its documentation

eamigo86 avatar Oct 04 '18 13:10 eamigo86

Thanks for the fast replay. I am still getting the same error. Later today or tomorrow I can provide simple application

masarliev avatar Oct 04 '18 14:10 masarliev

https://github.com/graphql-python/graphql-ws/issues/8 I have the same problem as here

masarliev avatar Oct 04 '18 14:10 masarliev

https://github.com/masarliev/subs-example @eamigo86 here is the example project

masarliev avatar Oct 05 '18 05:10 masarliev

Hi @masarliev , I was reviewing your project and apparently it lacks the definition of the file asgi.py, and it's mandatory for Channles. Could you send me what the command "pip freeze" returns?

eamigo86 avatar Oct 07 '18 11:10 eamigo86

for this I was using docker python:3.6 image and install all required packages from requirements.txt I found that using python setup.py install from master branch works like charm

masarliev avatar Oct 08 '18 06:10 masarliev

defining a custom GraphQLCoreBackend can pass allow_subscriptions to execution context like:

class GraphQLCustomCoreBackend(GraphQLCoreBackend):
    def __init__(self, executor=None):
        # type: (Optional[Any]) -> None
        super().__init__(executor)
        self.execute_params['allow_subscriptions'] = True

then it can be passed to your GraphQL view (say):

url(r'^graphql', GraphQLView.as_view(graphiql=True, backend=GraphQLCustomCoreBackend()))

https://github.com/graphql-python/graphql-ws/issues/8#issuecomment-482062178

ambientlight avatar Apr 11 '19 10:04 ambientlight