Skip to content

Commit

Permalink
allow configuring input unions via config file as an escape hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Aug 11, 2024
1 parent 2463c88 commit e2bf7ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions rescript-relay-documentation/docs/input-unions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e2bf7ac

Please sign in to comment.