@@ -231,7 +231,7 @@ Adding a new member type to an Input Union or doing any non-breaking change to e
231231
232232| [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
233233| ----| ----| ----| ----| ----|
234- | ✅ | ✅ | 🚫 | ⚠️ | ✅ |
234+ | ✅ | ⚠ | 🚫 | ⚠️ | ✅ |
235235
236236Criteria score: 🥇
237237
@@ -390,6 +390,17 @@ For example, GraphiQL should successfully render when pointed at a schema which
390390
391391Criteria score: 🥈
392392
393+ ## 🎯 O. Unconstrained combination of input types to unions
394+
395+ It should be possible to combine existing or new input types to unions freely and with ease.
396+ Adding an input to one or more unions should not require extraneous changes, constrain or be constrained by schema design.
397+
398+ | [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
399+ | ----| ----| ----| ----| ----|
400+ | ✅️ | 🚫️ | ❔ | 🚫 | ✅ |
401+
402+ Criteria score: 🥇
403+
393404# 🚧 Possible Solutions
394405
395406The community has imagined a variety of possible solutions, synthesized here.
@@ -469,6 +480,8 @@ type Mutation {
469480 * 🚫 Parsers will not recognize the `inputunion` keyword
470481* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
471482 * ❔ Not evaluated
483+ * [O. Unconstrained combination of input types to unions][criteria-o]
484+ * ✅ Adding or removing an input type to a union has no extraneous effects on schema design
472485
473486## 💡 2. Explicit configurable Discriminator field
474487
@@ -555,6 +568,7 @@ inputunion AnimalInput @discriminator(field: "species") =
555568 * ✅ Data structures can mirror eachother.
556569* [ C. Doesn't inhibit schema evolution] [ criteria-c ]
557570 * ✅ Discriminator is explicit.
571+ * ⚠️ Adding an existing input type to an input union requires it to add the non-null discriminator field
558572* [ D. Any member type restrictions are validated in schema] [ criteria-d ]
559573 * ✅ Schema validation can check that all members of the input union have the discriminator field
560574* [ E. A member type may be a Leaf type] [ criteria-e ]
@@ -576,6 +590,10 @@ inputunion AnimalInput @discriminator(field: "species") =
576590 * 🚫 Parsers will not recognize the ` inputunion ` keyword
577591* [ N. Existing code generated tooling is backwards compatible with Introspection additions] [ criteria-n ]
578592 * ❔ Not evaluated
593+ * [ O. Unconstrained combination of input types to unions] [ criteria-o ]
594+ * 🚫 Adding an input type to a union requires that it has the non-null discriminator field
595+ * The input might already have a field with the same name, but a different type
596+ * Reusing input types in multiple input unions can become unwieldy
579597
580598## 💡 3. Order based discrimination
581599
@@ -663,6 +681,8 @@ type Mutation {
663681 * 🚫 Parsers will not recognize the `inputunion` keyword
664682* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
665683 * ❔ Not evaluated
684+ * [O. Unconstrained combination of input types to unions][criteria-o]
685+ * ❔ Not evaluated
666686
667687## 💡 4. Structural uniqueness
668688
@@ -733,6 +753,7 @@ input DogInput {
733753 * ⚠️ Restrictions on required fields may prevent matching output types
734754* [C . Doesn 't inhibit schema evolution][criteria-c]
735755 * ⚠️ Inputs may be forced to include extraneous fields to ensure uniqueness.
756+ * ⚠️ Making a field nullable may be impossible without losing uniqueness
736757* [D. Any member type restrictions are validated in schema][criteria-d]
737758 * ✅ A "uniqueness" algorithm must be applied during schema validation
738759* [E. A member type may be a Leaf type][criteria-e]
@@ -753,6 +774,8 @@ input DogInput {
753774 * 🚫 Parsers will not recognize the `inputunion` keyword
754775* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
755776 * ❔ Not evaluated
777+ * [O. Unconstrained combination of input types to unions][criteria-o]
778+ * 🚫 Input types with similar fields may not be able to be combined without breaking changes
756779
757780## 💡 5. One Of (Tagged Union)
758781
@@ -827,6 +850,8 @@ type Mutation {
827850 * ✅ Proposal uses a simple directive ; directive parsing is widely supported
828851* [N . Existing code generated tooling is backwards compatible with Introspection additions ][criteria -n ]
829852 * ✅ Existing code generation tools will degrade gracefully to a regular input object
853+ * [O . Unconstrained combination of input types to unions ][criteria -o ]
854+ * ✅ Adding or removing input types to a tagged union requires no extraneous effort
830855
831856### Summary of spec changes
832857
@@ -857,6 +882,7 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
857882| [L ][criteria -l ] 🥉 | ❔ | ❔ | ❔ | ❔ | ✅ |
858883| [M ][criteria -m ] 🥈 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ |
859884| [N ][criteria -n ] 🥈 | ❔ | ❔ | ❔ | ❔ | ✅ |
885+ | [O ][criteria -o ] 🥈 | ✅️ | 🚫️ | ❔ | 🚫 | ✅ |
860886
861887[criteria -a ]: #-a-graphql-should-contain-a-polymorphic-input-type
862888[criteria -b ]: #-b-input-polymorphism-matches-output-polymorphism
@@ -872,6 +898,7 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
872898[criteria -l ]: #-l-input-unions-should-be-performant-for-servers
873899[criteria -m ]: #-m-existing-sdl-parsers-are-backwards-compatible-with-sdl-additions
874900[criteria -n ]: #-n-existing-code-generated-tooling-is-backwards-compatible-with-introspection-additions
901+ [criteria -o ]: #-o-unconstrained-combination-of-input-types-to-unions
875902
876903[solution -1]: #-1-explicit-__typename-discriminator-field
877904[solution -2]: #-2-explicit-configurable-discriminator-field
0 commit comments