Skip to content

Commit 841d2e8

Browse files
committed
Fix test for GraphQL mutation type introspection
The order of elements in "data.__type.fields" is non-deterministic
1 parent 2e13147 commit 841d2e8

File tree

1 file changed

+347
-8
lines changed

1 file changed

+347
-8
lines changed

features/graphql/mutation.feature

Lines changed: 347 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,353 @@ Feature: GraphQL mutation support
3131
Then the response status code should be 200
3232
And the response should be in JSON
3333
And the header "Content-Type" should be equal to "application/json"
34-
And the JSON node "data.__type.fields[2].name" should contain "delete"
35-
And the JSON node "data.__type.fields[2].description" should match '/^Deletes a [A-z0-9]+.$/'
36-
And the JSON node "data.__type.fields[2].type.name" should match "/^delete[A-z0-9]+Payload$/"
37-
And the JSON node "data.__type.fields[2].type.kind" should be equal to "OBJECT"
38-
And the JSON node "data.__type.fields[2].args[0].name" should be equal to "input"
39-
And the JSON node "data.__type.fields[2].args[0].type.kind" should be equal to "NON_NULL"
40-
And the JSON node "data.__type.fields[2].args[0].type.ofType.name" should match "/^delete[A-z0-9]+Input$/"
41-
And the JSON node "data.__type.fields[2].args[0].type.ofType.kind" should be equal to "INPUT_OBJECT"
34+
And the JSON should be valid according to this schema:
35+
"""
36+
{
37+
"type": "object",
38+
"required": [
39+
"data"
40+
],
41+
"properties": {
42+
"data": {
43+
"type": "object",
44+
"required": [
45+
"__type"
46+
],
47+
"properties": {
48+
"__type": {
49+
"type": "object",
50+
"required": [
51+
"fields"
52+
],
53+
"properties": {
54+
"fields": {
55+
"type": "array",
56+
"minItems": 1,
57+
"items": {
58+
"oneOf": [
59+
{
60+
"type": "object",
61+
"required": [
62+
"name",
63+
"description",
64+
"type",
65+
"args"
66+
],
67+
"properties": {
68+
"name": {
69+
"pattern": "^create[A-z0-9]+$"
70+
},
71+
"description": {
72+
"pattern": "^Creates a [A-z0-9]+.$"
73+
},
74+
"type": {
75+
"type": "object",
76+
"required": [
77+
"name",
78+
"kind"
79+
],
80+
"properties": {
81+
"name": {
82+
"pattern": "^create[A-z0-9]+Payload$"
83+
},
84+
"kind": {
85+
"enum": ["OBJECT"]
86+
}
87+
}
88+
},
89+
"args": {
90+
"type": "array",
91+
"minItems": 1,
92+
"maxItems": 1,
93+
"items": [
94+
{
95+
"type": "object",
96+
"required": [
97+
"name",
98+
"type"
99+
],
100+
"properties": {
101+
"name": {
102+
"enum": ["input"]
103+
},
104+
"type": {
105+
"type": "object",
106+
"required": [
107+
"kind",
108+
"ofType"
109+
],
110+
"properties": {
111+
"kind": {
112+
"enum": ["NON_NULL"]
113+
},
114+
"ofType": {
115+
"type": "object",
116+
"required": [
117+
"name",
118+
"kind"
119+
],
120+
"properties": {
121+
"name": {
122+
"pattern": "^create[A-z0-9]+Input$"
123+
},
124+
"kind": {
125+
"enum": ["INPUT_OBJECT"]
126+
}
127+
}
128+
}
129+
}
130+
}
131+
}
132+
}
133+
]
134+
}
135+
}
136+
},
137+
{
138+
"type": "object",
139+
"required": [
140+
"name",
141+
"description",
142+
"type",
143+
"args"
144+
],
145+
"properties": {
146+
"name": {
147+
"pattern": "^update[A-z0-9]+$"
148+
},
149+
"description": {
150+
"pattern": "^Updates a [A-z0-9]+.$"
151+
},
152+
"type": {
153+
"type": "object",
154+
"required": [
155+
"name",
156+
"kind"
157+
],
158+
"properties": {
159+
"name": {
160+
"pattern": "^update[A-z0-9]+Payload$"
161+
},
162+
"kind": {
163+
"enum": ["OBJECT"]
164+
}
165+
}
166+
},
167+
"args": {
168+
"type": "array",
169+
"minItems": 1,
170+
"maxItems": 1,
171+
"items": [
172+
{
173+
"type": "object",
174+
"required": [
175+
"name",
176+
"type"
177+
],
178+
"properties": {
179+
"name": {
180+
"enum": ["input"]
181+
},
182+
"type": {
183+
"type": "object",
184+
"required": [
185+
"kind",
186+
"ofType"
187+
],
188+
"properties": {
189+
"kind": {
190+
"enum": ["NON_NULL"]
191+
},
192+
"ofType": {
193+
"type": "object",
194+
"required": [
195+
"name",
196+
"kind"
197+
],
198+
"properties": {
199+
"name": {
200+
"pattern": "^update[A-z0-9]+Input$"
201+
},
202+
"kind": {
203+
"enum": ["INPUT_OBJECT"]
204+
}
205+
}
206+
}
207+
}
208+
}
209+
}
210+
}
211+
]
212+
}
213+
}
214+
},
215+
{
216+
"type": "object",
217+
"required": [
218+
"name",
219+
"description",
220+
"type",
221+
"args"
222+
],
223+
"properties": {
224+
"name": {
225+
"pattern": "^delete[A-z0-9]+$"
226+
},
227+
"description": {
228+
"pattern": "^Deletes a [A-z0-9]+.$"
229+
},
230+
"type": {
231+
"type": "object",
232+
"required": [
233+
"name",
234+
"kind"
235+
],
236+
"properties": {
237+
"name": {
238+
"pattern": "^delete[A-z0-9]+Payload$"
239+
},
240+
"kind": {
241+
"enum": ["OBJECT"]
242+
}
243+
}
244+
},
245+
"args": {
246+
"type": "array",
247+
"minItems": 1,
248+
"maxItems": 1,
249+
"items": [
250+
{
251+
"type": "object",
252+
"required": [
253+
"name",
254+
"type"
255+
],
256+
"properties": {
257+
"name": {
258+
"enum": ["input"]
259+
},
260+
"type": {
261+
"type": "object",
262+
"required": [
263+
"kind",
264+
"ofType"
265+
],
266+
"properties": {
267+
"kind": {
268+
"enum": ["NON_NULL"]
269+
},
270+
"ofType": {
271+
"type": "object",
272+
"required": [
273+
"name",
274+
"kind"
275+
],
276+
"properties": {
277+
"name": {
278+
"pattern": "^delete[A-z0-9]+Input$"
279+
},
280+
"kind": {
281+
"enum": ["INPUT_OBJECT"]
282+
}
283+
}
284+
}
285+
}
286+
}
287+
}
288+
}
289+
]
290+
}
291+
}
292+
},
293+
{
294+
"type": "object",
295+
"required": [
296+
"name",
297+
"description",
298+
"type",
299+
"args"
300+
],
301+
"properties": {
302+
"name": {
303+
"pattern": "^(?!create|update|delete)[A-z0-9]+$"
304+
},
305+
"description": {
306+
"pattern": "^(?!Create|Update|Delete)[A-z0-9]+s a [A-z0-9]+.$"
307+
},
308+
"type": {
309+
"type": "object",
310+
"required": [
311+
"name",
312+
"kind"
313+
],
314+
"properties": {
315+
"name": {
316+
"pattern": "^(?!create|update|delete)[A-z0-9]+Payload$"
317+
},
318+
"kind": {
319+
"enum": ["OBJECT"]
320+
}
321+
}
322+
},
323+
"args": {
324+
"type": "array",
325+
"minItems": 1,
326+
"maxItems": 1,
327+
"items": [
328+
{
329+
"type": "object",
330+
"required": [
331+
"name",
332+
"type"
333+
],
334+
"properties": {
335+
"name": {
336+
"enum": ["input"]
337+
},
338+
"type": {
339+
"type": "object",
340+
"required": [
341+
"kind",
342+
"ofType"
343+
],
344+
"properties": {
345+
"kind": {
346+
"enum": ["NON_NULL"]
347+
},
348+
"ofType": {
349+
"type": "object",
350+
"required": [
351+
"name",
352+
"kind"
353+
],
354+
"properties": {
355+
"name": {
356+
"pattern": "^(?!create|update|delete)[A-z0-9]+Input$"
357+
},
358+
"kind": {
359+
"enum": ["INPUT_OBJECT"]
360+
}
361+
}
362+
}
363+
}
364+
}
365+
}
366+
}
367+
]
368+
}
369+
}
370+
}
371+
]
372+
}
373+
}
374+
}
375+
}
376+
}
377+
}
378+
}
379+
}
380+
"""
42381

43382
Scenario: Create an item
44383
When I send the following GraphQL request:

0 commit comments

Comments
 (0)