Skip to content

Commit fc9660f

Browse files
committed
graphql unit test
1 parent ca476c6 commit fc9660f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_integrations/test_graphql.py

+25
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,28 @@ def handler_factory():
5151
assert len(responses) == 10
5252
assert responses[0] == {'greetings': {'message': 'Hello world 0'}}
5353
assert responses[9] == {'greetings': {'message': 'Hello world 9'}}
54+
55+
56+
async def test_graphql_get_schema(lazy_pipe, graphql_schema):
57+
expected_schema = {'__schema': {
58+
'types': [{'name': 'Query'}, {'name': 'String'}, {'name': 'Subscription'}, {'name': 'Greeting'},
59+
{'name': 'Mutation'}, {'name': 'Boolean'}, {'name': '__Schema'}, {'name': '__Type'},
60+
{'name': '__TypeKind'}, {'name': '__Field'}, {'name': '__InputValue'}, {'name': '__EnumValue'},
61+
{'name': '__Directive'}, {'name': '__DirectiveLocation'}]}}
62+
63+
def handler_factory():
64+
return RoutingRequestHandler(graphql_handler(graphql_schema, 'graphql'))
65+
66+
async with lazy_pipe(
67+
client_arguments={'metadata_encoding': WellKnownMimeTypes.MESSAGE_RSOCKET_COMPOSITE_METADATA},
68+
server_arguments={'handler_factory': handler_factory}) as (server, client):
69+
graphql = Client(
70+
schema=graphql_schema,
71+
transport=RSocketTransport(client),
72+
)
73+
74+
response = await graphql.execute_async(
75+
gql("""{__schema { types { name } } }"""),
76+
get_execution_result=True)
77+
78+
assert response.data == expected_schema

0 commit comments

Comments
 (0)