3
3
4
4
import pytest
5
5
from graphql .execution import Middleware , MiddlewareManager , execute , subscribe
6
- from graphql .execution import Middleware , MiddlewareManager , execute
7
6
from graphql .language .parser import parse
8
7
from graphql .type import GraphQLField , GraphQLObjectType , GraphQLSchema , GraphQLString
9
8
10
9
11
- def _create_subscription_schema (tp : GraphQLObjectType ) -> GraphQLSchema :
12
- noop_type = GraphQLObjectType (
13
- "Noop" , {"noop" : GraphQLField (GraphQLString , resolve = lambda * _ : "noop" )}
14
- )
15
- return GraphQLSchema (query = noop_type , subscription = tp )
16
-
17
-
18
10
def describe_middleware ():
19
11
def describe_with_manager ():
20
12
def default ():
@@ -247,7 +239,6 @@ async def resolve(self, next_, *args, **kwargs):
247
239
248
240
@pytest .mark .asyncio ()
249
241
async def subscription_simple ():
250
-
251
242
async def bar_resolve (_obj , _info ):
252
243
yield "bar"
253
244
yield "oof"
@@ -268,8 +259,14 @@ async def reverse_middleware(next_, value, info, **kwargs):
268
259
awaitable_maybe = next_ (value , info , ** kwargs )
269
260
return awaitable_maybe [::- 1 ]
270
261
262
+ noop_type = GraphQLObjectType (
263
+ "Noop" ,
264
+ {"noop" : GraphQLField (GraphQLString , resolve = lambda * _args : "noop" )},
265
+ )
266
+ schema = GraphQLSchema (query = noop_type , subscription = test_type )
267
+
271
268
agen = subscribe (
272
- _create_subscription_schema ( test_type ) ,
269
+ schema ,
273
270
doc ,
274
271
middleware = MiddlewareManager (reverse_middleware ),
275
272
)
0 commit comments