diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6a6eda..7272beaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add `Environment.findAllConnectionIds` for finding all IDs of all connection instances for a specific connection, regardless of what configs that connection has been fetched (and cached) with. - Add `RecordSourceSelectorProxy.invalidateRecordsByIds` for invalidating multilple records at the same time. +- Allow configuring input unions via `inputUnions` in `relay.config.js` as an escape hatch for when `@oneOf` support on your server is tricky to set up. # 3.0.0 stable diff --git a/packages/relay b/packages/relay index 686d7a39..1b2d5616 160000 --- a/packages/relay +++ b/packages/relay @@ -1 +1 @@ -Subproject commit 686d7a399bae3f8da73553ccd71ac23eb341ab6a +Subproject commit 1b2d5616cdbccf3d6244806888070f3866d31e97 diff --git a/rescript-relay-documentation/docs/input-unions.md b/rescript-relay-documentation/docs/input-unions.md index 6cd549cf..64a9f348 100644 --- a/rescript-relay-documentation/docs/input-unions.md +++ b/rescript-relay-documentation/docs/input-unions.md @@ -72,6 +72,21 @@ let make = (~shopLocationId) => { This brings all of the power of variants also to inputs. +### Input unions without server support + +If you for some reason cannot setup `@oneOf` on your server, but still have input objects in the schema you'd like to use as input unions, you can configure those input objects to be treated as input unions by adding the name of them to `inputUnions` in `relay.config.js`: + +```js title="relay.config.js" +module.exports = { + src: "./src", + schema: "./schema.graphql", + artifactDirectory: "./src/__generated__", + inputUnions: ["SomeInputObjectName", "AnotherInputObjectName"], +}; +``` + +The compiler will check that the input object is elgible to use as input union (all fields are optional) but outside of that, all bets are off. This is an escape hatch and should be treated as such. Prefer to use real support via `@oneOf` on your server as much as possible. + ## Summary Here's all you need to remember about input unions in RescriptRelay: