Skip to content

Commit 4073718

Browse files
authored
Tweak nested input in directive argument tests (#996)
This commit: * moves the test with directive definition using a nested argument to file tests * adds a test (to file tests) that confirms a directive can be named the same as an input object type it uses * fixes message in expect_err() in builtin_type_redefinitions
1 parent febe8d3 commit 4073718

7 files changed

+466
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
directive @custom(input: NestedInput) on OBJECT | INTERFACE
2+
3+
input NestedInput {
4+
name: String
5+
nested: NestedInput
6+
}
7+
8+
type Query @custom(input: {name: "hello", nested: {name: "hello"}}) {
9+
foo: String
10+
}
11+
12+
query myQuery {
13+
foo
14+
}
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
Schema {
2+
sources: {
3+
1: SourceFile {
4+
path: "built_in.graphql",
5+
source_text: include_str!("built_in.graphql"),
6+
},
7+
47: SourceFile {
8+
path: "0118_directive_with_nested_input_types.graphql",
9+
source_text: "directive @custom(input: NestedInput) on OBJECT | INTERFACE\n\ninput NestedInput {\n name: String\n nested: NestedInput\n}\n\ntype Query @custom(input: {name: \"hello\", nested: {name: \"hello\"}}) {\n foo: String\n}\n\nquery myQuery {\n foo\n}",
10+
},
11+
},
12+
schema_definition: SchemaDefinition {
13+
description: None,
14+
directives: [],
15+
query: Some(
16+
ComponentName {
17+
origin: Definition,
18+
name: "Query",
19+
},
20+
),
21+
mutation: None,
22+
subscription: None,
23+
},
24+
directive_definitions: {
25+
"skip": built_in_directive!("skip"),
26+
"include": built_in_directive!("include"),
27+
"deprecated": built_in_directive!("deprecated"),
28+
"specifiedBy": built_in_directive!("specifiedBy"),
29+
"custom": 0..59 @47 DirectiveDefinition {
30+
description: None,
31+
name: "custom",
32+
arguments: [
33+
18..36 @47 InputValueDefinition {
34+
description: None,
35+
name: "input",
36+
ty: 25..36 @47 Named(
37+
"NestedInput",
38+
),
39+
default_value: None,
40+
directives: [],
41+
},
42+
],
43+
repeatable: false,
44+
locations: [
45+
"OBJECT",
46+
"INTERFACE",
47+
],
48+
},
49+
},
50+
types: {
51+
"__Schema": built_in_type!("__Schema"),
52+
"__Type": built_in_type!("__Type"),
53+
"__TypeKind": built_in_type!("__TypeKind"),
54+
"__Field": built_in_type!("__Field"),
55+
"__InputValue": built_in_type!("__InputValue"),
56+
"__EnumValue": built_in_type!("__EnumValue"),
57+
"__Directive": built_in_type!("__Directive"),
58+
"__DirectiveLocation": built_in_type!("__DirectiveLocation"),
59+
"String": built_in_type!("String"),
60+
"Boolean": built_in_type!("Boolean"),
61+
"NestedInput": InputObject(
62+
61..119 @47 InputObjectType {
63+
description: None,
64+
name: "NestedInput",
65+
directives: [],
66+
fields: {
67+
"name": Component {
68+
origin: Definition,
69+
node: 83..95 @47 InputValueDefinition {
70+
description: None,
71+
name: "name",
72+
ty: 89..95 @47 Named(
73+
"String",
74+
),
75+
default_value: None,
76+
directives: [],
77+
},
78+
},
79+
"nested": Component {
80+
origin: Definition,
81+
node: 98..117 @47 InputValueDefinition {
82+
description: None,
83+
name: "nested",
84+
ty: 106..117 @47 Named(
85+
"NestedInput",
86+
),
87+
default_value: None,
88+
directives: [],
89+
},
90+
},
91+
},
92+
},
93+
),
94+
"Query": Object(
95+
121..206 @47 ObjectType {
96+
description: None,
97+
name: "Query",
98+
implements_interfaces: {},
99+
directives: [
100+
Component {
101+
origin: Definition,
102+
node: 132..188 @47 Directive {
103+
name: "custom",
104+
arguments: [
105+
140..187 @47 Argument {
106+
name: "input",
107+
value: 147..187 @47 Object(
108+
[
109+
(
110+
"name",
111+
154..161 @47 String(
112+
"hello",
113+
),
114+
),
115+
(
116+
"nested",
117+
171..186 @47 Object(
118+
[
119+
(
120+
"name",
121+
178..185 @47 String(
122+
"hello",
123+
),
124+
),
125+
],
126+
),
127+
),
128+
],
129+
),
130+
},
131+
],
132+
},
133+
},
134+
],
135+
fields: {
136+
"foo": Component {
137+
origin: Definition,
138+
node: 193..204 @47 FieldDefinition {
139+
description: None,
140+
name: "foo",
141+
arguments: [],
142+
ty: Named(
143+
"String",
144+
),
145+
directives: [],
146+
},
147+
},
148+
},
149+
},
150+
),
151+
},
152+
}
153+
ExecutableDocument {
154+
sources: {
155+
1: SourceFile {
156+
path: "built_in.graphql",
157+
source_text: include_str!("built_in.graphql"),
158+
},
159+
47: SourceFile {
160+
path: "0118_directive_with_nested_input_types.graphql",
161+
source_text: "directive @custom(input: NestedInput) on OBJECT | INTERFACE\n\ninput NestedInput {\n name: String\n nested: NestedInput\n}\n\ntype Query @custom(input: {name: \"hello\", nested: {name: \"hello\"}}) {\n foo: String\n}\n\nquery myQuery {\n foo\n}",
162+
},
163+
},
164+
operations: OperationMap {
165+
anonymous: None,
166+
named: {
167+
"myQuery": 208..231 @47 Operation {
168+
operation_type: Query,
169+
name: Some(
170+
"myQuery",
171+
),
172+
variables: [],
173+
directives: [],
174+
selection_set: SelectionSet {
175+
ty: "Query",
176+
selections: [
177+
Field(
178+
226..229 @47 Field {
179+
definition: 193..204 @47 FieldDefinition {
180+
description: None,
181+
name: "foo",
182+
arguments: [],
183+
ty: Named(
184+
"String",
185+
),
186+
directives: [],
187+
},
188+
alias: None,
189+
name: "foo",
190+
arguments: [],
191+
directives: [],
192+
selection_set: SelectionSet {
193+
ty: "String",
194+
selections: [],
195+
},
196+
},
197+
),
198+
],
199+
},
200+
},
201+
},
202+
},
203+
fragments: {},
204+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
directive @custom(input: Custom) on OBJECT | INTERFACE
2+
3+
input Custom {
4+
name: String
5+
nested: Custom
6+
}
7+
8+
type Query @custom(input: {name: "hello", nested: {name: "hello"}}) {
9+
foo: String
10+
}
11+
12+
query myQuery {
13+
foo
14+
}

0 commit comments

Comments
 (0)