Skip to content

Commit 7ec7f0f

Browse files
committed
Simplify test "includes input types only used in directives"
Replicates graphql/graphql-js@f21acae
1 parent e9a4f46 commit 7ec7f0f

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

tests/type/test_schema.py

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from graphql.language import DirectiveLocation
44
from graphql.type import (
55
GraphQLField,
6-
GraphQLInterfaceType,
76
GraphQLObjectType,
87
GraphQLScalarType,
98
GraphQLSchema,
@@ -15,40 +14,31 @@
1514
GraphQLList,
1615
)
1716

18-
InterfaceType = GraphQLInterfaceType(
19-
"Interface", {"fieldName": GraphQLField(GraphQLString)}
20-
)
21-
22-
DirectiveInputType = GraphQLInputObjectType(
23-
"DirInput", {"field": GraphQLInputField(GraphQLString)}
24-
)
25-
26-
WrappedDirectiveInputType = GraphQLInputObjectType(
27-
"WrappedDirInput", {"field": GraphQLInputField(GraphQLString)}
28-
)
29-
30-
Directive = GraphQLDirective(
31-
name="dir",
32-
locations=[DirectiveLocation.OBJECT],
33-
args={
34-
"arg": GraphQLArgument(DirectiveInputType),
35-
"argList": GraphQLArgument(GraphQLList(WrappedDirectiveInputType)),
36-
},
37-
)
38-
39-
Schema = GraphQLSchema(
40-
query=GraphQLObjectType(
41-
"Query", {"getObject": GraphQLField(InterfaceType, resolve=lambda: {})}
42-
),
43-
directives=[Directive],
44-
)
45-
4617

4718
def describe_type_system_schema():
4819
def describe_type_map():
4920
def includes_input_types_only_used_in_directives():
50-
assert "DirInput" in Schema.type_map
51-
assert "WrappedDirInput" in Schema.type_map
21+
directive = GraphQLDirective(
22+
name="dir",
23+
locations=[DirectiveLocation.OBJECT],
24+
args={
25+
"arg": GraphQLArgument(
26+
GraphQLInputObjectType(
27+
"Foo", {"field": GraphQLInputField(GraphQLString)}
28+
)
29+
),
30+
"argList": GraphQLArgument(
31+
GraphQLList(
32+
GraphQLInputObjectType(
33+
"Bar", {"field": GraphQLInputField(GraphQLString)}
34+
)
35+
)
36+
),
37+
},
38+
)
39+
schema = GraphQLSchema(directives=[directive])
40+
assert "Foo" in schema.type_map
41+
assert "Bar" in schema.type_map
5242

5343
def describe_validity():
5444
def describe_when_not_assumed_valid():

0 commit comments

Comments
 (0)