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
+63-23Lines changed: 63 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,6 +192,12 @@ Solutions are evaluated and scored using a simple 3 part scale. A solution may h
192
192
193
193
Passing or failing a specific criteria is NOT the final word. Both the Criteria _and_ the Solutions are up for debate.
194
194
195
+
Criteria have been given a "score" according to their relative importance in solving the problem laid out in this RFC while adhering to the GraphQL Spec Guiding Principles. The scores are:
196
+
197
+
* 🥇 Gold - A must-have
198
+
* 🥈 Silver - A nice-to-have
199
+
* 🥉 Bronze - Not necessary
200
+
195
201
## 🎯 A. GraphQL should contain a polymorphic Input type
196
202
197
203
The premise of this RFC - GraphQL should contain a polymorphic Input type.
@@ -200,6 +206,8 @@ The premise of this RFC - GraphQL should contain a polymorphic Input type.
200
206
|----|----|----|----|----|
201
207
| ✅ | ✅ | ✅ | ✅ | ⚠️ |
202
208
209
+
Criteria score: 🥇
210
+
203
211
## 🎯 B. Input polymorphism matches output polymorphism
204
212
205
213
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.
@@ -210,6 +218,8 @@ Any data structure that can be modeled with output type polymorphism should be a
210
218
|----|----|----|----|----|
211
219
| ✅⚠️ | ✅ | ✅ | ✅⚠️ | 🚫 |
212
220
221
+
Criteria score: 🥇
222
+
213
223
## 🎯 C. Doesn't inhibit schema evolution
214
224
215
225
The GraphQL specification mentions the ability to evolve your schema as one of its core values:
@@ -221,6 +231,8 @@ Adding a new member type to an Input Union or doing any non-breaking change to e
221
231
|----|----|----|----|----|
222
232
| ✅ | ✅ | 🚫 | ⚠️ | ✅ |
223
233
234
+
Criteria score: 🥇
235
+
224
236
## 🎯 D. Any member type restrictions are validated in schema
225
237
226
238
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).
@@ -229,6 +241,8 @@ If a solution places any restrictions on member types, compliance with these res
229
241
|----|----|----|----|----|
230
242
| ✅ | ✅ | ✅ | ✅ | ✅ |
231
243
244
+
Criteria score: 🥇
245
+
232
246
## 🎯 E. A member type may be a Leaf type
233
247
234
248
In addition to containing Input types, member type may also contain Leaf types like `Scalar`s or `Enum`s.
@@ -241,6 +255,8 @@ In addition to containing Input types, member type may also contain Leaf types l
241
255
|----|----|----|----|----|
242
256
| 🚫 | 🚫 | ✅⚠️ | 🚫 | ✅ |
243
257
258
+
Criteria score: 🥉
259
+
244
260
## 🎯 F. Migrating a field to a polymorphic input type is non-breaking
245
261
246
262
Since the input object type is now a member of the input union, existing input objects being sent through should remain valid.
@@ -252,6 +268,8 @@ Since the input object type is now a member of the input union, existing input o
252
268
|----|----|----|----|----|
253
269
| ✅⚠️ | ✅⚠️ | ✅ | ⚠️ | ✅ |
254
270
271
+
Criteria score: 🥉
272
+
255
273
## 🎯 G. Input unions may include other input unions
256
274
257
275
To ease development.
@@ -262,6 +280,8 @@ To ease development.
262
280
|----|----|----|----|----|
263
281
| ❔ | ❔ | ❔ | ❔ | ❔ |
264
282
283
+
Criteria score: 🥉
284
+
265
285
## 🎯 H. Input unions should accept plain data
266
286
267
287
Clients should be able to pass "natural" input data to unions without specially formatting it or adding extra metadata.
@@ -272,6 +292,8 @@ Clients should be able to pass "natural" input data to unions without specially
272
292
|----|----|----|----|----|
273
293
| ⚠️ | ⚠️ | ✅ | ✅ | ⚠️ |
274
294
295
+
Criteria score: 🥈
296
+
275
297
## 🎯 I. Input unions should be easy to upgrade from existing solutions
276
298
277
299
Many people in the wild are solving the need for input unions with validation at run-time (e.g. using the "tagged union" pattern). Formalising support for these existing patterns in a non-breaking way would enable existing schemas to become retroactively more type-safe.
@@ -284,14 +306,18 @@ Note: This criteria is similar to [F. Migrating a field to a polymorphic input
284
306
|----|----|----|----|----|
285
307
| ✅⚠️ | ✅⚠️ | ✅ | ⚠️ | ✅ |
286
308
309
+
Criteria score: 🥉
310
+
287
311
## 🎯 J. A GraphQL schema that supports input unions can be queried by older GraphQL clients
288
312
289
-
Preferably without a loss of or change in functionality.
313
+
Preferably without a loss of or change in previously supported functionality.
0 commit comments