mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-28 20:43:57 +03:00
Updated v3 release notes (markdown)
parent
45b65d65a7
commit
ee785d29a7
|
@ -63,6 +63,36 @@ assert result.data["color"] == "RED"
|
|||
|
||||
Reference: https://github.com/graphql-python/graphene/pull/1153
|
||||
|
||||
### Subscription support
|
||||
|
||||
Graphene v3 add subscription support 🎉 Here is an example of it in action:
|
||||
|
||||
```python
|
||||
from graphene import ObjectType, Int, Schema
|
||||
|
||||
class Subscription(ObjectType):
|
||||
count_to_ten = Int()
|
||||
|
||||
async def subscribe_count_to_ten(root, info):
|
||||
count = 0
|
||||
while count < 10:
|
||||
count += 1
|
||||
yield count
|
||||
|
||||
class Query(ObjectType):
|
||||
a = String()
|
||||
|
||||
schema = Schema(query=Query, subscription=Subscription)
|
||||
|
||||
result = await schema.subscribe("subscription { countToTen }")
|
||||
count = 0
|
||||
async for item in result:
|
||||
count = item.data["countToTen"]
|
||||
assert count == 10
|
||||
```
|
||||
|
||||
**Note:** Using subscriptions with a server like Django or Flask still relies on the server supporting websockets.
|
||||
|
||||
### Fast ObjectType creation
|
||||
|
||||
In Graphene v3 optimises the ObjectType initialization resulting in a x3 speed up! It does this by leveraging the same strategy that dataclasses introduced (dynamic creation of optimal `__init__` functions based on eval).
|
||||
|
|
Loading…
Reference in New Issue
Block a user