Skip to content

Commit f76de17

Browse files
committed
NonNull tests: Use SDL to create test schema
Replicates graphql/graphql-js@c32d2d8
1 parent e670ed4 commit f76de17

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tests/execution/test_nonnull.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
GraphQLSchema,
1313
GraphQLString,
1414
)
15+
from graphql.utilities import build_schema
1516

1617
sync_error = RuntimeError("sync")
1718
sync_non_null_error = RuntimeError("syncNonNull")
@@ -73,22 +74,25 @@ async def promiseNonNullNest(self, _info):
7374
return NullingData()
7475

7576

76-
DataType = GraphQLObjectType(
77-
"DataType",
78-
lambda: {
79-
"sync": GraphQLField(GraphQLString),
80-
"syncNonNull": GraphQLField(GraphQLNonNull(GraphQLString)),
81-
"promise": GraphQLField(GraphQLString),
82-
"promiseNonNull": GraphQLField(GraphQLNonNull(GraphQLString)),
83-
"syncNest": GraphQLField(DataType),
84-
"syncNonNullNest": GraphQLField(GraphQLNonNull(DataType)),
85-
"promiseNest": GraphQLField(DataType),
86-
"promiseNonNullNest": GraphQLField(GraphQLNonNull(DataType)),
87-
},
77+
schema = build_schema(
78+
"""
79+
type DataType {
80+
sync: String
81+
syncNonNull: String!
82+
promise: String
83+
promiseNonNull: String!
84+
syncNest: DataType
85+
syncNonNullNest: DataType!
86+
promiseNest: DataType
87+
promiseNonNullNest: DataType!
88+
}
89+
90+
schema {
91+
query: DataType
92+
}
93+
"""
8894
)
8995

90-
schema = GraphQLSchema(DataType)
91-
9296

9397
def execute_query(query, root_value):
9498
return execute(schema, parse(query), root_value)

0 commit comments

Comments
 (0)