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