mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Fix subscribe with arguments (#1251)
This commit is contained in:
parent
86b904d327
commit
188ce9a6cb
|
@ -80,7 +80,7 @@ def is_type_of_from_possible_types(possible_types, root, _info):
|
|||
|
||||
|
||||
# We use this resolver for subscriptions
|
||||
def identity_resolve(root, info):
|
||||
def identity_resolve(root, info, **arguments):
|
||||
return root
|
||||
|
||||
|
||||
|
|
|
@ -54,3 +54,27 @@ async def test_subscription_fails_when_query_is_not_valid():
|
|||
assert "Anonymous Subscription must select only one top level field." in str(
|
||||
result.errors[0]
|
||||
)
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_subscription_with_args():
|
||||
class Query(ObjectType):
|
||||
hello = String()
|
||||
|
||||
class Subscription(ObjectType):
|
||||
count_upwards = Field(Int, limit=Int(required=True))
|
||||
|
||||
async def subscribe_count_upwards(root, info, limit):
|
||||
count = 0
|
||||
while count < limit:
|
||||
count += 1
|
||||
yield count
|
||||
|
||||
schema = Schema(query=Query, subscription=Subscription)
|
||||
|
||||
subscription = "subscription { countUpwards(limit: 5) }"
|
||||
result = await schema.subscribe(subscription)
|
||||
count = 0
|
||||
async for item in result:
|
||||
count = item.data["countUpwards"]
|
||||
assert count == 5
|
||||
|
|
Loading…
Reference in New Issue
Block a user