什么是route_类替换?

2024-09-30 08:26:19 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是关于Django的GraphQL订阅的教程。 但在路由通道上没有“route_class”成员。 但我不知道为什么。 有人知道如何使用通道路由吗

class Suscription(ObjectType):
  count_seconds = Int(up_to=Int())

  def resolve_count_seconds(root, info, up_to=5):
    return Observable.interval(1000).map(lambda i: "{0}".format(i))\
      .take_while(lambda i: int(i) <= up_to)

ROOT_SCHEMA = graphene.Schema(query=Query, mutation=Mutation, suscription=Suscription)

#urls
from channels.routing import route_class # route_class does not exists
from graphql_ws.django_channels import GraphQLSubscriptionConsumer
channel_routes = [
  route_class(GraphQLSubscriptionConsumer, path='subscriptions')
]

Tags: todjangolambdafromimport路由countroute

热门问题