Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions are not allowed. #7

Open
masarliev opened this issue Oct 4, 2018 · 7 comments
Open

Subscriptions are not allowed. #7

masarliev opened this issue Oct 4, 2018 · 7 comments

Comments

@masarliev
Copy link

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?

@eamigo86
Copy link
Owner

eamigo86 commented Oct 4, 2018

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

@masarliev
Copy link
Author

masarliev commented Oct 4, 2018

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

@masarliev
Copy link
Author

graphql-python/graphql-ws#8
I have the same problem as here

@masarliev
Copy link
Author

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

@eamigo86
Copy link
Owner

eamigo86 commented Oct 7, 2018

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?

@masarliev
Copy link
Author

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

@ambientlight
Copy link

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()))

graphql-python/graphql-ws#8 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants