You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/InputUnion.md
+34-5Lines changed: 34 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ RFC: GraphQL Input Union
3
3
4
4
The addition of an Input Union type has been discussed in the GraphQL community for many years now. The value of this feature has largely been agreed upon, but the implementation has not.
5
5
6
-
This document attempts to bring together all the various solutions that have been discussed with the goal of reaching a shared understanding of the problem space.
6
+
This document attempts to bring together all the various solutions and perspectives that have been discussed with the goal of reaching a shared understanding of the problem space.
7
7
8
-
From that shared understanding, this document can then evolve into a proposed solution.
8
+
From that shared understanding, the GraphQL Working Group aims to reach a consensus on how to address the proposal.
9
9
10
10
### Contributing
11
11
@@ -128,11 +128,40 @@ In this mutation, we encounter the main challenge of the **Input Union** - we ne
128
128
129
129
A wide variety of solutions have been explored by the community, and they are outlined in detail in this document under [Possible Solutions](#Possible-Solutions).
130
130
131
-
## Requirements
131
+
## Solution Criteria
132
132
133
-
1.**Doesn't inhibit [schema evolution](https://graphql.github.io/graphql-spec/draft/#sec-Validation.Type-system-evolution)** ─ adding a new member type to an Input Union or doing any non-breaking change to existing member types must not result in breaking change. For example, adding a new optional field to member type or changing a field from non-nullable to nullable must not break previously valid client operations.
133
+
Hypothetical goals that a solution might attempt to fulfill. These goals will be evaluated with the [GraphQL Spec Guiding Principles](https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md#guiding-principles)in mind:
134
134
135
-
**Note**: Input Unions may enforce some restrictions on member types, but if they do so compliance with these restrictions must be fully validated during schema building (analagous to how interfaces enforce restrictions on member types).
135
+
* Backwards compatibility
136
+
* Performance is a feature
137
+
* Favor no change
138
+
* Enable new capabilities motivated by real use cases
139
+
* Simplicity and consistency over expressiveness and terseness
140
+
* Preserve option value
141
+
* Understandability is just as important as correctness
142
+
143
+
### GraphQL should contain a polymorphic Input type
144
+
145
+
The premise of this RFC - GraphQL should contain a polymorphic Input type.
Any data structure that can be modeled with output type polymorphism should be able to be mirrored with Input polymorphism. Minimal transformation of outputs should be required to send a data structure back as inputs.
Adding a new member type to an Input Union or doing any non-breaking change to existing member types does not result in breaking change. For example, adding a new optional field to member type or changing a field from non-nullable to nullable does not break previously valid client operations.
154
+
155
+
### Any member type restrictions are validated in schema
156
+
157
+
If a solution places any restrictions on member types, compliance with these restrictions should be fully validated during schema building (analagous to how interfaces enforce restrictions on member types).
158
+
159
+
### A member type may be a Leaf type
160
+
161
+
In addition to containing Input types, member type may also contain Leaf types like `Scalar`s or `Enum`s.
162
+
163
+
* Objection: Multiple Leaf types serialize the same way, making it impossible to distinguish the type. For example, a `String`, `ID` and `Enum`.
164
+
* Objection: Output polymorphism is restricted to Object types only. Supporting Leaf types in Input polymorphism would create a new inconsistency.
0 commit comments