mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-28 09:40:34 +03:00
30 lines
603 B
Python
30 lines
603 B
Python
import graphene
|
|
|
|
|
|
class Query(graphene.ObjectType):
|
|
base = graphene.String()
|
|
|
|
|
|
class Subscription(graphene.ObjectType):
|
|
subscribe_to_foo = graphene.Boolean(id=graphene.Int())
|
|
|
|
def resolve_subscribe_to_foo(self, args, info):
|
|
return args.get('id') == 1
|
|
|
|
|
|
schema = graphene.Schema(query=Query, subscription=Subscription)
|
|
|
|
|
|
def test_execute_subscription():
|
|
query = '''
|
|
subscription {
|
|
subscribeToFoo(id: 1)
|
|
}
|
|
'''
|
|
expected = {
|
|
'subscribeToFoo': True
|
|
}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|