Commit 6a639da
committed
[validation] Loosen overlapping field validation rules
This loosens the rules for fields of the same response name which occur in the same selection set. Implemented in JS by graphql/graphql-js#230 and graphql/graphql-js#229
This allows for fields of the same response name to differ in a few conditions deemed to be safe where previously the validation was too conservative.
The currently supported directives: @Skip and @include do not create an ambiguous or erroneous query when used on conflicting fields in a divergent fashion. In fact, this may be intended when many different conditions should result in the same outcome. For example:
```graphql
{
field @include(if: $firstCondition)
field @include(if: $secondCondition)
}
```
This example could be considered as the intent of fetching `field` given `$firstCondition || $secondCondition`. While this example is contrived, there are more complex examples where such fields are nested within fragments that this condition is reasonable.
The following example is now legal, since no object can be both the concrete object type "Cat" and "Dog" at the same time, so the response shape is still unambiguous provided the types are known.
```graphql
{
... on Cat {
name
}
... on Dog {
name: nickname
}
}
```
However the following is still not legal, since it results in ambiguity:
```graphql
{
name
... on Dog {
name: nickname
}
}
```1 parent 5d5bcd7 commit 6a639da
1 file changed
+35
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
245 | | - | |
246 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
247 | 252 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 253 | + | |
| 254 | + | |
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
| |||
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
310 | | - | |
311 | 313 | | |
312 | | - | |
313 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
314 | 319 | | |
315 | | - | |
| 320 | + | |
| 321 | + | |
316 | 322 | | |
317 | 323 | | |
318 | | - | |
319 | | - | |
320 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
321 | 331 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | 332 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
330 | 340 | | |
331 | 341 | | |
332 | 342 | | |
| |||
0 commit comments