You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### 2- Defining Channels settings and custom routing config ( *For more information see Channels documentation* ):
326
326
327
-
Defining our app routing, like custom apps urls:
327
+
We define app routing, as if they were app urls:
328
328
329
329
```python
330
330
# app/routing.py
@@ -345,7 +345,7 @@ app_routing = [
345
345
]
346
346
```
347
347
348
-
Defining our project routing, like custom root project urls:
348
+
We define project routing, as if they were project urls:
349
349
350
350
```python
351
351
# project/routing.py
@@ -358,7 +358,7 @@ project_routing = [
358
358
359
359
```
360
360
361
-
You should add **channels** and **channels_api** modules into your INSTALLED_APPS setting and you must defining your routing project definition into the CHANNEL_LAYERS setting:
361
+
You should put into your INSTALLED_APPS the **channels** and **channels_api** modules and you must to add your project's routing definition into the CHANNEL_LAYERS setting:
362
362
363
363
```python
364
364
# settings.py
@@ -384,17 +384,18 @@ CHANNEL_LAYERS = {
384
384
...
385
385
```
386
386
387
-
#### 3- Examples of Subscriptions:
387
+
#### 3- Subscription's examples:
388
388
389
-
In your client you must define websocket connection to: *'ws://host:port/custom_websocket_path'*.
390
-
When the connection is established, the server return a websocket message like this:
389
+
In your WEB client you must define websocket connection to: *'ws://host:port/custom_websocket_path'*.
390
+
When the connection is established, the server return a websocket's message like this:
391
391
*{"channel_id": "GthKdsYVrK!WxRCdJQMPi", "connect": "success"}*, where you must store the **channel_id** value to later use in your graphql subscriptions request for subscribe or unsubscribe operations.
392
-
The Subscription accept five possible parameters:
392
+
393
+
The graphql's subscription request accept five possible parameters:
393
394
1.**operation**: Operation to perform: subscribe or unsubscribe. (*required*)
394
-
2.**action**: Action you wish to subscribe: create, update, delete or all_actions. (*required*)
4.**id**: ID field value of model object that you wish to subscribe to. (*optional*)
397
-
5.**data**: List of desired model fields that you want in subscription's notification. (*optional*)
395
+
2.**action**: Action to which you wish to subscribe: create, update, delete or all_actions. (*required*)
396
+
3.**channelId**: Identification of the connection by websocket. (*required*)
397
+
4.**id**: Object's ID field value that you wish to subscribe to. (*optional*)
398
+
5.**data**: Model's fields that you want to appear in the subscription notifications. (*optional*)
398
399
399
400
```js
400
401
subscription{
@@ -412,7 +413,9 @@ subscription{
412
413
}
413
414
```
414
415
415
-
In this case, the subscription request sanded return a websocket message to client like this: *{"action": "update", "operation": "subscribe", "ok": true, "stream": "users", "error": null}* and each time than the user with id=5 get modified, you will receive a message through websocket's connection with the following format:
416
+
In this case, the subscription request sent return a websocket message to client like this:
and from that moment each time than the user with id=5 get modified, you will receive a message through websocket's connection with the following format:
416
419
417
420
```js
418
421
{
@@ -432,7 +435,7 @@ In this case, the subscription request sanded return a websocket message to clie
432
435
}
433
436
```
434
437
435
-
For unsubscribe you must send a graphql subscription request like this:
438
+
For unsubscribe you must send a graphql request like this:
436
439
437
440
```js
438
441
subscription{
@@ -449,14 +452,17 @@ subscription{
449
452
}
450
453
```
451
454
452
-
**NOTE:** Each time than the Graphql server restart, you must to reestablish the websocket's connection and resend the subscription graphqlrequest with a new websocket connection id.
455
+
**NOTE:** Each time than the graphql's server restart, you must to reestablish the websocket connection and resend the graphql's subscription request with the new websocket connection id.
453
456
454
457
455
458
## Change Log:
456
459
457
460
#### v0.1.0-alpha12:
458
-
1. Added MAX_PAGE_SIZE configuration field to global dict GRAPHENE_DJANGO_EXTRAS
459
-
configuration for better customize paginations.
461
+
1. Added new settings param: MAX_PAGE_SIZE, to use on GRAPHENE_DJANGO_EXTRAS
462
+
configuration dict for better customize DjangoListObjectType's pagination.
463
+
2. Added support to Django's field: GenericRel.
464
+
3. Improve model's fields calculation for to add all possible related and reverse fields.
465
+
4. Improved documentation translation.
460
466
461
467
#### v0.1.0-alpha11:
462
468
1. Improved ordering for showed fields on graphqli's IDE.
@@ -482,7 +488,8 @@ subscription{
482
488
1. Add queryset options to DjangoListObjectType Meta class for specify wanted model queryset.
483
489
2. Add AuthenticatedGraphQLView on graphene_django_extras.views for use
484
490
'permission', 'authorization' and 'throttle' classes based on the DRF settings. Special thanks to
485
-
[@jacobh](https://github.com/jacobh) for this [comment](https://github.com/graphql-python/graphene/issues/249#issuecomment-300068390)
0 commit comments