Skip to content

Commit 188ce9a

Browse files
authored
Fix subscribe with arguments (#1251)
1 parent 86b904d commit 188ce9a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

graphene/types/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def is_type_of_from_possible_types(possible_types, root, _info):
8080

8181

8282
# We use this resolver for subscriptions
83-
def identity_resolve(root, info):
83+
def identity_resolve(root, info, **arguments):
8484
return root
8585

8686

graphene/types/tests/test_subscribe_async.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,27 @@ async def test_subscription_fails_when_query_is_not_valid():
5454
assert "Anonymous Subscription must select only one top level field." in str(
5555
result.errors[0]
5656
)
57+
58+
59+
@mark.asyncio
60+
async def test_subscription_with_args():
61+
class Query(ObjectType):
62+
hello = String()
63+
64+
class Subscription(ObjectType):
65+
count_upwards = Field(Int, limit=Int(required=True))
66+
67+
async def subscribe_count_upwards(root, info, limit):
68+
count = 0
69+
while count < limit:
70+
count += 1
71+
yield count
72+
73+
schema = Schema(query=Query, subscription=Subscription)
74+
75+
subscription = "subscription { countUpwards(limit: 5) }"
76+
result = await schema.subscribe(subscription)
77+
count = 0
78+
async for item in result:
79+
count = item.data["countUpwards"]
80+
assert count == 5

0 commit comments

Comments
 (0)