-
Notifications
You must be signed in to change notification settings - Fork 89
Django Channels Example issues #8
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
Comments
I have experienced exactly the same today, but after seeing your issue I have stopped trying already after the second step. |
I'm whiling to help, but I don't understand too much about the Observables :( |
I've checked that |
@jonatasbaldin which version of channels are you using? |
Changing the urls.py it's solved |
I'm stuck on the AnonymousObserable issue as well. https://github.com/xDHILEx/graphqlwsdjangochannels. @colanconnon I'm using channels 1.1.8 |
@xDHILEx I will have to look at this closer when I have some time |
Has anyone managed to solve this? I'm getting the same issue. |
just discovered graphene and though of evaluating state of graphql integration with django. For short:
from graphql.backend import GraphQLCoreBackend
class GraphQLCustomCoreBackend(GraphQLCoreBackend):
def __init__(self, executor=None):
# type: (Optional[Any]) -> None
super().__init__(executor)
self.execute_params['allow_subscriptions'] = True
class GraphQLObservableUnboxingView(GraphQLView):
def execute_graphql_request(
self, request, data, query, variables, operation_name, show_graphiql=False
):
target_result = None
def override_target_result(value):
nonlocal target_result
target_result = value
execution_result = super().execute_graphql_request(request, data, query, variables, operation_name, show_graphiql)
if execution_result:
if isinstance(execution_result, ObservableBase):
target = execution_result.subscribe(on_next=lambda value: override_target_result(value))
target.dispose()
else:
return execution_result
return target_result So in urls.py it can be:
I have not used django channels and just tried reproducing the most possible minimal example so that subscription can be resolved: subscription{
subscribeToFoo(id: 1)
} from rx import Observable
class Subscription(graphene.ObjectType):
subscribe_to_foo = graphene.Boolean(id=graphene.Int())
def resolve_subscribe_to_foo(self, args, **kwargs):
return Observable.of(True)
schema = graphene.Schema(query=Query, subscription=Subscription) also please make sure you are using rxpy 1.6.* |
what is it ObservableBase? |
@ambientlight your solution seems to work when MIDDLEWARE: [ ], but since I'm using 'graphql_jwt.middleware.JSONWebTokenMiddleware', the rest of queries and mutations throws a Not logged in Error... |
@phjocoronel2806: @carlosalvarez91: haven't used any middleware with the above test so cannot yet give you any feedback on this. |
@carlosalvarez91 same issue as you.. Did you come up with any solution? |
@arturataide I ended up using this: https://github.com/datadvance/DjangoChannelsGraphqlWs |
Django v2+ version now merged to master |
Hello there, I am trying to call a subscription from PostMan, but whenever run got is error even when I did the same step as @ambientlight did. I can't find any solution for that any help please! |
Description
When testing the Django Channels examples, I went through some errors:
1:
graphql_ws/django_channels.py
file is not on the latest package version. But I downloaded it manually inside the package.2: I was getting the error
"Subscriptions are not allowed. You will need to either use the subscribe function or pass allow_subscriptions=True"
. And, since theGraphQLView
object does not support theallow_subscriptions
parameter, I changed it inside the package toTrue
(just for testing).3. After that, I was getting the error
Subscription must return Async Iterable or Observable
. Reading this issue, I decided to add'MIDDLEWARE: []
into theGRAPHENE
settings variable.4. After that, I started receiving this error:
'AnonymousObservable' object has no attribute 'errors'
. Then I got a little bit frustrated and stop trying 😅Does anyone have a clue why this is happening?
Thanks!
The text was updated successfully, but these errors were encountered: