@@ -427,6 +427,17 @@ Adding an input to one or more unions should not require extraneous changes, con
427
427
428
428
Criteria score: 🥇
429
429
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
+
430
441
# 🚧 Possible Solutions
431
442
432
443
The community has imagined a variety of possible solutions, synthesized here.
@@ -509,6 +520,8 @@ type Mutation {
509
520
* ✅⚠️
510
521
* [O. Unconstrained combination of input types to unions][criteria-o]
511
522
* ✅ 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
+ * ✅
512
525
513
526
## 💡 2. Explicit configurable Discriminator field
514
527
@@ -621,6 +634,8 @@ inputunion AnimalInput @discriminator(field: "species") =
621
634
* 🚫 Adding an input type to a union requires that it has the non-null discriminator field
622
635
* The input might already have a field with the same name, but a different type
623
636
* Reusing input types in multiple input unions can become unwieldy
637
+ * [ P. Error states and messages should be clear and helpful] [ criteria-p ]
638
+ * ✅
624
639
625
640
## 💡 3. Order based discrimination
626
641
@@ -710,6 +725,8 @@ type Mutation {
710
725
* ✅⚠️
711
726
* [O. Unconstrained combination of input types to unions][criteria-o]
712
727
* ❔ 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.
713
730
714
731
## 💡 4. Structural uniqueness
715
732
@@ -803,6 +820,8 @@ input DogInput {
803
820
* ✅⚠️
804
821
* [O. Unconstrained combination of input types to unions][criteria-o]
805
822
* 🚫 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.
806
825
807
826
## 💡 5. One Of (Tagged Union)
808
827
@@ -883,6 +902,8 @@ type Mutation {
883
902
* ✅ Existing code generation tools will degrade gracefully to a regular input object
884
903
* [O . Unconstrained combination of input types to unions ][criteria -o ]
885
904
* ✅ 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
+ * ✅
886
907
887
908
### Summary of spec changes
888
909
@@ -1003,6 +1024,8 @@ https://github.com/graphql/graphql-spec/pull/733
1003
1024
* ✅⚠️
1004
1025
* [O . Unconstrained combination of input types to unions ][criteria -o ]
1005
1026
* ✅ 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
+ * ✅
1006
1029
1007
1030
### Summary of spec changes
1008
1031
@@ -1039,6 +1062,7 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
1039
1062
| [M ][criteria -m ] 🥈 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | ? | 🚫 |
1040
1063
| [N ][criteria -n ] 🥈 | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅ | ? | ✅⚠️ |
1041
1064
| [O ][criteria -o ] 🥈 | ✅️ | 🚫️ | ❔ | 🚫 | ✅ | ? | ✅ |
1065
+ | [P ][criteria -p ] 🥉 | ✅️ | ✅️ | ⚠️ | 🚫 | ✅ | ❔ | ✅ |
1042
1066
1043
1067
[criteria -a ]: #-a-graphql-should-contain-a-polymorphic-input-type
1044
1068
[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
1055
1079
[criteria -m ]: #-m-existing-sdl-parsers-are-backwards-compatible-with-sdl-additions
1056
1080
[criteria -n ]: #-n-existing-code-generated-tooling-is-backwards-compatible-with-introspection-additions
1057
1081
[criteria -o ]: #-o-unconstrained-combination-of-input-types-to-unions
1082
+ [criteria -p ]: #-p-error-states-and-messages-should-be-clear-and-helpful
1058
1083
1059
1084
[solution -1]: #-1-explicit-__typename-discriminator-field
1060
1085
[solution -2]: #-2-explicit-configurable-discriminator-field
0 commit comments