Skip to content

Commit f4e9f07

Browse files
committed
Add regression test for #16
1 parent 6a9814d commit f4e9f07

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

1515
The current version 1.0.1 of GraphQL-core-next is up-to-date with GraphQL.js version
16-
14.0.2. All parts of the API are covered by an extensive test suite of currently 1656
16+
14.0.2. All parts of the API are covered by an extensive test suite of currently 1657
1717
unit tests.
1818

1919

tests/execution/test_middleware.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,39 @@ def reverse_middleware(next_, *args, **kwargs):
5555

5656
assert result.data == {"first": "eno", "second": "owt"}
5757

58+
def two_functions_and_field_resolvers():
59+
doc = parse("{ first second }")
60+
61+
# noinspection PyMethodMayBeStatic
62+
class Data:
63+
first = "one"
64+
second = "two"
65+
66+
test_type = GraphQLObjectType(
67+
"TestType",
68+
{
69+
"first": GraphQLField(
70+
GraphQLString, resolve=lambda obj, _info: obj.first
71+
),
72+
"second": GraphQLField(
73+
GraphQLString, resolve=lambda obj, _info: obj.second
74+
),
75+
},
76+
)
77+
78+
def reverse_middleware(next_, *args, **kwargs):
79+
return next_(*args, **kwargs)[::-1]
80+
81+
def capitalize_middleware(next_, *args, **kwargs):
82+
return next_(*args, **kwargs).capitalize()
83+
84+
middlewares = MiddlewareManager(reverse_middleware, capitalize_middleware)
85+
result = execute(
86+
GraphQLSchema(test_type), doc, Data(), middleware=middlewares
87+
)
88+
89+
assert result.data == {"first": "Eno", "second": "Owt"}
90+
5891
@mark.asyncio
5992
async def single_async_function():
6093
doc = parse("{ first second }")

0 commit comments

Comments
 (0)