Skip to content

Commit

Permalink
review fiexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrbnlulu committed Jul 7, 2024
1 parent 70866d7 commit bd6c36f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tests/execution/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@

import pytest
from graphql.execution import Middleware, MiddlewareManager, execute, subscribe
from graphql.execution import Middleware, MiddlewareManager, execute
from graphql.language.parser import parse
from graphql.type import GraphQLField, GraphQLObjectType, GraphQLSchema, GraphQLString


def _create_subscription_schema(tp: GraphQLObjectType) -> GraphQLSchema:
noop_type = GraphQLObjectType(
"Noop", {"noop": GraphQLField(GraphQLString, resolve=lambda *_: "noop")}
)
return GraphQLSchema(query=noop_type, subscription=tp)


def describe_middleware():
def describe_with_manager():
def default():
Expand Down Expand Up @@ -247,7 +239,6 @@ async def resolve(self, next_, *args, **kwargs):

@pytest.mark.asyncio()
async def subscription_simple():

async def bar_resolve(_obj, _info):
yield "bar"
yield "oof"
Expand All @@ -268,8 +259,14 @@ async def reverse_middleware(next_, value, info, **kwargs):
awaitable_maybe = next_(value, info, **kwargs)
return awaitable_maybe[::-1]

noop_type = GraphQLObjectType(
"Noop",
{"noop": GraphQLField(GraphQLString, resolve=lambda *_args: "noop")},
)
schema = GraphQLSchema(query=noop_type, subscription=test_type)

agen = subscribe(
_create_subscription_schema(test_type),
schema,
doc,
middleware=MiddlewareManager(reverse_middleware),
)
Expand Down

0 comments on commit bd6c36f

Please sign in to comment.