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
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,6 +261,15 @@ Criteria score: 🥉
261
261
262
262
Since the input object type is now a member of the input union, existing input objects being sent through should remain valid.
263
263
264
+
Example: Relay Mutation
265
+
266
+
```graphql
267
+
# From
268
+
inputI { x: String }
269
+
# To (pseudocode)
270
+
inputunionIU = I | { y: Int }
271
+
```
272
+
264
273
* ✂️ Objection: achieving this by indicating the default in the union (either explicitly or implicitly via the order) is undesirable as it may require multiple equivalent unions being created where only the default differs.
265
274
* ✂️ Objection: Numerous changes to a schema currently introduce breaking changes. The possibility of a breaking change isn't a breaking change and shouldn't prevent a polymorphic input type from existing.
266
275
@@ -280,12 +289,14 @@ To ease development.
280
289
|----|----|----|----|----|
281
290
| ❔ | ❔ | ❔ | ❔ | ❔ |
282
291
283
-
Criteria score: 🥉
292
+
Criteria score: X (not considered)
284
293
285
294
## 🎯 H. Input unions should accept plain data
286
295
287
296
Clients should be able to pass "natural" input data to unions without specially formatting it or adding extra metadata.
288
297
298
+
In other words: data should require minimal or no transformation and metadata over the wire
299
+
289
300
* ✂️ Objection: This is a matter of taste - legitimate [Prior Art](#-prior-art) exists that require formatting / extra metadata.
@@ -300,7 +311,15 @@ Many people in the wild are solving the need for input unions with validation at
300
311
301
312
Note: This criteria is similar to [F. Migrating a field to a polymorphic input type is non-breaking][criteria-f]
302
313
314
+
```graphql
315
+
# From
316
+
inputI { x: String, y: Int }
317
+
# To (pseudocode)
318
+
inputunionIU = { x: String } | { y: Int }
319
+
```
320
+
303
321
* ✂️ Objection: The addition of a polymorphic input type shouldn't depend on the ability to change the type of an existing field or an existing usage pattern. One can always add new fields that leverage new features.
322
+
* ✂️ Objection: May break variable names? Only avoided with care
## 🎯 N. Existing code generated tooling is backwards compatible with Introspection additions
357
382
358
383
For example, GraphiQL should successfully render when pointed at a schema which contains polymorphic input types. It should continue to function even if it can't support the polymorphic input type.
0 commit comments