graphene-subscriptions: Error: "subscriptions are not allowed"
Hey there, trying to get this set up in my project. I’ve gone through the README and set up the required pieces (I think). I’m now trying to use Graphiql to test out a subscription that I set up. When I do, I get this error response:
Subscriptions are not allowed. You will need to either use the subscribe function or pass allow_subscriptions=True
and can see this in stack trace as well:
File "/Users/levinotik/.local/share/virtualenvs/great-control-ic_1WMqr/lib/python3.7/site-packages/graphql/execution/executor.py", line 176, in execute_operation
"Subscriptions are not allowed. "
I must be missing something basic. Any ideas on what I’m doing wrong here? Thanks.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 76 (25 by maintainers)
Guys, I figured it out, I used the examples given in this tests with their schemas and they worked properly. So on my code I’ll modify it a little bit so that it can receive signals.
And also
If your terminal doesn’t print that, it means your signals aren’t being read. What you do is try calling your app in init.py using your apps config
default_app_config = 'subs.apps.SubsConfig'
Thanks @jaydenwindle for the package.
@levinotik I get an error. Could be an issue with graphql-core: https://github.com/graphql-python/graphql-core/issues/149.
Well, I’ll be damned. Works now! Thanks so much for your time on this, really appreciate it!
I don’t understand where is the solution?
Thanks a lot, @jaydenwindle that’s helpful!
Thank you @jaydenwindle, @levinotik I’m happy to state that this was very helpful. I’m recommending graphene-subscriptions to anyone looking to plug subscriptions.
Ok, just passed
runserver
to our custommanage.sh
script and it seems to work! All good now.I’m not sure, taking a closer look. I first need to fix some issues that will let me run with the regular
runserver
and not WSGI which you had said won’t work because WS requests need to be processed asynchronously.Ok, I think I may have found the issue. This is definitely on me for not documenting something this important in the readme 🤦♂️.
You’ll need to set up Channel Layers in order for subscriptions to work properly. If you don’t want to set up a Redis in your dev environment, you can set up Channel Layers using an in-memory backend by adding the following to your
settings.py
file:I’m updating the REAME now. Can you give this a try and see if it works for you? I still think you might have a config issue (since there are no websocket connections in the logs), but let’s try this first.
Hey @levinotik! Yes, afaik the default GraphiQL view in Graphene doesn’t support subscriptions out of the box. That’s really neat that you can add subscription support to the default GraphiQL view by passing in a different backend, I didn’t know that!
I usually use GraphQL Playground to test anything subscription-related. Can you test this example in GraphQL Playground to see whether it’s a GraphiQL view issue or a subscriptions implementation issue that’s happening here?
I’ll see if I can reproduce this locally as well. Can you post some more details about your setup (
requirements.txt
, how you’re triggering the subscription, etc) to help me debug?I think I actually got past that issue by creating a custom
GraphQLCoreBackend
and hooking it up in my
urls.py
as inpath('graphql/', csrf_exempt(CustomGraphQLView.as_view(graphiql=True, backend=GraphQLCustomCoreBackend())), name='graphql')
.The issue now is that I’m receiving this error:
My resolve function is defined as:
Any guidance on this?