@@ -512,6 +512,17 @@ The community has imagined a variety of possible solutions, synthesized here.
512
512
Each solution is identified with a ` Number ` so they can be referenced in the
513
513
rest of the document. New solutions must be added to the end of the list.
514
514
515
+ Semantic nullability is only relevant to output positions, so when comparing
516
+ syntax we will look for changes versus the current syntax used to represent
517
+ these types:
518
+
519
+ | | Input syntax | Output syntax |
520
+ | ------------------------- | ------------ | ------------- |
521
+ | Semantically nullable | ` Int ` | ` Int ` |
522
+ | Semantically non-nullable | - | ` Int ` |
523
+ | Strictly non-nullable | ` Int! ` | ` Int! ` |
524
+
525
+
515
526
## 💡 1. New "Semantic Non-Null" type, represented by ` * `
516
527
517
528
[ solution-1 ] : #-1-new-semantic-non-null-type-represented-by-
@@ -545,11 +556,11 @@ type Post {
545
556
546
557
Querying a semantic non -null field is the same as querying any other field .
547
558
548
- | | Existing syntax | Proposed syntax |
549
- | ------------------------- | --------------- | --------------- |
550
- | Semantically nullable | `Int ` | `Int ` |
551
- | Semantically non -nullable | - | `Int *` |
552
- | Strictly non -nullable | `Int !` | `Int !` |
559
+ | | Input syntax | Output syntax |
560
+ | ------------------------- | --------------- | ------------------- |
561
+ | Semantically nullable | `Int ` | `Int ` |
562
+ | Semantically non -nullable | - | `Int ` & rArr ; ` Int *` |
563
+ | Strictly non -nullable | `Int !` | `Int !` |
553
564
554
565
### 🎲 Variations
555
566
@@ -606,11 +617,11 @@ in schemas using this directive would now be semantically non-nullable by
606
617
default, and a new semantically nullable type is introduced (using the `?`
607
618
symbol) to indicate that a position may semantically be null.
608
619
609
- | | Existing syntax | Proposed syntax |
610
- | ------------------------- | --------------- | --------------- |
611
- | Semantically nullable | `Int` | `Int?` |
612
- | Semantically non-nullable | - | `Int` |
613
- | Strictly non-nullable | `Int!` | `Int!` |
620
+ | | Input syntax | Output syntax |
621
+ | ------------------------- | -------------------- | ---- --------------- |
622
+ | Semantically nullable | `Int` ⇒ ??? | `Int` ⇒ `Int?` |
623
+ | Semantically non-nullable | - | `Int` |
624
+ | Strictly non-nullable | `Int!` ⇒ ??? | `Int!` |
614
625
615
626
### ⚖️ Evaluation
616
627
@@ -661,23 +672,26 @@ symbol) to indicate that a position may semantically be null.
661
672
662
673
This proposal is similar to proposal 1, but :
663
674
664
- 1. It introduces a document -level directive , `@semanticNullability `, which when
665
- present on a document allows the `!` suffix to be used to represent
666
- semantically non -nullable types , and a new `!!` suffix to be used to
667
- represent strictly non -nullable types :
675
+ It introduces a document -level directive , `@semanticNullability `, which when
676
+ present on a document allows the `!` suffix to be used to represent
677
+ semantically non -nullable output types , and a new `!!` suffix to be used to
678
+ represent strictly non -nullable output types .
679
+
680
+ The `Int !` syntax simply means "non-nullable" on input , as it always has .
681
+ (Note : input types are always either semantically nullable or strictly
682
+ non -nullable .)
668
683
669
- | | Syntax without directive | Syntax with directive |
670
- | ------------------------- | ------------------------ | --------------------- |
671
- | Semantically nullable | `Int ` | `Int ` |
672
- | Semantically non -nullable | - | `Int !` |
673
- | Strictly non -nullable | `Int !` | `Int !!` |
684
+ Syntax only changes when `@semanticNullability ` directive is present :
674
685
675
- As such all documents (both SDL and executable documents) retain their current
676
- meaning , and the semantically non -null type can be adopted on a per -document
677
- basis .
686
+ | | Input syntax | Output syntax |
687
+ | ------------------------- | ------------ | --------------------- |
688
+ | Semantically nullable | `Int ` | `Int ` |
689
+ | Semantically non -nullable | - | `Int ` &rArr ; `Int !` |
690
+ | Strictly non -nullable | `Int !` | `Int !` &rArr ; `Int !!` |
678
691
679
- 2. It allows using semantically non -nullable types in input positions , allowing
680
- the `Int !` syntax to simply mean "non-nullable" on input .
692
+ All documents (both SDL and executable documents) retain their current meaning ,
693
+ and the semantically non -null type can be adopted in output positions on a
694
+ per -document basis by adding the document directive .
681
695
682
696
Since there 's no difference between whether a type is "semantically" or
683
697
"strictly" non -nullable on input (input does not represent errors), executable
@@ -752,11 +766,14 @@ This proposal builds on solution 3, but with a syntactic shuffle such that the
752
766
unadorned type may be used as the semantically non-nullable type when the
753
767
directive is present, and a `?` symbol is used to indicate a nullable position.
754
768
755
- | | Syntax without directive | Syntax with directive |
756
- | ------------------------- | ------------------------ | --------------------- |
757
- | Semantically nullable | `Int` | `Int?` |
758
- | Semantically non-nullable | - | `Int` |
759
- | Strictly non-nullable | `Int!` | `Int!` |
769
+ Syntax only changes when `@semanticNullability ` directive is present:
770
+
771
+ | | Input syntax | Output syntax |
772
+ | ------------------------- | ------------------- | ------------------- |
773
+ | Semantically nullable | `Int` ⇒ `Int?` | `Int` ⇒ `Int?` |
774
+ | Semantically non-nullable | - | `Int` |
775
+ | Strictly non-nullable | `Int!` ⇒ `Int` | `Int!` |
776
+
760
777
761
778
### ⚖️ Evaluation
762
779
@@ -810,6 +827,12 @@ directive is present, and a `?` symbol is used to indicate a nullable position.
810
827
811
828
This proposal relies on the ability of clients to opt out of error propagation; instead of introducing a new type it instructs schema authors to optimize for error-handling clients and use the traditional non-null type (`!`) on all semantically non-null fields.
812
829
830
+ | | Input syntax | Output syntax |
831
+ | ------------------------- | ------------ | ------------------- |
832
+ | Semantically nullable | `Int` | `Int` |
833
+ | Semantically non-nullable | - | `Int` ⇒ `Int!` |
834
+ | Strictly non-nullable | `Int!` | `Int!` |
835
+
813
836
### ⚖️ Evaluation
814
837
815
838
- [A][criteria-a]
0 commit comments