graphql 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/language/parser.rb +215 -215
- data/lib/graphql/query.rb +5 -1
- data/lib/graphql/schema.rb +10 -2
- data/lib/graphql/schema/build_from_definition.rb +1 -10
- data/lib/graphql/static_validation/arguments_validator.rb +0 -2
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +1 -2
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +0 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +0 -1
- data/lib/graphql/static_validation/validation_context.rb +0 -6
- data/lib/graphql/version.rb +1 -1
- data/readme.md +0 -5
- data/spec/graphql/query_spec.rb +7 -0
- data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +16 -0
- data/spec/graphql/static_validation/rules/arguments_are_defined_spec.rb +16 -0
- data/spec/graphql/static_validation/rules/fields_are_defined_on_type_spec.rb +86 -1
- data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1aafd43a1c33e73554a5e5231efd24bfdf236de
|
4
|
+
data.tar.gz: f0d8e2e7225fce433a02976d7b61195afea4c573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd15c75d9467dd23867d281dae3f932f64351a1a18d0010c85ca8c74297e0368e33dc15d3f6265937a09fe4339aadfa387f87e466137d265583577d951bedbc
|
7
|
+
data.tar.gz: 39b48cbccf44d3c0c02226d7329dacef7045f5a8acea12cebe56f6ad2ce9fe6b4f0b318bd45699e7965884dbc935df015bb71abdcd65d964af211eca21718344
|
@@ -95,38 +95,38 @@ end
|
|
95
95
|
|
96
96
|
racc_action_table = [
|
97
97
|
10, 11, 12, 128, 100, 78, 138, 138, 77, 138,
|
98
|
-
81,
|
98
|
+
81, 32, 53, 37, 38, 39, 40, 41, 42, 43,
|
99
99
|
44, 45, 46, 47, 48, 49, 50, 10, 11, 12,
|
100
|
-
81, 81, 60, 81, 138, 138,
|
100
|
+
81, 81, 60, 81, 138, 138, 63, 214, 214, 74,
|
101
101
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
102
|
-
47, 48, 49, 50, 10, 11, 12,
|
103
|
-
10, 11, 12,
|
102
|
+
47, 48, 49, 50, 10, 11, 12, 70, 138, 60,
|
103
|
+
182, 10, 11, 12, 71, 73, 85, 83, 38, 39,
|
104
104
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
105
|
-
50, 10, 11, 12,
|
106
|
-
215,
|
105
|
+
50, 10, 11, 12, 81, 81, 177, 91, 81, 178,
|
106
|
+
215, 81, 179, 81, 152, 38, 39, 40, 41, 42,
|
107
107
|
43, 44, 45, 46, 150, 151, 169, 170, 166, 167,
|
108
|
-
168, 176, 10, 11, 12,
|
109
|
-
178,
|
108
|
+
168, 176, 10, 11, 12, 81, 81, 177, 100, 81,
|
109
|
+
178, 81, 81, 179, 13, 152, 38, 39, 40, 41,
|
110
110
|
42, 43, 44, 45, 46, 150, 151, 169, 170, 166,
|
111
|
-
167, 168, 176, 10, 11, 12,
|
112
|
-
|
111
|
+
167, 168, 176, 10, 11, 12, 117, 81, 177, 121,
|
112
|
+
122, 178, 201, 123, 179, 124, 152, 38, 39, 40,
|
113
113
|
41, 42, 43, 44, 45, 46, 150, 151, 169, 170,
|
114
|
-
166, 167, 168, 176, 10, 11, 12, 13,
|
115
|
-
|
114
|
+
166, 167, 168, 176, 10, 11, 12, 125, 13, 177,
|
115
|
+
13, 78, 178, 136, 78, 179, 143, 152, 38, 39,
|
116
116
|
40, 41, 42, 43, 44, 45, 46, 150, 151, 169,
|
117
|
-
170, 166, 167, 168, 176, 10, 11, 12,
|
118
|
-
177, 81,
|
117
|
+
170, 166, 167, 168, 176, 10, 11, 12, 162, 163,
|
118
|
+
177, 81, 13, 178, 13, 125, 179, 188, 152, 38,
|
119
119
|
39, 40, 41, 42, 43, 44, 45, 46, 150, 151,
|
120
|
-
169, 170, 166, 167, 168, 176, 10, 11, 12,
|
121
|
-
|
120
|
+
169, 170, 166, 167, 168, 176, 10, 11, 12, 81,
|
121
|
+
192, 13, 209, 212, 112, 219, nil, nil, nil, 37,
|
122
122
|
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
123
123
|
48, 49, 50, 10, 11, 12, nil, nil, nil, nil,
|
124
124
|
nil, nil, nil, nil, nil, nil, 37, 38, 39, 40,
|
125
125
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
126
126
|
10, 11, 12, nil, nil, nil, nil, nil, nil, nil,
|
127
|
-
nil, nil,
|
127
|
+
nil, nil, 187, 37, 38, 39, 40, 41, 42, 43,
|
128
128
|
44, 45, 46, 47, 48, 49, 50, 10, 11, 12,
|
129
|
-
nil, nil, nil, nil, nil,
|
129
|
+
nil, nil, nil, nil, nil, 112, nil, nil, nil, nil,
|
130
130
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
131
131
|
47, 48, 49, 50, 10, 11, 12, nil, nil, nil,
|
132
132
|
nil, nil, nil, nil, nil, nil, nil, 37, 38, 39,
|
@@ -140,20 +140,20 @@ racc_action_table = [
|
|
140
140
|
nil, nil, nil, nil, nil, nil, nil, nil, 37, 38,
|
141
141
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
142
142
|
49, 50, 10, 11, 12, nil, nil, nil, nil, nil,
|
143
|
-
nil, nil, nil, nil, nil,
|
143
|
+
nil, nil, nil, nil, nil, 37, 38, 39, 40, 41,
|
144
144
|
42, 43, 44, 45, 46, 47, 48, 49, 50, 10,
|
145
145
|
11, 12, nil, nil, nil, nil, nil, nil, nil, nil,
|
146
146
|
nil, nil, 37, 38, 39, 40, 41, 42, 43, 44,
|
147
147
|
45, 46, 47, 48, 49, 50, 10, 11, 12, nil,
|
148
|
-
|
148
|
+
103, nil, nil, nil, nil, nil, nil, nil, nil, 37,
|
149
149
|
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
150
150
|
48, 49, 50, 10, 11, 12, nil, nil, nil, nil,
|
151
|
-
nil,
|
151
|
+
nil, nil, nil, nil, nil, nil, 37, 38, 39, 40,
|
152
152
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
153
|
-
10, 11, 12, nil, nil, nil, nil, nil,
|
153
|
+
10, 11, 12, nil, nil, nil, nil, nil, nil, nil,
|
154
154
|
nil, nil, nil, 37, 38, 39, 40, 41, 42, 43,
|
155
155
|
44, 45, 46, 47, 48, 49, 50, 10, 11, 12,
|
156
|
-
nil, nil, nil, nil, nil,
|
156
|
+
nil, nil, nil, nil, nil, 112, nil, nil, nil, nil,
|
157
157
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
158
158
|
47, 48, 49, 50, 10, 11, 12, nil, nil, nil,
|
159
159
|
nil, nil, nil, nil, nil, nil, nil, 37, 38, 39,
|
@@ -161,7 +161,7 @@ racc_action_table = [
|
|
161
161
|
50, 10, 11, 12, nil, nil, nil, nil, nil, nil,
|
162
162
|
nil, nil, nil, nil, 37, 38, 39, 40, 41, 42,
|
163
163
|
43, 44, 45, 46, 47, 48, 49, 50, 10, 11,
|
164
|
-
12, nil, nil, nil, nil, nil,
|
164
|
+
12, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
165
165
|
nil, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
166
166
|
46, 47, 48, 49, 50, 10, 11, 12, nil, nil,
|
167
167
|
nil, nil, nil, nil, nil, nil, nil, nil, 37, 38,
|
@@ -172,229 +172,229 @@ racc_action_table = [
|
|
172
172
|
11, 12, nil, nil, nil, nil, nil, nil, nil, nil,
|
173
173
|
nil, nil, 37, 38, 39, 40, 41, 42, 43, 44,
|
174
174
|
45, 46, 47, 48, 49, 50, 10, 11, 12, nil,
|
175
|
-
nil, nil, nil, nil, nil, nil, nil, nil,
|
175
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 37,
|
176
176
|
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
177
|
-
48, 49, 50, 10, 11, 12, nil,
|
177
|
+
48, 49, 50, 10, 11, 12, nil, nil, nil, nil,
|
178
178
|
nil, nil, nil, nil, nil, nil, 37, 38, 39, 40,
|
179
179
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
180
|
-
10, 11, 12, nil,
|
180
|
+
10, 11, 12, nil, 134, nil, nil, nil, nil, nil,
|
181
181
|
nil, nil, nil, 37, 38, 39, 40, 41, 42, 43,
|
182
182
|
44, 45, 46, 47, 48, 49, 50, 10, 11, 12,
|
183
183
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
184
|
-
|
185
|
-
47, 48, 49, 50, 10, 11, 12, nil,
|
186
|
-
nil, nil,
|
184
|
+
nil, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
185
|
+
47, 48, 49, 50, 10, 11, 12, nil, nil, nil,
|
186
|
+
nil, nil, 112, nil, nil, nil, nil, 37, 38, 39,
|
187
187
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
188
|
-
50, 10, 11, 12, nil, nil, nil, nil, nil,
|
188
|
+
50, 10, 11, 12, nil, nil, nil, nil, nil, nil,
|
189
189
|
nil, nil, nil, nil, 37, 38, 39, 40, 41, 42,
|
190
190
|
43, 44, 45, 46, 47, 48, 49, 50, 10, 11,
|
191
191
|
12, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
192
|
-
|
193
|
-
46, 47, 48, 49, 50, 10, 11, 12, nil,
|
192
|
+
194, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
193
|
+
46, 47, 48, 49, 50, 10, 11, 12, nil, 195,
|
194
194
|
nil, nil, nil, nil, nil, nil, nil, nil, 37, 38,
|
195
195
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
196
196
|
49, 50, 10, 11, 12, nil, nil, nil, nil, nil,
|
197
|
-
|
197
|
+
nil, nil, nil, nil, nil, 37, 38, 39, 40, 41,
|
198
198
|
42, 43, 44, 45, 46, 47, 48, 49, 50, 10,
|
199
|
-
11, 12, nil,
|
199
|
+
11, 12, nil, nil, nil, nil, nil, 112, nil, nil,
|
200
200
|
nil, nil, 37, 38, 39, 40, 41, 42, 43, 44,
|
201
201
|
45, 46, 47, 48, 49, 50, 10, 11, 12, nil,
|
202
|
-
nil, nil, nil, nil,
|
202
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 37,
|
203
203
|
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
204
204
|
48, 49, 50, 10, 11, 12, nil, nil, nil, nil,
|
205
|
-
nil, nil, nil, nil, nil,
|
205
|
+
nil, nil, nil, nil, nil, 204, 37, 38, 39, 40,
|
206
206
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
207
207
|
10, 11, 12, nil, nil, nil, nil, nil, nil, nil,
|
208
|
-
nil, nil,
|
208
|
+
nil, nil, 208, 37, 38, 39, 40, 41, 42, 43,
|
209
209
|
44, 45, 46, 47, 48, 49, 50, 10, 11, 12,
|
210
210
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
211
211
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
212
212
|
47, 48, 49, 50, 10, 11, 12, nil, nil, nil,
|
213
213
|
nil, nil, nil, nil, nil, nil, nil, 37, 38, 39,
|
214
214
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
215
|
-
50, 10, 11, 12, nil, nil, nil, nil, nil,
|
216
|
-
nil, nil, nil,
|
215
|
+
50, 10, 11, 12, nil, nil, nil, nil, nil, 112,
|
216
|
+
nil, nil, nil, nil, 37, 38, 39, 40, 41, 42,
|
217
217
|
43, 44, 45, 46, 47, 48, 49, 50, 10, 11,
|
218
218
|
12, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
219
219
|
nil, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
220
220
|
46, 47, 48, 49, 50, 10, 11, 12, nil, nil,
|
221
|
-
nil, nil, nil, nil, nil, nil, nil,
|
221
|
+
nil, nil, nil, nil, nil, nil, nil, 217, 37, 38,
|
222
222
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
223
|
-
49, 50, 10, 11, 12, nil, nil,
|
223
|
+
49, 50, 10, 11, 12, nil, nil, 10, 11, 12,
|
224
|
+
nil, nil, nil, 13, nil, nil, 18, 25, 26, 115,
|
225
|
+
27, 28, 29, 30, 31, nil, 14, 10, 11, 12,
|
226
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
227
|
+
152, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
228
|
+
150, 151, 10, 11, 12, nil, nil, nil, nil, nil,
|
224
229
|
nil, nil, nil, nil, 191, 152, 38, 39, 40, 41,
|
225
230
|
42, 43, 44, 45, 46, 150, 151, 10, 11, 12,
|
226
|
-
nil, nil, 10, 11, 12, nil, nil, nil, 13, nil,
|
227
|
-
nil, 18, 25, 26, 115, 27, 28, 29, 30, 31,
|
228
|
-
nil, 14, 10, 11, 12, nil, nil, nil, nil, nil,
|
229
|
-
nil, nil, nil, nil, nil, 152, 38, 39, 40, 41,
|
230
|
-
42, 43, 44, 45, 46, 150, 151, 10, 11, 12,
|
231
231
|
nil, nil, nil, nil, nil, nil, nil, nil, 13, nil,
|
232
232
|
nil, 18, 25, 26, nil, 27, 28, 29, 30, 31,
|
233
233
|
nil, 14 ]
|
234
234
|
|
235
235
|
racc_action_check = [
|
236
236
|
13, 13, 13, 98, 98, 59, 111, 114, 59, 220,
|
237
|
-
|
237
|
+
221, 1, 13, 13, 13, 13, 13, 13, 13, 13,
|
238
238
|
13, 13, 13, 13, 13, 13, 13, 54, 54, 54,
|
239
|
-
111, 114, 13, 220, 211, 198,
|
239
|
+
111, 114, 13, 220, 198, 211, 18, 198, 211, 54,
|
240
240
|
54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
241
|
-
54, 54, 54, 54, 60, 60, 60,
|
242
|
-
63, 63, 63,
|
241
|
+
54, 54, 54, 54, 60, 60, 60, 31, 140, 54,
|
242
|
+
140, 63, 63, 63, 32, 34, 61, 60, 60, 60,
|
243
243
|
60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
|
244
|
-
60, 202, 202, 202,
|
245
|
-
202,
|
244
|
+
60, 202, 202, 202, 64, 60, 202, 65, 66, 202,
|
245
|
+
202, 67, 202, 68, 202, 202, 202, 202, 202, 202,
|
246
246
|
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
|
247
|
-
202, 202,
|
248
|
-
|
247
|
+
202, 202, 214, 214, 214, 69, 72, 214, 73, 76,
|
248
|
+
214, 79, 82, 214, 84, 214, 214, 214, 214, 214,
|
249
|
+
214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
|
250
|
+
214, 214, 214, 178, 178, 178, 88, 90, 178, 92,
|
251
|
+
93, 178, 178, 94, 178, 95, 178, 178, 178, 178,
|
249
252
|
178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
|
250
|
-
178, 178, 178,
|
251
|
-
|
253
|
+
178, 178, 178, 178, 136, 136, 136, 96, 97, 136,
|
254
|
+
101, 102, 136, 106, 108, 136, 118, 136, 136, 136,
|
252
255
|
136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
|
253
|
-
136, 136, 136, 136, 219, 219, 219,
|
254
|
-
|
256
|
+
136, 136, 136, 136, 136, 219, 219, 219, 126, 130,
|
257
|
+
219, 133, 139, 219, 141, 145, 219, 149, 219, 219,
|
255
258
|
219, 219, 219, 219, 219, 219, 219, 219, 219, 219,
|
256
|
-
219, 219, 219, 219, 219,
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
259
|
+
219, 219, 219, 219, 219, 219, 83, 83, 83, 155,
|
260
|
+
158, 164, 185, 196, 83, 207, nil, nil, nil, 83,
|
261
|
+
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
262
|
+
83, 83, 83, 143, 143, 143, nil, nil, nil, nil,
|
263
|
+
nil, nil, nil, nil, nil, nil, 143, 143, 143, 143,
|
264
|
+
143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
|
265
|
+
147, 147, 147, nil, nil, nil, nil, nil, nil, nil,
|
266
|
+
nil, nil, 147, 147, 147, 147, 147, 147, 147, 147,
|
267
|
+
147, 147, 147, 147, 147, 147, 147, 85, 85, 85,
|
268
|
+
nil, nil, nil, nil, nil, 85, nil, nil, nil, nil,
|
269
|
+
85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
|
270
|
+
85, 85, 85, 85, 117, 117, 117, nil, nil, nil,
|
271
|
+
nil, nil, nil, nil, nil, nil, nil, 117, 117, 117,
|
261
272
|
117, 117, 117, 117, 117, 117, 117, 117, 117, 117,
|
262
|
-
117,
|
263
|
-
nil, nil, nil, nil,
|
264
|
-
|
265
|
-
|
266
|
-
nil,
|
267
|
-
|
268
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
269
|
-
29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
270
|
-
29, 29, 29, 29, 30, 30, 30, nil, nil, nil,
|
271
|
-
nil, nil, nil, nil, nil, nil, nil, 30, 30, 30,
|
272
|
-
30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
|
273
|
-
30, 25, 25, 25, nil, nil, nil, nil, nil, nil,
|
274
|
-
nil, nil, nil, nil, 25, 25, 25, 25, 25, 25,
|
275
|
-
25, 25, 25, 25, 25, 25, 25, 25, 212, 212,
|
276
|
-
212, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
277
|
-
nil, 212, 212, 212, 212, 212, 212, 212, 212, 212,
|
278
|
-
212, 212, 212, 212, 212, 122, 122, 122, nil, nil,
|
273
|
+
117, 120, 120, 120, nil, nil, nil, nil, nil, nil,
|
274
|
+
nil, nil, nil, nil, 120, 120, 120, 120, 120, 120,
|
275
|
+
120, 120, 120, 120, 120, 120, 120, 120, 121, 121,
|
276
|
+
121, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
277
|
+
nil, 121, 121, 121, 121, 121, 121, 121, 121, 121,
|
278
|
+
121, 121, 121, 121, 121, 122, 122, 122, nil, nil,
|
279
279
|
nil, nil, nil, nil, nil, nil, nil, nil, 122, 122,
|
280
280
|
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
|
281
|
-
122, 122,
|
282
|
-
nil, nil, nil, nil, nil,
|
283
|
-
|
284
|
-
|
285
|
-
nil, nil,
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
nil,
|
281
|
+
122, 122, 124, 124, 124, nil, nil, nil, nil, nil,
|
282
|
+
nil, nil, nil, nil, nil, 124, 124, 124, 124, 124,
|
283
|
+
124, 124, 124, 124, 124, 124, 124, 124, 124, 125,
|
284
|
+
125, 125, nil, nil, nil, nil, nil, nil, nil, nil,
|
285
|
+
nil, nil, 125, 125, 125, 125, 125, 125, 125, 125,
|
286
|
+
125, 125, 125, 125, 125, 125, 78, 78, 78, nil,
|
287
|
+
78, nil, nil, nil, nil, nil, nil, nil, nil, 78,
|
288
|
+
78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
|
289
|
+
78, 78, 78, 81, 81, 81, nil, nil, nil, nil,
|
290
|
+
nil, nil, nil, nil, nil, nil, 81, 81, 81, 81,
|
291
|
+
81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
|
292
|
+
26, 26, 26, nil, nil, nil, nil, nil, nil, nil,
|
293
|
+
nil, nil, nil, 26, 26, 26, 26, 26, 26, 26,
|
294
|
+
26, 26, 26, 26, 26, 26, 26, 209, 209, 209,
|
295
|
+
nil, nil, nil, nil, nil, 209, nil, nil, nil, nil,
|
291
296
|
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
|
292
|
-
|
293
|
-
nil, nil, nil,
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
nil, nil, nil, nil, nil, nil, nil,
|
299
|
-
|
300
|
-
|
301
|
-
nil, nil, nil, nil,
|
302
|
-
|
303
|
-
|
304
|
-
nil,
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
nil, nil, nil, nil, nil,
|
310
|
-
|
311
|
-
70, 70,
|
312
|
-
nil, nil,
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
nil, nil, nil, nil, nil, nil, 104, 104, 104, 104,
|
318
|
-
104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
|
319
|
-
177, 177, 177, nil, nil, nil, nil, nil, nil, nil,
|
320
|
-
nil, nil, nil, 177, 177, 177, 177, 177, 177, 177,
|
321
|
-
177, 177, 177, 177, 177, 177, 177, 77, 77, 77,
|
297
|
+
209, 209, 209, 209, 212, 212, 212, nil, nil, nil,
|
298
|
+
nil, nil, nil, nil, nil, nil, nil, 212, 212, 212,
|
299
|
+
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
|
300
|
+
212, 27, 27, 27, nil, nil, nil, nil, nil, nil,
|
301
|
+
nil, nil, nil, nil, 27, 27, 27, 27, 27, 27,
|
302
|
+
27, 27, 27, 27, 27, 27, 27, 27, 28, 28,
|
303
|
+
28, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
304
|
+
nil, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
305
|
+
28, 28, 28, 28, 28, 29, 29, 29, nil, nil,
|
306
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 29, 29,
|
307
|
+
29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
308
|
+
29, 29, 30, 30, 30, nil, nil, nil, nil, nil,
|
309
|
+
nil, nil, nil, nil, nil, 30, 30, 30, 30, 30,
|
310
|
+
30, 30, 30, 30, 30, 30, 30, 30, 30, 100,
|
311
|
+
100, 100, nil, nil, nil, nil, nil, nil, nil, nil,
|
312
|
+
nil, nil, 100, 100, 100, 100, 100, 100, 100, 100,
|
313
|
+
100, 100, 100, 100, 100, 100, 70, 70, 70, nil,
|
314
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 70,
|
315
|
+
70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
|
316
|
+
70, 70, 70, 8, 8, 8, nil, nil, nil, nil,
|
317
|
+
nil, nil, nil, nil, nil, nil, 8, 8, 8, 8,
|
318
|
+
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
319
|
+
104, 104, 104, nil, 104, nil, nil, nil, nil, nil,
|
320
|
+
nil, nil, nil, 104, 104, 104, 104, 104, 104, 104,
|
321
|
+
104, 104, 104, 104, 104, 104, 104, 14, 14, 14,
|
322
322
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
323
|
-
|
324
|
-
|
325
|
-
nil, nil,
|
326
|
-
|
327
|
-
|
328
|
-
nil, nil, nil, nil,
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
nil, nil, nil, nil, nil, nil, nil, nil,
|
334
|
-
|
335
|
-
162, 162,
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
nil, nil,
|
340
|
-
|
341
|
-
nil, nil, nil, nil,
|
342
|
-
|
343
|
-
|
344
|
-
nil, nil, nil, nil, nil,
|
345
|
-
|
346
|
-
|
347
|
-
nil, nil,
|
348
|
-
|
323
|
+
nil, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
324
|
+
14, 14, 14, 14, 112, 112, 112, nil, nil, nil,
|
325
|
+
nil, nil, 112, nil, nil, nil, nil, 112, 112, 112,
|
326
|
+
112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
|
327
|
+
112, 77, 77, 77, nil, nil, nil, nil, nil, nil,
|
328
|
+
nil, nil, nil, nil, 77, 77, 77, 77, 77, 77,
|
329
|
+
77, 77, 77, 77, 77, 77, 77, 77, 160, 160,
|
330
|
+
160, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
331
|
+
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
|
332
|
+
160, 160, 160, 160, 160, 161, 161, 161, nil, 161,
|
333
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 161, 161,
|
334
|
+
161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
|
335
|
+
161, 161, 162, 162, 162, nil, nil, nil, nil, nil,
|
336
|
+
nil, nil, nil, nil, nil, 162, 162, 162, 162, 162,
|
337
|
+
162, 162, 162, 162, 162, 162, 162, 162, 162, 163,
|
338
|
+
163, 163, nil, nil, nil, nil, nil, 163, nil, nil,
|
339
|
+
nil, nil, 163, 163, 163, 163, 163, 163, 163, 163,
|
340
|
+
163, 163, 163, 163, 163, 163, 177, 177, 177, nil,
|
341
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 177,
|
342
|
+
177, 177, 177, 177, 177, 177, 177, 177, 177, 177,
|
343
|
+
177, 177, 177, 179, 179, 179, nil, nil, nil, nil,
|
344
|
+
nil, nil, nil, nil, nil, 179, 179, 179, 179, 179,
|
345
|
+
179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
|
346
|
+
184, 184, 184, nil, nil, nil, nil, nil, nil, nil,
|
347
|
+
nil, nil, 184, 184, 184, 184, 184, 184, 184, 184,
|
348
|
+
184, 184, 184, 184, 184, 184, 184, 91, 91, 91,
|
349
349
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
350
|
-
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
|
351
|
-
100, 100, 100, 100, 91, 91, 91, nil, nil, nil,
|
352
|
-
nil, nil, nil, nil, nil, nil, nil, 91, 91, 91,
|
353
350
|
91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
|
354
|
-
91,
|
355
|
-
nil, nil, nil,
|
356
|
-
|
357
|
-
|
358
|
-
nil,
|
359
|
-
|
360
|
-
nil, nil, nil, nil, nil, nil, nil,
|
361
|
-
|
362
|
-
|
351
|
+
91, 91, 91, 91, 188, 188, 188, nil, nil, nil,
|
352
|
+
nil, nil, nil, nil, nil, nil, nil, 188, 188, 188,
|
353
|
+
188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
|
354
|
+
188, 192, 192, 192, nil, nil, nil, nil, nil, 192,
|
355
|
+
nil, nil, nil, nil, 192, 192, 192, 192, 192, 192,
|
356
|
+
192, 192, 192, 192, 192, 192, 192, 192, 25, 25,
|
357
|
+
25, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
358
|
+
nil, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
359
|
+
25, 25, 25, 25, 25, 205, 205, 205, nil, nil,
|
360
|
+
nil, nil, nil, nil, nil, nil, nil, 205, 205, 205,
|
361
|
+
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
|
362
|
+
205, 205, 0, 0, 0, nil, nil, 86, 86, 86,
|
363
|
+
nil, nil, nil, 0, nil, nil, 0, 0, 0, 86,
|
364
|
+
0, 0, 0, 0, 0, nil, 0, 123, 123, 123,
|
365
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
366
|
+
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
|
367
|
+
123, 123, 157, 157, 157, nil, nil, nil, nil, nil,
|
363
368
|
nil, nil, nil, nil, 157, 157, 157, 157, 157, 157,
|
364
369
|
157, 157, 157, 157, 157, 157, 157, 3, 3, 3,
|
365
|
-
nil, nil,
|
366
|
-
nil, 3, 3, 3,
|
367
|
-
nil, 3
|
368
|
-
nil, nil, nil, nil, nil, 123, 123, 123, 123, 123,
|
369
|
-
123, 123, 123, 123, 123, 123, 123, 0, 0, 0,
|
370
|
-
nil, nil, nil, nil, nil, nil, nil, nil, 0, nil,
|
371
|
-
nil, 0, 0, 0, nil, 0, 0, 0, 0, 0,
|
372
|
-
nil, 0 ]
|
370
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 3, nil,
|
371
|
+
nil, 3, 3, 3, nil, 3, 3, 3, 3, 3,
|
372
|
+
nil, 3 ]
|
373
373
|
|
374
374
|
racc_action_pointer = [
|
375
|
-
|
376
|
-
nil, nil, nil, -2,
|
377
|
-
nil, nil, nil, nil, nil,
|
378
|
-
|
375
|
+
1260, 11, nil, 1335, nil, nil, nil, nil, 801, nil,
|
376
|
+
nil, nil, nil, -2, 855, nil, nil, nil, 23, nil,
|
377
|
+
nil, nil, nil, nil, nil, 1206, 558, 639, 666, 693,
|
378
|
+
720, 24, 64, nil, 60, nil, nil, nil, nil, nil,
|
379
379
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
380
380
|
nil, nil, nil, nil, 25, nil, nil, nil, nil, 0,
|
381
|
-
52,
|
382
|
-
|
383
|
-
nil,
|
384
|
-
114,
|
385
|
-
|
386
|
-
nil, -3,
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
nil, nil, nil, nil, nil,
|
391
|
-
|
392
|
-
nil, nil, nil, nil, nil, nil, nil,
|
393
|
-
nil, nil, nil, nil,
|
394
|
-
nil, nil,
|
395
|
-
nil, nil, 79, nil, nil,
|
396
|
-
nil,
|
397
|
-
0,
|
381
|
+
52, 51, nil, 59, 51, 68, 55, 58, 60, 82,
|
382
|
+
774, nil, 83, 111, nil, nil, 86, 909, 504, 88,
|
383
|
+
nil, 531, 89, 234, 111, 315, 1265, nil, 138, nil,
|
384
|
+
114, 1125, 136, 138, 140, 142, 172, 165, -3, nil,
|
385
|
+
747, 167, 176, nil, 828, nil, 175, nil, 179, nil,
|
386
|
+
nil, -3, 882, nil, -2, nil, nil, 342, 173, nil,
|
387
|
+
369, 396, 423, 1285, 450, 477, 193, nil, nil, nil,
|
388
|
+
201, nil, nil, 178, nil, nil, 172, nil, nil, 199,
|
389
|
+
49, 201, nil, 261, nil, 210, nil, 288, nil, 182,
|
390
|
+
nil, nil, nil, nil, nil, 206, nil, 1310, 232, nil,
|
391
|
+
936, 963, 990, 1017, 228, nil, nil, nil, nil, nil,
|
392
|
+
nil, nil, nil, nil, nil, nil, nil, 1044, 141, 1071,
|
393
|
+
nil, nil, nil, nil, 1098, 234, nil, nil, 1152, nil,
|
394
|
+
nil, nil, 1179, nil, nil, nil, 208, nil, 25, nil,
|
395
|
+
nil, nil, 79, nil, nil, 1233, nil, 237, nil, 585,
|
396
|
+
nil, 26, 612, nil, 110, nil, nil, nil, nil, 203,
|
397
|
+
0, -23, nil, nil, nil, nil, nil ]
|
398
398
|
|
399
399
|
racc_action_default = [
|
400
400
|
-136, -136, -1, -2, -3, -5, -6, -7, -13, -9,
|
@@ -423,16 +423,16 @@ racc_action_default = [
|
|
423
423
|
|
424
424
|
racc_goto_table = [
|
425
425
|
8, 62, 111, 8, 114, 154, 132, 55, 35, 165,
|
426
|
-
126,
|
427
|
-
213,
|
428
|
-
69, 140, 127, 221, 84,
|
429
|
-
92, 93, 94, 95, 184,
|
430
|
-
101, 203, 186, 105, 59, 133, 109,
|
431
|
-
154, 137, 4, 88, 118, 33,
|
432
|
-
96,
|
433
|
-
|
434
|
-
|
435
|
-
130, 154,
|
426
|
+
126, 156, 76, 59, 87, 186, 160, 161, 154, 113,
|
427
|
+
213, 196, 147, 155, 99, 64, 65, 66, 67, 68,
|
428
|
+
69, 140, 127, 221, 84, 2, 131, 116, 89, 154,
|
429
|
+
92, 93, 94, 95, 184, 190, 97, 82, 75, 129,
|
430
|
+
101, 203, 186, 105, 59, 133, 109, 155, 3, 185,
|
431
|
+
154, 137, 4, 88, 118, 33, 34, 206, 72, 199,
|
432
|
+
96, 193, 193, 98, 181, 216, 183, 102, 106, 135,
|
433
|
+
54, 108, 198, 120, 154, 139, 88, 223, 141, 157,
|
434
|
+
104, 119, 224, 218, 202, 205, 154, 107, 61, 131,
|
435
|
+
130, 154, 86, 90, 106, 149, 1, 164, nil, nil,
|
436
436
|
nil, 211, nil, nil, nil, nil, nil, 142, nil, nil,
|
437
437
|
144, 145, 148, 153, 158, 158, nil, nil, 220, 189,
|
438
438
|
nil, nil, nil, nil, nil, nil, 153, nil, nil, nil,
|
@@ -447,16 +447,16 @@ racc_goto_table = [
|
|
447
447
|
|
448
448
|
racc_goto_check = [
|
449
449
|
8, 26, 16, 8, 16, 27, 20, 21, 13, 18,
|
450
|
-
60,
|
451
|
-
17,
|
452
|
-
13, 16, 12, 17, 11,
|
453
|
-
11, 11, 11, 11, 57,
|
454
|
-
11, 18, 61, 33, 13, 25, 11,
|
455
|
-
27, 25, 4, 8, 11, 4,
|
456
|
-
13,
|
457
|
-
|
458
|
-
|
459
|
-
13, 27,
|
450
|
+
60, 30, 25, 13, 49, 61, 59, 59, 27, 12,
|
451
|
+
17, 63, 57, 28, 15, 13, 13, 13, 13, 13,
|
452
|
+
13, 16, 12, 17, 11, 2, 12, 49, 11, 27,
|
453
|
+
11, 11, 11, 11, 57, 30, 11, 26, 21, 15,
|
454
|
+
11, 18, 61, 33, 13, 25, 11, 28, 3, 60,
|
455
|
+
27, 25, 4, 8, 11, 4, 9, 41, 10, 20,
|
456
|
+
13, 58, 58, 14, 12, 18, 12, 13, 13, 33,
|
457
|
+
19, 13, 16, 29, 27, 11, 8, 18, 11, 31,
|
458
|
+
32, 13, 18, 41, 39, 40, 27, 43, 44, 12,
|
459
|
+
13, 27, 48, 56, 13, 62, 1, 11, nil, nil,
|
460
460
|
nil, 16, nil, nil, nil, nil, nil, 13, nil, nil,
|
461
461
|
13, 13, 13, 8, 13, 13, nil, nil, 16, 11,
|
462
462
|
nil, nil, nil, nil, nil, nil, 8, nil, nil, nil,
|
@@ -470,13 +470,13 @@ racc_goto_check = [
|
|
470
470
|
nil, nil, 13, nil, 8, nil, nil, nil, nil, 8 ]
|
471
471
|
|
472
472
|
racc_goto_pointer = [
|
473
|
-
nil,
|
474
|
-
|
475
|
-
-95, -6, nil, nil, nil, -47, -13, -118, -
|
476
|
-
-
|
477
|
-
|
478
|
-
nil, nil, nil, nil, nil, nil,
|
479
|
-
-86, -132, -17,
|
473
|
+
nil, 106, 35, 58, 62, nil, nil, nil, 0, 58,
|
474
|
+
34, -26, -65, 0, 0, -49, -81, -178, -127, 67,
|
475
|
+
-95, -6, nil, nil, nil, -47, -13, -118, -100, -8,
|
476
|
+
-112, -34, 12, -25, nil, nil, nil, nil, nil, -84,
|
477
|
+
-84, -112, nil, 18, 84, nil, nil, nil, 39, -49,
|
478
|
+
nil, nil, nil, nil, nil, nil, 38, -99, -89, -108,
|
479
|
+
-86, -132, -17, -141 ]
|
480
480
|
|
481
481
|
racc_goto_default = [
|
482
482
|
nil, nil, nil, nil, nil, 5, 6, 7, 51, nil,
|
data/lib/graphql/query.rb
CHANGED
@@ -56,7 +56,11 @@ module GraphQL
|
|
56
56
|
@operation_name = operation_name
|
57
57
|
@fragments = {}
|
58
58
|
@operations = {}
|
59
|
-
|
59
|
+
if variables.is_a?(String)
|
60
|
+
raise ArgumentError, "Query variables should be a Hash, not a String. Try JSON.parse to prepare variables."
|
61
|
+
else
|
62
|
+
@provided_variables = variables
|
63
|
+
end
|
60
64
|
@query_string = query_string
|
61
65
|
@document = document || GraphQL.parse(query_string)
|
62
66
|
@document.definitions.each do |part|
|
data/lib/graphql/schema.rb
CHANGED
@@ -46,8 +46,6 @@ module GraphQL
|
|
46
46
|
# end
|
47
47
|
#
|
48
48
|
class Schema
|
49
|
-
include BuildFromDefinition
|
50
|
-
|
51
49
|
include GraphQL::Define::InstanceDefinable
|
52
50
|
accepts_definitions \
|
53
51
|
:query, :mutation, :subscription,
|
@@ -270,6 +268,16 @@ module GraphQL
|
|
270
268
|
GraphQL::Schema::Loader.load(introspection_result)
|
271
269
|
end
|
272
270
|
|
271
|
+
# Create schema from an IDL schema.
|
272
|
+
# @param definition_string String A schema definition string
|
273
|
+
# @return [GraphQL::Schema] the schema described by `document`
|
274
|
+
def self.from_definition(definition_string)
|
275
|
+
GraphQL::Schema::BuildFromDefinition.from_definition(definition_string)
|
276
|
+
end
|
277
|
+
|
278
|
+
# Error that is raised when [#Schema#from_definition] is passed an invalid schema definition string.
|
279
|
+
class InvalidDocumentError < Error; end;
|
280
|
+
|
273
281
|
private
|
274
282
|
|
275
283
|
# Lazily create a middleware and add it to the schema
|
@@ -1,16 +1,7 @@
|
|
1
1
|
module GraphQL
|
2
2
|
class Schema
|
3
3
|
module BuildFromDefinition
|
4
|
-
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
end
|
7
|
-
|
8
|
-
class InvalidDocumentError < Error; end;
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
# Create schema from an IDL schema.
|
12
|
-
# @param definition_string String A schema definition string
|
13
|
-
# @return [GraphQL::Schema] the schema described by `document`
|
4
|
+
class << self
|
14
5
|
def from_definition(definition_string)
|
15
6
|
document = GraphQL::parse(definition_string)
|
16
7
|
Builder.build(document)
|
@@ -6,7 +6,6 @@ module GraphQL
|
|
6
6
|
def validate(context)
|
7
7
|
visitor = context.visitor
|
8
8
|
visitor[GraphQL::Language::Nodes::Field] << ->(node, parent) {
|
9
|
-
return if context.skip_field?(node.name)
|
10
9
|
parent_type = context.object_types[-2]
|
11
10
|
parent_type = parent_type.unwrap
|
12
11
|
validate_field(context, node, parent_type, parent)
|
@@ -16,7 +15,7 @@ module GraphQL
|
|
16
15
|
private
|
17
16
|
|
18
17
|
def validate_field(context, ast_field, parent_type, parent)
|
19
|
-
if parent_type.kind.union?
|
18
|
+
if parent_type.kind.union? && ast_field.name != '__typename'
|
20
19
|
context.errors << message("Selections can't be made directly on unions (see selections on #{parent_type.name})", parent, context: context)
|
21
20
|
return GraphQL::Language::Visitor::SKIP
|
22
21
|
end
|
@@ -74,12 +74,6 @@ module GraphQL
|
|
74
74
|
@literal_validator ||= LiteralValidator.new(warden: @warden)
|
75
75
|
@literal_validator.validate(ast_value, type)
|
76
76
|
end
|
77
|
-
|
78
|
-
# Don't try to validate dynamic fields
|
79
|
-
# since they aren't defined by the type system
|
80
|
-
def skip_field?(field_name)
|
81
|
-
GraphQL::Schema::DYNAMIC_FIELDS.include?(field_name)
|
82
|
-
end
|
83
77
|
end
|
84
78
|
end
|
85
79
|
end
|
data/lib/graphql/version.rb
CHANGED
data/readme.md
CHANGED
@@ -55,9 +55,6 @@ See "Getting Started" on the [website](https://rmosolgo.github.io/graphql-ruby/)
|
|
55
55
|
- Improve API for creating edges (better RANGE_ADD support)
|
56
56
|
- If the new edge isn't a member of the connection's objects, raise a nice error
|
57
57
|
- `args` should whitelist keys -- if you request a key that isn't defined for the field, it should 💥
|
58
|
-
- Fix middleware ([discussion](https://github.com/rmosolgo/graphql-ruby/issues/186))
|
59
|
-
- Handle out-of-bounds lookup, eg `graphql-batch`
|
60
|
-
- Handle non-serial execution, eg `@defer`
|
61
58
|
- Support non-instance-eval `.define`, eg `.define { |defn| ... }`
|
62
59
|
- First-class promise support ([discussion](https://github.com/rmosolgo/graphql-ruby/issues/274))
|
63
60
|
- like `graphql-batch` but more local
|
@@ -67,5 +64,3 @@ See "Getting Started" on the [website](https://rmosolgo.github.io/graphql-ruby/)
|
|
67
64
|
- Adding fields to selections (`__typename` can go anywhere, others are type-specific)
|
68
65
|
- Renaming fragments from local names to unique names
|
69
66
|
- Document encrypted & versioned cursors
|
70
|
-
- Make it faster
|
71
|
-
- Is it possible to merge typed branches before resolving them? It's hard because even the branches will have branches.
|
data/spec/graphql/query_spec.rb
CHANGED
@@ -315,6 +315,13 @@ describe GraphQL::Query do
|
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
318
|
+
describe "when they're a string" do
|
319
|
+
let(:query_variables) { '{ "var" : 1 }' }
|
320
|
+
it "raises an error" do
|
321
|
+
assert_raises(ArgumentError) { result }
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
318
325
|
describe "default values" do
|
319
326
|
let(:query_string) {%|
|
320
327
|
query getCheese($cheeseId: Int = 3){
|
@@ -187,4 +187,20 @@ describe GraphQL::StaticValidation::ArgumentLiteralsAreCompatible do
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
190
|
+
|
191
|
+
describe "dynamic fields" do
|
192
|
+
let(:query_string) {"
|
193
|
+
query {
|
194
|
+
__type(name: 1) { name }
|
195
|
+
}
|
196
|
+
"}
|
197
|
+
|
198
|
+
it "finds invalid argument types" do
|
199
|
+
assert_includes(errors, {
|
200
|
+
"message"=>"Argument 'name' on Field '__type' has an invalid value. Expected type 'String!'.",
|
201
|
+
"locations"=>[{"line"=>3, "column"=>9}],
|
202
|
+
"fields"=>["query", "__type", "name"],
|
203
|
+
})
|
204
|
+
end
|
205
|
+
end
|
190
206
|
end
|
@@ -49,4 +49,20 @@ describe GraphQL::StaticValidation::ArgumentsAreDefined do
|
|
49
49
|
}
|
50
50
|
assert_includes(errors, directive_error)
|
51
51
|
end
|
52
|
+
|
53
|
+
describe "dynamic fields" do
|
54
|
+
let(:query_string) {"
|
55
|
+
query {
|
56
|
+
__type(somethingInvalid: 1) { name }
|
57
|
+
}
|
58
|
+
"}
|
59
|
+
|
60
|
+
it "finds undefined arguments" do
|
61
|
+
assert_includes(errors, {
|
62
|
+
"message"=>"Field '__type' doesn't accept argument 'somethingInvalid'",
|
63
|
+
"locations"=>[{"line"=>3, "column"=>9}],
|
64
|
+
"fields"=>["query", "__type", "somethingInvalid"],
|
65
|
+
})
|
66
|
+
end
|
67
|
+
end
|
52
68
|
end
|
@@ -59,7 +59,6 @@ describe GraphQL::StaticValidation::FieldsAreDefinedOnType do
|
|
59
59
|
fragment dpIndirectFields on DairyProduct { ... on Cheese { source } }
|
60
60
|
"}
|
61
61
|
|
62
|
-
|
63
62
|
it "doesnt allow selections on unions" do
|
64
63
|
expected_errors = [
|
65
64
|
{
|
@@ -73,4 +72,90 @@ describe GraphQL::StaticValidation::FieldsAreDefinedOnType do
|
|
73
72
|
assert_equal(expected_errors, errors)
|
74
73
|
end
|
75
74
|
end
|
75
|
+
|
76
|
+
describe "__typename" do
|
77
|
+
describe "on existing unions" do
|
78
|
+
let(:query_string) { "
|
79
|
+
query { favoriteEdible { ...dpFields } }
|
80
|
+
fragment dpFields on DairyProduct { __typename }
|
81
|
+
"}
|
82
|
+
|
83
|
+
it "is allowed" do
|
84
|
+
assert_equal([], errors)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "on existing objects" do
|
89
|
+
let(:query_string) { "
|
90
|
+
query { cheese(id: 1) { __typename } }
|
91
|
+
"}
|
92
|
+
|
93
|
+
it "is allowed" do
|
94
|
+
assert_equal([], errors)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "__schema" do
|
100
|
+
describe "on query root" do
|
101
|
+
let(:query_string) { "
|
102
|
+
query { __schema { queryType { name } } }
|
103
|
+
"}
|
104
|
+
|
105
|
+
it "is allowed" do
|
106
|
+
assert_equal([], errors)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "on non-query root" do
|
111
|
+
let(:query_string) { "
|
112
|
+
query { cheese(id: 1) { __schema { queryType { name } } } }
|
113
|
+
"}
|
114
|
+
|
115
|
+
it "is not allowed" do
|
116
|
+
expected_errors = [
|
117
|
+
{
|
118
|
+
"message"=>"Field '__schema' doesn't exist on type 'Cheese'",
|
119
|
+
"locations"=>[
|
120
|
+
{"line"=>2, "column"=>33}
|
121
|
+
],
|
122
|
+
"fields"=>["query", "cheese", "__schema"],
|
123
|
+
}
|
124
|
+
]
|
125
|
+
assert_equal(expected_errors, errors)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "__type" do
|
131
|
+
describe "on query root" do
|
132
|
+
let(:query_string) { %|
|
133
|
+
query { __type(name: "Cheese") { name } }
|
134
|
+
|}
|
135
|
+
|
136
|
+
it "is allowed" do
|
137
|
+
assert_equal([], errors)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "on non-query root" do
|
142
|
+
let(:query_string) { %|
|
143
|
+
query { cheese(id: 1) { __type(name: "Cheese") { name } } }
|
144
|
+
|}
|
145
|
+
|
146
|
+
it "is not allowed" do
|
147
|
+
expected_errors = [
|
148
|
+
{
|
149
|
+
"message"=>"Field '__type' doesn't exist on type 'Cheese'",
|
150
|
+
"locations"=>[
|
151
|
+
{"line"=>2, "column"=>33}
|
152
|
+
],
|
153
|
+
"fields"=>["query", "cheese", "__type"],
|
154
|
+
}
|
155
|
+
]
|
156
|
+
assert_equal(expected_errors, errors)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
76
161
|
end
|
@@ -39,4 +39,25 @@ describe GraphQL::StaticValidation::RequiredArgumentsArePresent do
|
|
39
39
|
}
|
40
40
|
assert_includes(errors, directive_error)
|
41
41
|
end
|
42
|
+
|
43
|
+
describe "dynamic fields" do
|
44
|
+
let(:query_string) {"
|
45
|
+
query {
|
46
|
+
__type { name }
|
47
|
+
}
|
48
|
+
"}
|
49
|
+
|
50
|
+
it "finds undefined required arguments" do
|
51
|
+
expected_errors = [
|
52
|
+
{
|
53
|
+
"message"=>"Field '__type' is missing required arguments: name",
|
54
|
+
"locations"=>[
|
55
|
+
{"line"=>3, "column"=>9}
|
56
|
+
],
|
57
|
+
"fields"=>["query", "__type"],
|
58
|
+
}
|
59
|
+
]
|
60
|
+
assert_equal(expected_errors, errors)
|
61
|
+
end
|
62
|
+
end
|
42
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|