Fix subscribe with arguments (#1251)

This commit is contained in:
Jonathan Kim 2020-08-12 22:43:35 +01:00 committed by GitHub
parent 86b904d327
commit 188ce9a6cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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