Skip to content

Commit b2aca18

Browse files
binaryseedIvanGoncharov
authored andcommitted
Input Union RFC: Move Requirements to "Criteria" (#626)
* Move Requreiments to Aims * Apply suggestions from code review Co-Authored-By: Benjie Gillam <[email protected]> * Feedback - merge leaf, add objection * input matches output * stronger assertion in matching criteria * Reference guiding principles
1 parent 92ad4ca commit b2aca18

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

rfcs/InputUnion.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ RFC: GraphQL Input Union
33

44
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.
55

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.
77

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.
99

1010
### Contributing
1111

@@ -128,11 +128,40 @@ In this mutation, we encounter the main challenge of the **Input Union** - we ne
128128

129129
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).
130130

131-
## Requirements
131+
## Solution Criteria
132132

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:
134134

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.
146+
147+
### Input polymorphism matches output polymorphism
148+
149+
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.
150+
151+
### Doesn't inhibit [schema evolution](https://graphql.github.io/graphql-spec/draft/#sec-Validation.Type-system-evolution)
152+
153+
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.
136165

137166
## Use Cases
138167

0 commit comments

Comments
 (0)