File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -244,17 +244,17 @@ class GraphQLHTTPConsumer(
244
244
To use this, place it in your ProtocolTypeRouter for your channels project:
245
245
246
246
```
247
- from graphql_server.channels import GraphQLHttpRouter
247
+ from graphql_server.channels import GraphQLHTTPConsumer, GraphQLWSConsumer
248
248
from channels.routing import ProtocolTypeRouter
249
249
from django.core.asgi import get_asgi_application
250
250
251
251
application = ProtocolTypeRouter({
252
252
"http": URLRouter([
253
- re_path("^graphql", GraphQLHTTPRouter (schema=schema)),
253
+ re_path("^graphql", GraphQLHTTPConsumer.as_asgi (schema=schema)),
254
254
re_path("^", get_asgi_application()),
255
255
]),
256
256
"websocket": URLRouter([
257
- re_path("^ws/graphql", GraphQLWebSocketRouter (schema=schema)),
257
+ re_path("^ws/graphql", GraphQLWSConsumer.as_asgi (schema=schema)),
258
258
]),
259
259
})
260
260
```
Original file line number Diff line number Diff line change @@ -49,8 +49,17 @@ def __init__(
49
49
schema : GraphQLSchema ,
50
50
django_application : Optional [str ] = None ,
51
51
url_pattern : str = "^graphql" ,
52
+ http_consumer_class : type [GraphQLHTTPConsumer ] = GraphQLHTTPConsumer ,
53
+ ws_consumer_class : type [GraphQLWSConsumer ] = GraphQLWSConsumer ,
54
+ * args ,
55
+ ** kwargs ,
52
56
) -> None :
53
- http_urls = [re_path (url_pattern , GraphQLHTTPConsumer .as_asgi (schema = schema ))]
57
+ http_urls = [
58
+ re_path (
59
+ url_pattern ,
60
+ http_consumer_class .as_asgi (* args , ** kwargs ),
61
+ )
62
+ ]
54
63
if django_application is not None :
55
64
http_urls .append (re_path ("^" , django_application ))
56
65
@@ -59,7 +68,10 @@ def __init__(
59
68
"http" : URLRouter (http_urls ),
60
69
"websocket" : URLRouter (
61
70
[
62
- re_path (url_pattern , GraphQLWSConsumer .as_asgi (schema = schema )),
71
+ re_path (
72
+ url_pattern ,
73
+ ws_consumer_class .as_asgi (* args , ** kwargs ),
74
+ ),
63
75
]
64
76
),
65
77
}
Original file line number Diff line number Diff line change
1
+ from .views import GraphQLView , AsyncGraphQLView
2
+
3
+ __all__ = ["GraphQLView" , "AsyncGraphQLView" ]
You can’t perform that action at this time.
0 commit comments