Commit 0699f51
committed
RFC: Return type overlap validation
Implements graphql/graphql-spec#162
This alters the "Overlapping Fields Can Be Merged" validation rule to better express return type validation issues.
The existing rule has presented some false-positives in some schema where interfaces with co-variant types are commonly used. The "same return type" check doesn't remove any ambiguity.
Instead what that "same return type" check is attempting to prevent is spreading two fragments (or inline fragments) which have fields with return types where ambiguity would be introduced in the response.
In order to curb false-positives, we later changed this rule such that if two fields were known to never apply simultaneously, then we would skip the remainder of the rule.
```
{
... on Person {
foo: fullName
}
... on Pet {
foo: petName
}
}
```
However this can introduce false-negatives!
```
{
... on Person {
foo: birthday {
bar: year
}
}
... on Business {
foo: location {
bar: street
}
}
}
```
In the above example, `data.foo.bar` could be of type `Int` or type `String`, it's ambiguous!
This differing return type breaks some client model implementations (Fragment models) in addition to just being confusing.1 parent c7e6a75 commit 0699f51
2 files changed
Lines changed: 261 additions & 61 deletions
File tree
- src/validation
- __tests__
- rules
Lines changed: 138 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
379 | | - | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
383 | 386 | | |
384 | 387 | | |
385 | 388 | | |
386 | 389 | | |
387 | 390 | | |
388 | | - | |
| 391 | + | |
389 | 392 | | |
390 | 393 | | |
391 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
392 | 398 | | |
393 | 399 | | |
394 | 400 | | |
| |||
455 | 461 | | |
456 | 462 | | |
457 | 463 | | |
458 | | - | |
| 464 | + | |
459 | 465 | | |
460 | 466 | | |
461 | 467 | | |
| |||
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
480 | | - | |
| 486 | + | |
481 | 487 | | |
482 | 488 | | |
483 | 489 | | |
484 | 490 | | |
485 | 491 | | |
486 | | - | |
487 | | - | |
488 | | - | |
| 492 | + | |
| 493 | + | |
489 | 494 | | |
490 | 495 | | |
491 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
492 | 500 | | |
493 | 501 | | |
494 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
495 | 622 | | |
496 | 623 | | |
497 | 624 | | |
| |||
0 commit comments