Skip to content

Commit

Permalink
Parallel request execution inproduced.
Browse files Browse the repository at this point in the history
- Parallel execution initially introduced.
- Tests added. Tests are split into different files.

Cosmetics:
- Plugin `pylint-django` disabled until new release is here (current
  version is 0.11.1) because of the bug:
  pylint-dev/pylint-django#173.
- Dependencies updated.
- README.md updated.
  • Loading branch information
prokher committed Jul 22, 2018
1 parent a70b639 commit aaa5232
Show file tree
Hide file tree
Showing 10 changed files with 1,259 additions and 976 deletions.
26 changes: 21 additions & 5 deletions README.md
Expand Up @@ -3,9 +3,9 @@
## Features

- WebSocket-based GraphQL server implemented on the Django Channels.
- Graphene-like subscriptions support.
- Operation order is guaranteed due to WebSocket usage.
- Subscription groups support based on the Django Channels groups.
- Graphene-like subscriptions.
- Subscription groups based on the Django Channels groups.
- Parallel execution of requests.

## Quick start

Expand Down Expand Up @@ -67,7 +67,7 @@ class Subscription(graphene.ObjectType):
"""Root GraphQL subscription."""
my_subscription = MySubscription.Field()

my_schema = graphene.Schema(
graphql_schema = graphene.Schema(
query=Query,
mutation=Mutation,
subscription=Subscription,
Expand All @@ -79,7 +79,7 @@ Make your own WebSocket consumer subclass and set the schema it serves:
```python
class MyGraphqlWsConsumer(channels_graphql_ws.GraphqlWsConsumer):
"""Channels WebSocket consumer which provides GraphQL API."""
schema = my_schema
schema = graphql_schema
```

Setup Django Channels routing:
Expand Down Expand Up @@ -122,6 +122,22 @@ which is used by the [Apollo GraphQL](https://github.com/apollographql).
Check the [protocol description](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md)
for details.

### Execution

- Different requests from different WebSocket client are processed
asynchronously.
- By default different requests (WebSocket messages) from a single
client are processed concurrently in different worker threads. So
there is no guarantee that requests will be processed in the same
the client sent these requests. Actually, with HTTP we have this
behavior for years.
- It is possible to serialize message processing by setting
`strict_ordering` to `True`. But note, this disables parallel requests
execution - in other words, the server will not start processing
another request from the client before it finishes the current one.
See comments in the class `GraphqlWsConsumer`.


## Alternatives

There is a [Tomáš Ehrlich](https://gist.github.com/tricoder42)
Expand Down

0 comments on commit aaa5232

Please sign in to comment.