Skip to content

Commit 40b8d63

Browse files
authored
Input Union: Expand Prior Art section (#641)
* Expand Prior Art section * Criteria wording * title
1 parent e2a1132 commit 40b8d63

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

rfcs/InputUnion.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,38 @@ 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+
132+
## Prior Art
133+
134+
Many other technologies provide polymorphic types, and have done so using a variety of techniques.
135+
136+
Tech | Type | Read | Write
137+
---- | -------- | ---- | -----
138+
GraphQL | [Union](https://graphql.github.io/graphql-spec/June2018/#sec-Unions) | ✅ | ❌
139+
Protocol Buffers | [Oneof](https://developers.google.com/protocol-buffers/docs/proto3#oneof) | ✅ | ✅
140+
FlatBuffers | [Union](https://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html) | ✅ | ✅
141+
Cap'n Proto | [Union](https://capnproto.org/language.html#unions) | ✅ | ✅
142+
Thrift | [Union](https://thrift.apache.org/docs/idl#union) | ✅ | ✅
143+
Arvo | [Union](https://avro.apache.org/docs/current/spec.html#Unions) | ✅ | ✅
144+
OpenAPI 3 | [oneOf](https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/) | ✅ | ✅
145+
JSON Schema | [oneOf](https://json-schema.org/understanding-json-schema/reference/combining.html#oneof) | ✅ | ✅
146+
Typescript | [Union](http://www.typescriptlang.org/docs/handbook/advanced-types.html#union-types) | ✅ | ✅
147+
Typescript | [Discriminated Union](http://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions) | ✅ | ✅
148+
Rust | [Enum](https://doc.rust-lang.org/rust-by-example/custom_types/enum.html) | ✅ | ✅
149+
Swift | [Enumeration](https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html) | ✅ | ✅
150+
Haskell | [Algebraic data types](http://learnyouahaskell.com/making-our-own-types-and-typeclasses) | ✅ | ✅
151+
152+
The topic has also been extensively explored in Computer Science more generally.
153+
154+
* [Wikipedia: Algebraic data type](https://en.wikipedia.org/wiki/Algebraic_data_type)
155+
* [Wikipedia: Union type](https://en.wikipedia.org/wiki/Union_type)
156+
* [Wikipedia: Tagged Union](https://en.wikipedia.org/wiki/Tagged_union)
157+
* [C2 Wiki: Nominative And Structural Typing](http://wiki.c2.com/?NominativeAndStructuralTyping)
158+
159+
131160
## Solution Criteria
132161

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:
162+
This section sketches out the potential 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:
134163

135164
* Backwards compatibility
136165
* Performance is a feature
@@ -212,12 +241,6 @@ There have been a variety of use cases described by users asking for an abstract
212241
* [Observability Cloud Integrations](https://gist.github.com/binaryseed/f2dd63d1a1406124be70c17e2e796891#cloud-integrations)
213242
* [Observability Dashboards](https://gist.github.com/binaryseed/f2dd63d1a1406124be70c17e2e796891#dashboards)
214243

215-
## Prior art
216-
217-
Other technologies/languages also faced the same problems and there things we can learn from them:
218-
219-
* [Wiki article on Tagged_union](https://en.wikipedia.org/wiki/Tagged_union)
220-
* [gRPC Oneof](https://developers.google.com/protocol-buffers/docs/proto3#oneof)
221244

222245
## Possible Solutions
223246

0 commit comments

Comments
 (0)