Skip to content

Commit a1c1348

Browse files
authored
Adding notes and updates from live discussion
1 parent dca1655 commit a1c1348

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

rfcs/InputUnion.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ Criteria score: 🥉
261261

262262
Since the input object type is now a member of the input union, existing input objects being sent through should remain valid.
263263

264+
Example: Relay Mutation
265+
266+
```graphql
267+
# From
268+
input I { x: String }
269+
# To (pseudocode)
270+
input union IU = I | { y: Int }
271+
```
272+
264273
* ✂️ 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.
265274
* ✂️ 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.
266275

@@ -280,12 +289,14 @@ To ease development.
280289
|----|----|----|----|----|
281290
||||||
282291

283-
Criteria score: 🥉
292+
Criteria score: X (not considered)
284293

285294
## 🎯 H. Input unions should accept plain data
286295

287296
Clients should be able to pass "natural" input data to unions without specially formatting it or adding extra metadata.
288297

298+
In other words: data should require minimal or no transformation and metadata over the wire
299+
289300
* ✂️ Objection: This is a matter of taste - legitimate [Prior Art](#-prior-art) exists that require formatting / extra metadata.
290301

291302
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
@@ -300,7 +311,15 @@ Many people in the wild are solving the need for input unions with validation at
300311

301312
Note: This criteria is similar to [F. Migrating a field to a polymorphic input type is non-breaking][criteria-f]
302313

314+
```graphql
315+
# From
316+
input I { x: String, y: Int }
317+
# To (pseudocode)
318+
input union IU = { x: String } | { y: Int }
319+
```
320+
303321
* ✂️ 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
304323

305324
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
306325
|----|----|----|----|----|
@@ -322,12 +341,14 @@ Criteria score: 🥇
322341

323342
The less typing and fewer bytes transmitted, the better.
324343

344+
(Not Related to B/H)
345+
325346
* ✂️ Objection: The quantity of "typing" isn't a worthwhile metric, most interactions with an API are programmatic.
326347
* ✂️ Objection: Simply compressing an HTTP request will reduce the bytes transmitted more than anything having to do with the structure of a Schema.
327348

328349
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
329350
|----|----|----|----|----|
330-
| | | | ||
351+
| | | | ||
331352

332353
Criteria score: 🥉
333354

@@ -339,27 +360,31 @@ Ideally a server does not have to do much computation to determine which concret
339360

340361
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
341362
|----|----|----|----|----|
342-
||||||
363+
||| ✅⚠️ | ✅⚠️ ||
364+
| O(1) | O(1) | O(N of members) | O(N of members) | O(1) |
343365

344366
Criteria score: 🥉
345367

346368
## 🎯 M. Existing SDL parsers are backwards compatible with SDL additions
347369

348370
Common tools that parse GraphQL SDL should not fail when pointed at a schema which supports polymorphic input types.
349371

372+
* ✂️ Objection: Evolution of the SDL is expected with new features.
373+
* ✂️ Objection: SDL syntax error can be a positive as a "fail fast" if a system doesn't know about input unions.
374+
350375
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
351376
|----|----|----|----|----|
352377
| 🚫 | 🚫 | 🚫 | 🚫 ||
353378

354-
Criteria score: 🥈
379+
Criteria score: X (rejected)
355380

356381
## 🎯 N. Existing code generated tooling is backwards compatible with Introspection additions
357382

358383
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.
359384

360385
| [1][solution-1] | [2][solution-2] | [3][solution-3] | [4][solution-4] | [5][solution-5] |
361386
|----|----|----|----|----|
362-
| | | | ||
387+
| ✅⚠️ | ✅⚠️ | ✅⚠️ | ✅⚠️ ||
363388

364389
Criteria score: 🥈
365390

0 commit comments

Comments
 (0)