Skip to content

Exception inside application: No route found for path 'graphql'. #101

Description

@wlodevelopteam

after handshake, we got this error.
Exception inside application: No route found for path 'graphql'.

we implemented basic approach as below. whats wrong inside our approach?

### project/schema
class MySubscription(channels_graphql_ws.Subscription):
    notification_queue_limit = 64
    event = graphene.String()

    class Arguments:
        arg1 = graphene.String()
        arg2 = graphene.String()

    @staticmethod
    def subscribe(root, info, arg1, arg2):
        return ["group42"]

    @staticmethod
    def publish(payload, info, arg1, arg2):
        return MySubscription(event="Something has happened!")
    
class Subscription(graphene.ObjectType):
    my_subscription = MySubscription.Field()
### app/consumers.py
import channels_graphql_ws
from project.schema import schema

class MyGraphqlWsConsumer(channels_graphql_ws.GraphqlWsConsumer):
    schema = schema

    # send_keepalive_every = 42
    # strict_ordering = True

    async def on_connect(self, payload):
        print("New client connected!")
### project/asgi.py
import os
import channels
from django.urls import path
from django.core.asgi import get_asgi_application

from app.consumers import MyGraphqlWsConsumer

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

django_asgi_app = get_asgi_application()

application = channels.routing.ProtocolTypeRouter({
    "http": get_asgi_application(),
    "websocket": channels.routing.URLRouter([
        path("/graphql", MyGraphqlWsConsumer),
    ])
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions