@@ -231,7 +231,7 @@ Adding a new member type to an Input Union or doing any non-breaking change to e
231
231
232
232
| [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
233
233
| ----| ----| ----| ----| ----|
234
- | ✅ | ⚠ | 🚫 | ⚠️ | ✅ |
234
+ | ✅ | ✅⚠️ | 🚫 | ⚠️ | ✅ |
235
235
236
236
Criteria score: 🥇
237
237
@@ -325,7 +325,7 @@ input union IU = { x: String } | { y: Int }
325
325
326
326
| [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
327
327
| ----| ----| ----| ----| ----|
328
- | ✅⚠️ | ✅⚠️ | ✅ | ⚠️ | ✅ |
328
+ | ✅ | ✅ | ✅ | ⚠️ | ✅ |
329
329
330
330
Criteria score: 🥉
331
331
@@ -350,20 +350,17 @@ The less typing and fewer bytes transmitted, the better.
350
350
351
351
| [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
352
352
| ----| ----| ----| ----| ----|
353
- | ✅ | ✅ | ✅ | ✅ | ✅ |
353
+ | ✅ | ⚠️ | ✅ | ✅ | ✅ |
354
354
355
355
Criteria score: 🥉
356
356
357
357
## 🎯 L. Input unions should be performant for servers
358
358
359
359
Ideally a server does not have to do much computation to determine which concrete type is represented by an input.
360
360
361
- * ✂️ Objection: None of the solutions discussed so far do anything that is computationally expensive.
362
-
363
361
| [ 1] [ solution-1 ] | [ 2] [ solution-2 ] | [ 3] [ solution-3 ] | [ 4] [ solution-4 ] | [ 5] [ solution-5 ] |
364
362
| ----| ----| ----| ----| ----|
365
- | ✅ | ✅ | ✅⚠️ | ✅⚠️ | ✅ |
366
- | O(1) | O(1) | O(N of members) | O(N of members) | O(1) |
363
+ | ✅ | ✅ | ⚠️ | ⚠️ | ✅ |
367
364
368
365
Criteria score: 🥉
369
366
@@ -473,13 +470,14 @@ type Mutation {
473
470
* [J. A GraphQL schema that supports input unions can be queried by older GraphQL clients][criteria-j]
474
471
* ✅ Changes are additive only
475
472
* [K. Input unions should be expressed efficiently in the query and on the wire][criteria-k]
476
- * ❔ Not evaluated
473
+ * ✅ Discriminator field only needed when used in union
474
+ * ✅ Compresses well, as the field name is always the same
477
475
* [L. Input unions should be performant for servers][criteria-l]
478
- * ❔ Not evaluated
476
+ * ✅ O(1)
479
477
* [M. Existing SDL parsers are backwards compatible with SDL additions][criteria-m]
480
478
* 🚫 Parsers will not recognize the `inputunion` keyword
481
479
* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
482
- * ❔ Not evaluated
480
+ * ✅⚠️
483
481
* [O. Unconstrained combination of input types to unions][criteria-o]
484
482
* ✅ Adding or removing an input type to a union has no extraneous effects on schema design
485
483
@@ -583,13 +581,13 @@ inputunion AnimalInput @discriminator(field: "species") =
583
581
* [ J. A GraphQL schema that supports input unions can be queried by older GraphQL clients] [ criteria-j ]
584
582
* ✅ Changes are additive only
585
583
* [ K. Input unions should be expressed efficiently in the query and on the wire] [ criteria-k ]
586
- * ❔ Not evaluated
584
+ * ⚠️ Input types that are part of an input union always have to contain the non-null discriminator
587
585
* [ L. Input unions should be performant for servers] [ criteria-l ]
588
- * ❔ Not evaluated
586
+ * ✅ O(1)
589
587
* [ M. Existing SDL parsers are backwards compatible with SDL additions] [ criteria-m ]
590
588
* 🚫 Parsers will not recognize the ` inputunion ` keyword
591
589
* [ N. Existing code generated tooling is backwards compatible with Introspection additions] [ criteria-n ]
592
- * ❔ Not evaluated
590
+ * ✅⚠️
593
591
* [ O. Unconstrained combination of input types to unions] [ criteria-o ]
594
592
* 🚫 Adding an input type to a union requires that it has the non-null discriminator field
595
593
* The input might already have a field with the same name, but a different type
@@ -674,13 +672,13 @@ type Mutation {
674
672
* [J. A GraphQL schema that supports input unions can be queried by older GraphQL clients][criteria-j]
675
673
* ✅ Changes are additive only
676
674
* [K. Input unions should be expressed efficiently in the query and on the wire][criteria-k]
677
- * ❔ Not evaluated
675
+ * ✅ No overhead
678
676
* [L. Input unions should be performant for servers][criteria-l]
679
- * ❔ Not evaluated
677
+ * ⚠️ O(N of members)
680
678
* [M. Existing SDL parsers are backwards compatible with SDL additions][criteria-m]
681
679
* 🚫 Parsers will not recognize the `inputunion` keyword
682
680
* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
683
- * ❔ Not evaluated
681
+ * ✅⚠️
684
682
* [O. Unconstrained combination of input types to unions][criteria-o]
685
683
* ❔ Not evaluated
686
684
@@ -767,13 +765,13 @@ input DogInput {
767
765
* [J. A GraphQL schema that supports input unions can be queried by older GraphQL clients][criteria-j]
768
766
* ✅ Changes are additive only
769
767
* [K. Input unions should be expressed efficiently in the query and on the wire][criteria-k]
770
- * ❔ Not evaluated
768
+ * ✅ No overhead
771
769
* [L. Input unions should be performant for servers][criteria-l]
772
- * ❔ Not evaluated
770
+ * ⚠️ O(N of members)
773
771
* [M. Existing SDL parsers are backwards compatible with SDL additions][criteria-m]
774
772
* 🚫 Parsers will not recognize the `inputunion` keyword
775
773
* [N. Existing code generated tooling is backwards compatible with Introspection additions][criteria-n]
776
- * ❔ Not evaluated
774
+ * ✅⚠️
777
775
* [O. Unconstrained combination of input types to unions][criteria-o]
778
776
* 🚫 Input types with similar fields may not be able to be combined without breaking changes
779
777
@@ -870,18 +868,18 @@ A quick glance at the evaluation results. Remember that passing or failing a spe
870
868
| -- | -- | -- | -- | -- | -- |
871
869
| [A ][criteria -a ] 🥇 | ✅ | ✅ | ✅ | ✅ | ✅ |
872
870
| [B ][criteria -b ] 🥇 | ✅⚠️ | ✅ | ✅ | ✅⚠️ | 🚫 |
873
- | [C ][criteria -c ] 🥇 | ✅ | ✅ | 🚫 | ⚠️ | ✅ |
871
+ | [C ][criteria -c ] 🥇 | ✅ | ✅⚠️ | 🚫 | ⚠️ | ✅ |
874
872
| [D ][criteria -d ] 🥇 | ✅ | ✅ | ✅ | ✅ | ✅ |
875
873
| [E ][criteria -e ] 🥉 | 🚫 | 🚫 | ✅⚠️ | 🚫 | ✅ |
876
874
| [F ][criteria -f ] 🥉 | ✅⚠️ | ✅⚠️ | ✅ | ⚠️ | ✅ |
877
875
| [G ][criteria -g ] 🥉 | ❔ | ❔ | ❔ | ❔ | ❔ |
878
876
| [H ][criteria -h ] 🥉 | ⚠️ | ⚠️ | ✅ | ✅ | ⚠️ |
879
- | [I ][criteria -i ] 🥉 | ✅⚠️ | ✅⚠️ | ✅ | ⚠️ | ✅ |
877
+ | [I ][criteria -i ] 🥉 | ✅ | ✅ | ✅ | ⚠️ | ✅ |
880
878
| [J ][criteria -j ] 🥇 | ✅ | ✅ | ✅ | ✅ | ✅ |
881
- | [K ][criteria -k ] 🥉 | ❔ | ❔ | ❔ | ❔ | ✅ |
882
- | [L ][criteria -l ] 🥉 | ❔ | ❔ | ❔ | ❔ | ✅ |
879
+ | [K ][criteria -k ] 🥉 | ✅ | ⚠️ | ✅ | ✅ | ✅ |
880
+ | [L ][criteria -l ] 🥉 | ✅ | ✅ | ⚠️ | ⚠️ | ✅ |
883
881
| [M ][criteria -m ] 🥈 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ |
884
- | [N ][criteria -n ] 🥈 | ❔ | ❔ | ❔ | ❔ | ✅ |
882
+ | [N ][criteria -n ] 🥈 | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅ |
885
883
| [O ][criteria -o ] 🥈 | ✅️ | 🚫️ | ❔ | 🚫 | ✅ |
886
884
887
885
[criteria -a ]: #-a-graphql-should-contain-a-polymorphic-input-type
0 commit comments