Skip to content

Commit ef4b13b

Browse files
authored
Add error messages criterion to Input Union (#795)
I don't think it impacts the outcome in any strong fashion, but it's been discussed so we should document it for completeness' sake.
1 parent d388f13 commit ef4b13b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

rfcs/InputUnion.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ Adding an input to one or more unions should not require extraneous changes, con
427427

428428
Criteria score: 🥇
429429

430+
## 🎯 P. Error states and messages should be clear and helpful
431+
432+
Complex algorithms can make it difficult to write error messages that are helpful and clear.
433+
When an invalid schema or invalid query are used, it should be obvious what went wrong and how to fix it.
434+
435+
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] | [6][solution-6] | [7][solution-7]
436+
|----|----|----|----|----|----|----|
437+
| ✅️ | ✅️ | ⚠️ | 🚫 ||||
438+
439+
Criteria score: 🥉
440+
430441
# 🚧 Possible Solutions
431442

432443
The community has imagined a variety of possible solutions, synthesized here.
@@ -509,6 +520,8 @@ type Mutation {
509520
* ✅⚠️
510521
* [O. Unconstrained combination of input types to unions][criteria-o]
511522
* ✅ Adding or removing an input type to a union has no extraneous effects on schema design
523+
* [P. Error states and messages should be clear and helpful][criteria-p]
524+
* ✅
512525

513526
## 💡 2. Explicit configurable Discriminator field
514527

@@ -621,6 +634,8 @@ inputunion AnimalInput @discriminator(field: "species") =
621634
* 🚫 Adding an input type to a union requires that it has the non-null discriminator field
622635
* The input might already have a field with the same name, but a different type
623636
* Reusing input types in multiple input unions can become unwieldy
637+
* [P. Error states and messages should be clear and helpful][criteria-p]
638+
*
624639

625640
## 💡 3. Order based discrimination
626641

@@ -710,6 +725,8 @@ type Mutation {
710725
* ✅⚠️
711726
* [O. Unconstrained combination of input types to unions][criteria-o]
712727
* ❔ Not evaluated
728+
* [P. Error states and messages should be clear and helpful][criteria-p]
729+
* ⚠️ Order-based discrimination can lead to some subtle issues based on when one type is chosen over another.
713730

714731
## 💡 4. Structural uniqueness
715732

@@ -803,6 +820,8 @@ input DogInput {
803820
* ✅⚠️
804821
* [O. Unconstrained combination of input types to unions][criteria-o]
805822
* 🚫 Input types with similar fields may not be able to be combined without breaking changes
823+
* [P. Error states and messages should be clear and helpful][criteria-p]
824+
* 🚫 Structural uniqueness checks are very complex and have many hard-to-describe failure states.
806825

807826
## 💡 5. One Of (Tagged Union)
808827

@@ -883,6 +902,8 @@ type Mutation {
883902
* ✅ Existing code generation tools will degrade gracefully to a regular input object
884903
* [O. Unconstrained combination of input types to unions][criteria-o]
885904
* ✅ Adding or removing input types to a tagged union requires no extraneous effort
905+
* [P. Error states and messages should be clear and helpful][criteria-p]
906+
* ✅
886907

887908
### Summary of spec changes
888909

@@ -1003,6 +1024,8 @@ https://github.com/graphql/graphql-spec/pull/733
10031024
* ✅⚠️
10041025
* [O. Unconstrained combination of input types to unions][criteria-o]
10051026
* ✅ Adding or removing member fields to a tagged type requires no extraneous effort and has no non-local consequences
1027+
* [P. Error states and messages should be clear and helpful][criteria-p]
1028+
* ✅
10061029

10071030
### Summary of spec changes
10081031

@@ -1039,6 +1062,7 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
10391062
| [M][criteria-m] 🥈 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | ? | 🚫 |
10401063
| [N][criteria-n] 🥈 | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅ | ? | ✅⚠️ |
10411064
| [O][criteria-o] 🥈 | ✅️ | 🚫️ | ❔ | 🚫 | ✅ | ? | ✅ |
1065+
| [P][criteria-p] 🥉 | ✅️ | ✅️ | ⚠️ | 🚫 | ✅ | ❔ | ✅ |
10421066

10431067
[criteria-a]: #-a-graphql-should-contain-a-polymorphic-input-type
10441068
[criteria-b]: #-b-input-polymorphism-matches-output-polymorphism
@@ -1055,6 +1079,7 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
10551079
[criteria-m]: #-m-existing-sdl-parsers-are-backwards-compatible-with-sdl-additions
10561080
[criteria-n]: #-n-existing-code-generated-tooling-is-backwards-compatible-with-introspection-additions
10571081
[criteria-o]: #-o-unconstrained-combination-of-input-types-to-unions
1082+
[criteria-p]: #-p-error-states-and-messages-should-be-clear-and-helpful
10581083

10591084
[solution-1]: #-1-explicit-__typename-discriminator-field
10601085
[solution-2]: #-2-explicit-configurable-discriminator-field

0 commit comments

Comments
 (0)