-
Add support for
autoExhaustiveTypesconfig and a@nonExhaustivedirective to control automatic exhaustive checks for unions/interfaces. -
Add React-free mode support and split React APIs into
RescriptRelayReact.- New compiler config:
rescriptRelayMode: "Default" | "NonReact"(defaults to"Default"). - PPX
-non-react - Mark
@rescript/reactandreact-relayas optional peer deps so non‑React usage does not require them.
- New compiler config:
-
BREAKING: Move all React-specific APIs out of
RescriptRelayintoRescriptRelayReact.RescriptRelay.Context.Provider->RescriptRelayReact.Context.ProviderRescriptRelay.useEnvironmentFromContext->RescriptRelayReact.useEnvironmentFromContextRescriptRelay.useSubscribeToInvalidationState->RescriptRelayReact.useSubscribeToInvalidationState
Migration:
- Update imports/usages in app code to reference
RescriptRelayReactfor the APIs listed above. - For non‑React usage, set
rescriptRelayMode: "NonReact"inrelay.config.jsand pass-non-reactto the PPX.
- Support
@exhaustiveon interfaces as well. - Remove
ReactDOMExperimentalmodule, since everything needed is in the official RescriptReact bindings now. - Move fully to ReScript v12. From
4.x, only v12 is supported.
- Build Linux PPX binary in Debian 11 (bullseye) container to improve compatibility with older glibc versions. The binary now requires glibc 2.31 instead of 2.39, supporting Amazon Linux 2023 (Vercel), Ubuntu 20.04+, Debian 11+, and RHEL 9+.
- Move underlying Relay compiler version to
20.1.1.
react-relayandrelay-runtimeto20.1.1
- Add support for
@exhaustive- a directive to trigger exhaustiveness checks for unions at the GraphQL operation level. - BREAKING Drop
__typenamein inline records, since that conflicts with using@tag("__typename")in ReScript v12 and is not necessary since__typenameis set automatically via@tag.
- Add support for top level
@catchon fragments on unions. - Add parameter
excludedIds: array<dataId>toinvalidateRecordsByIdsto allow excluding a list of connection IDs from invalidation. - BREAKING:
operation.textandoperation.idare now nullable, which better reflects what values they can actually have in runtime. - fix bug where custom scalars would error when set to null in refetch variables.
- Add support for the new Relay
@catchdirective. #549 - Add support for
usePrefetchableForwardPagination. #551 - Remove
useBlockingPaginationsince it's being removed from Relay.
This brings the Relay version to 18.2.0.
If you have enabled the feature flags in relay.config.js for aliased fragments or Relay resolvers you'll need to remove them from the config file as they are now on by default, and not removing them will cause the compiler to fail with a non super helpful error message.
- Upgrade versions:
react-relayandrelay-runtimeto18.2.0. - Add support for
Fragment.waitForFragmentData, a new API in Relay 18.2 that lets you wait for fragment data outside of React. - Experimental: Add a "non React" mode to the PPX, which makes sure only APIs that don't rely on React directly are exposed. This is intended to be a way to simplify using RescriptRelay without React. Activate by passing
-non-reactto the PPX, like"ppx-flags": [["rescript-relay/ppx", "-non-react"]].
- Add
Environment.findAllConnectionIdsfor 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.invalidateRecordsByIdsfor invalidating multilple records at the same time. - Allow configuring input unions via
inputUnionsinrelay.config.jsas an escape hatch for when@oneOfsupport on your server is tricky to set up. - Move
@rescript/reactto>=0.13.0.
- Support
@aliasfragments. - Experimental support for
@codesplit, a RescriptRelay exclusive directive that's essentially a client side version of Relay data-driven dependencies (3D). - Remove
ReactExperimentalmodule since all APIs now ship in the official bindings.
- Fix client extension enums mixup with
FutureAddedValue.
- Initial implementation of more advanced Relay resolvers. More to come. #515
- BREAKING: Relay resolvers using fragments should now be exported with a function name that matches the field name for the resolver, and not
defaultlike before. - BREAKING: Client extension enums are now (correctly) not emitted with a
FutureAddedValuecase.
- Fix for not deleting removed artifacts.
- Upgrade versions:
react-relayandrelay-runtimeto17.0.0. - BREAKING: The
customScalarsoption in the Relay config is now calledcustomScalarTypes. - BREAKING:
requiredFieldLoggerin theEnvironmentconfig is now calledrelayFieldLogger.
- Support for Relay
@updatablequeries and fragments (https://relay.dev/docs/guided-tour/updating-data/imperatively-modifying-store-data/#optimistic-updaters-vs-updaters). #501 - Attempt 2: Fix an error in postinstall.js when reinstalling rescript-relay dependency (#493)
- Suppress more false positives for unused things in generated Relay files.
- Set explicit peer dependencies:
@rescript/react >= 0.12.1,react-relay@16.0.0,relay-runtime@16.0.0. - Clean up connection handler generators now that v3 let us use a better representation.
- Fix issue with default args in connection id makers. #488
- Fix issue with PPX not actually converting all functions to uncurried.
- Rename
bsconfig.json->rescript.json. - Fix an error in postinstall.js when reinstalling rescript-relay dependency (#487)
- Fix issue with custom scalars in arrays not being autoconverted properly.
- Depend on ReScript v11 and RescriptReact 0.12.0.
- BREAKING: Use zero cost tagged variants for
RequiredFieldLogger. - Add support for the
relay_resolver.errorevent kind.
- Get rid of functor for creating
loadQuery. - Support for the
@preloadabledirective.
- First RC version.
- Emit
@livefor union variant cases to prevent false positives in unions. - Set
@rescript/toolsversion explicitly. - First class support for input unions, leveraging the
@oneOfdirective.
- Enums in input objects are now (properly) typed as their input variants.
- Single item enums are now not emitted as
@unboxed. - Remove unused fields CLI now properly account for only record fields.
- Use an up-to-date
reanalyzefrom the new@rescript/toolspackage, for powering the CLI.
This brings the supported Relay version to 16.
react-relayandrelay-runtimeto>=16.0.0
Below is a series of releases for version 3 of RescriptRelay, which contain a large amount of breaking changes. The releases are cut up with a few breaking changes for each, to make them slightly less hard to migrate to. You're encouraged to start from the bottom and work your way up through the versions.
Dedicated tooling for migrating is coming, as well as docs.
- Unions are now represented as regular variants. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/3b5df51b80a0e1222b376fcfc730bb5dd0de099a
- All trailing unit arguments are removed. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/2a16791268afb29d106362d0cf17915f69d5b4ff
- Object maker functions are removed, and leverage optional fields for all variables/input objects. Also a large change, tooling upcoming. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/fd6b07a1b26620c91e5de61f930235c35517da6a
- Remove "top level node field" transform. Previously, a single selection on the top level
nodefield (likenode(id: $id) { ... on User { id, name }}) would skip the union mechanism and automatically collapse the generated types tooption<user>. This has now changed and the top level node field behaves just like any union. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/9ce73196794dbc6eba435414fcff708e7c53df78 - Enums are now (unboxed) regular variants rather than polyvariants. This is a large change, but we're going to provide some tools for easing the transition. Commit showing how this is migrated to in the tests: https://github.com/zth/rescript-relay/commit/9da425a3e65ce3e9403168af421522028424a4f0
RescriptRelay 2.0.0 is here! This isn't a large release really, but it's a major release just because it relies on functionality from ReScript v11. Meaning the lower bound of the required ReScript version is >=11.0.0-beta.2.
2.0.0 is built to work with uncurried mode. It's not fully optimized, that'll come in 3.0.0, but it works well in uncurried mode.
You can activate uncurried mode with RescriptRelay by setting "uncurried": true (true is also the default in ReScript >=11.0.0-beta.2) in your bsconfig.json, and then ensuring that you pass -uncurried to rescript-relay/ppx in ppx-flags: "ppx-flags": [["rescript-relay/ppx", "-uncurried"]].
%relay.deferredComponentnow works with uncurried mode.
First alpha of the 2.x series of releases. 2.x focuses on compat with ReScript v11, including uncurried mode.
You can activate uncurried mode with RescriptRelay by setting "uncurried": true in your bsconfig.json, and then ensuring that you pass -uncurried to rescript-relay/ppx in ppx-flags: "ppx-flags": [["rescript-relay/ppx", "-uncurried"]].
rescriptto>=11.0.0-beta.0@rescript/reactto>=0.12.0-alpha.2
- Leverage variant's new
stringrepresentation +@as()to get rid ofmapFetchPolicy. This was internal so it should not affect you as an end user.
This release mainly makes preparations under the hood for the upcoming 2.0 (ReScript v11 + uncurried mode support) and 3.0 (lots of changes, full uncurried mode only).
- A trailing unit
()arg is no longer needed inQuery.usePreloaded(). What was previouslyQuery.usePreloaded(~queryRef, ())is now justQuery.usePreloaded(~queryRef).
- Add
@liveannotations to generated JSXv4 dynamic import compat modules, so they don't show up in dead code analysis (which they shouldn't). - Preparations under the hood for ReScript v11 + uncurried mode.
- Fix M1 binary to include new JSXv4 dynamic import compat changes.
Notable changes:
- JSX v4 is now required
- Relay and @rescript/react upgraded
- M1 support for the PPX (should speed up builds for anyone on an M1)
react-relayandrelay-runtimeto>=15.0.0@rescript/reactto>=0.11.0
- The signature for missing field handlers has changed. Previously you got an open type
{..}as record, now instead you get a properRecordProxy.tfrom the store. Check out the changelog for Relay 15. - ReScript
>=10.1and JSX v4 is now required. - Work around issue with JSX v4 and
%relay.deferredComponent. You now need to annotate any component you want to use with%relay.deferredComponentwith@relay.deferredComponent. #439
- Experimental support for allowing
nullin operation variables. Add@rescriptRelayNullableVariablesto your operation (query, mutation, subscription) and you'll be allowed to passJs.null(via theJs.Nullmodule) to your server. #426 - 🎉 M1 support for the PPX! This should speed up builds some. #435
- Fix issue with conversion of custom scalars, where custom scalars represented as arrays would get converted "internally" although they should've really just been left alone. #433
- Fix fairly large performance issue with runtime conversion. This should give a large speedup in certain cases.
- Improved autocomplete for fragments etc (pulled from upstream Relay compiler). facebook/relay#4134
- Add
RescriptRelay.Disposable.ignorefor more ergonomic handling of ignoring disposables.
- Fix the
remove-unused-fieldsscript for CI with Node.js version >14 in #409
privateis now correctly marked as a reserved word.
- Add ReScript 10 compat in peerDependencies #397 @MoOx
makeConnectionIdhelpers are now marked as@liveto not trigger the dead code analysis.
- Fix issue with custom scalar of JSON values being accidentally mangled #395 @tsnobip
Here's a commit showing a project being upgraded to this version
The time has finally come - RescriptRelay 1.0.0 is released! This version brings a ton of new features and improvements. One of the the big major things this release brings is that the ReScript type generation for the Relay compiler has been completely rewritten, and fully integrated into the new Relay Rust compiler. The RescriptRelay fork of the compiler is available and maintained [here])(https://github.com/zth/relay/tree/rescript-relay).
react-relayandrelay-runtimeto>=14.1.0reactandreact-domto>=18.0.0
You can go ahead and remove these packages, that are no longer needed, as the compiler is now shipped in the main package:
relay-configrelay-compilergraphql(if you don't use it for anything else)
- The compiler itself should be much faster than the old one. An order of magnitude faster. Especially for incremental compilation in watch mode.
- There's no longer any need to manually select
__typenameon interfaces and unions for RescriptRelay's sake, unless you actually want to use it yourself. - We now support the
@requireddirective from Relay, which is a new directive that lets you force non-nullability for nullable fields on the client side. You can then choose to throw an error if null values are encountered, or let the null value bubble up. Docs are coming soon. - The errors reported by the compiler is now quite a lot better.
- Full support for
reanalyzeas all false positive dead code results from generated code are now suppressed. - Bindings for
requiredFieldLoggerfor logging when missing fields are encountered (kudos Emilios1995). - Improved utils for dealing with enums.
recordSourceRecordsis now typed asJs.Json.trather than being abstract.- Project now works in
"type": "module"mode inpackage.json(kudos cometkim) - The field name of the
idfield of theNodeinterface is now configurable viaschemaConfig: {nodeInterfaceIdField: "idNameHere"}. - Add support for experimental Relay Resolvers. Undocumented so far, but looking at the test and definition file should give you a hint of how it works.
- Support
@rescriptRelayIgnoreUnuseddirective on fragment definitions to insert annotations that makesreanalyzeconsider all fields in the fragment used, even if they aren't. - Support
@rescriptRelayAllowUnsafeEnumdirective on fields selecting enums, which will ignore safety measures for enums, meaning you won't need to add a catch all clause, etc. It'll essentially output the enum as an input enum (as desribed in the docs). - Support provided variables. More info in the docs.
- Windows support! 🎉
- A
RelaySchemaAssets_graphql.resis now emitted, containing type definitions for all enums and all input objects. This is designed to help with accessing and using enums and input objects outside of Relay's context. This means it'll be much easier to share makers for input objects, pass enums around, etc. - Each fragment with a
@connectionnow emits amakeConnectionIdfunction that allows you to generate type safe connection IDs. More on why this is useful in the documentation.
-
The list of disallowed field names has been adapted to ReScript (it was never properly updated for ReScript when moving from ReasonML). This means that some of your variable prop names might be renamed. One example - if you previously had a variable in GraphQL called
$to, you'd interact with that asto_in ReScript. This is because RescriptRelay would pintoas a reserved word, and rename it for you. But,toisn't actually a keyword in ReScript (it was in ReasonML), so with this release, thatto_in ReScript will be renamed toto. The fix is to just update allto_toto- let the compiler guide you! -
Using variable names that are reserved words in ReScript is now disallowed at the Relay compiler level. This means that Relay won't compile your project if you have variables whose names are reserved words. The fix is to simply rename the variables.
-
refetchVariablesnow works as intended with regards to supplying only the variables you want changed when refetching, as detailed undervariableshere. This means that what was previouslymakeRefetchVariables(~someValue=123, ())should now bemakeRefetchVariables(~someValue=Some(123), ()). Crash course:makeRefetchVariables(~someValue=Some(123), ())means refetch, use the same values for all variables that was used in the last fetch, but changesomeValueto123.makeRefetchVariables(~someValue=None, ())means refetch, use the same values for all variables that was used in the last fetch, but changesomeValuetonull(unsetting it).makeRefetchVariables()means refetch, use the same values for all variables that was used in the last fetch, change nothing.
This way you can surgically change only certain values when refetching, without having to keep track of the current values for the other values.
More details on this in the docs. Thanks to @tsnobip for fixing this!
-
All enum type definitions now reside in
RelaySchemaAssets_graphql.enum_<yourEnumName>, and are not generated on the operation itself anymore. So, if you previously referred to the actual enum type, likeFragment.Types.enum_MyFineEnum, you'll now need to refer to that enum type asRelaySchemaAssets_graphql.enum_MyFineEnum. -
Input object fields with illegal names in ReScript previously had their maker function argument names suffixed with
_, like~type_: string. This is now instead prefixed, like~_type: string. Prefixing like this instead of suffixing means we can ship fully zero cost maker functions, which we couldn't before for input objects with illegal field names.
- Add Environment isServer option @MoOx
- Remove rescript from dependencies @anmonteiro
- Add undocumented holdGC method on relay store @MoOx
- Fixed
setLinkedRecordToNull,setLinkedRecordToUndefined,setLinkedRecordsToNullandsetLinkedRecordsToUndefinedmethods by binding them tosetValueinstead ofsetLinkedRecord/s. Previously they were throwing an error becausesetLinkedRecord/sdid not support "deleting" values using them. (@reck753) - Fix long standing bug that would make whether connection helpers were emitted or not unreliable.
- Fix bug in the new type safe connection ID makers where null default values wouldn't turn the variable into a
Js.Null.t<t>, leading to type errors. - Fix bug with connection handling where connections behind a
@includeor@skipdirective would not be found. - Move
getConnectionNodesback into generated and auto includedUtilsmodule. This means that failing to generategetConnectionNodes, which can happen for various reasons, won't break the build, but rather not just emit the helper.
- Fix compat with
rescript@10.1.0-alpha.1.
- potentially breaking All enum type definitions now reside in
RelaySchemaAssets_graphql.enum_<yourEnumName>, and are not generated on the operation itself anymore. So, if you previously referred to the actual enum type, likeFragment.Types.enum_MyFineEnum, you'll now need to refer to that enum type asRelaySchemaAssets_graphql.enum_MyFineEnum. - Fix bug in the new type safe connection ID makers where different types could end up in the same array, yielding type errors in ReScript.
- Fix bug in the new type safe connection ID makers where constant value
nullcouldn't be used.
- Fix long standing bug that would make whether connection helpers were emitted or not unreliable.
- Restore half-broken connection helper function inlining.
- potentially breaking
getConnectionNodesandconnectionKeyis now located directly in the generated module, and not in a nestedUtilsmodule.connectionKeyis also no longer exposed on theFragmentmodule, but only via the generated module for that fragment (WhateverYourFragmentIsCalled_whatever_graphql.res) - Support provided variables. More info in the docs.
- Windows support! 🎉
- Fixed
setLinkedRecordToNull,setLinkedRecordToUndefined,setLinkedRecordsToNullandsetLinkedRecordsToUndefinedmethods by binding them tosetValueinstead ofsetLinkedRecord/s. Previously they were throwing an error becausesetLinkedRecord/sdid not support "deleting" values using them. (@reck753) - A
RelaySchemaAssets_graphql.resis now emitted, containing type definitions for all enums and all input objects. This is designed to help with accessing and using enums and input objects outside of Relay's context. This means it'll be much easier to share makers for input objects, pass enums around, etc. - Each fragment with a
@connectionnow emits amakeConnectionIdfunction that allows you to generate type safe connection IDs. More on why this is useful in the documentation. - breaking Input object fields with illegal names in ReScript previously had their maker function argument names suffixed with
_, like~type_: string. This is now instead prefixed, like~_type: string. Prefixing like this instead of suffixing means we can ship fully zero cost maker functions, which we couldn't before for input objects with illegal field names.
- Upgrade Relay packages to version
14.1.0.
- Change signature of preload function (router related).
- Fix compatibility with ReScript v10
- Add Environment isServer option @MoOx
- Fix incorrect react-relay peerDependencies version @MoOx
- Remove rescript from dependencies @anmonteiro
- Fix instantiation of Relay context @vikfroberg
- Add undocumented holdGC method on relay store @MoOx
- Fix locations for
%relay.deferredComponentso jump-to-definition, hover etc works as expected (pointing to the dynamically imported module rather than what the PPX produces). - Add links for
Operationmodule inQuery,Mutation,SubscriptionandFragment(XiNiHa)
- Support formatting commented out operations in the CLI (reck753).
- Support
@rescriptRelayIgnoreUnuseddirective on fragment definitions to insert annotations that makesreanalyzeconsider all fields in the fragment used, even if they aren't. - Support
@rescriptRelayAllowUnsafeEnumdirective on fields selecting enums, which will ignore safety measures for enums, meaning you won't need to add a catch all clause, etc. It'll essentially output the enum as an input enum (as desribed in the docs).
- Fix enums appearing in
@raw_response_type(local query updates, optimistic responses) to be input enums.
- Fix top level node interface issue.
- Fix
useTransitionbindings, wherestartTransitionbroke after going to React 18. Kudos to Emilios1995 for researching and finding the issue!
- Upgrade to stable React 18
- Fix bug that caused issues when using unions in optimistic responses and
commitLocalPayload. - Add support for experimental Relay Resolvers. Undocumented so far, but looking at the test and definition file should give you a hint of how it works.
- Fixes for input objects.
- Fixes a few issues introduced in
beta.13. - The list of disallowed field names has been adapted to ReScript. This means that some of your variable prop names might be renamed. Check out the Breaking Changes section above for details.
refetchVariablesnow works as intended with regards to supplying only the variables you want changed when refetching, as detailed undervariableshere. Check out the docs.- Make all object makers inlined. This should improve bundle size some.
- Support more Linux versions in CI (like the images Vercel uses).
- Make CLI work with
relay.config.cjs.
- Another batch of experimental stuff... Nothing new in this version compared to
beta.9.
- Sneaking out some experimental stuff... Nothing new in this version compared to
beta.9.
recordSourceRecordsis now typed asJs.Json.trather than being abstract.- The field name of the
idfield of theNodeinterface is now configurable viaschemaConfig: {nodeInterfaceIdField: "idNameHere"}.
- More fixes for conversion instructions in variables and input objects.
- Project now works in
"type": "module"mode inpackage.json(kudos cometkim)
- Full support for
reanalyzeas all false positive dead code results from generated code are now suppressed. - Bindings for
requiredFieldLoggerfor logging when missing fields are encountered (kudos Emilios1995). - Fix bug with conversion instructions in variables with input instructions.
- Fix wrong enum type being printed in input objects
- Fix
__typenamenot being automatically selected (and by that forcing a manual select) in some cases, even though it's not supposed to be required to select manually anymore
- Generate helpers for moving between unsafe enums coming from the server, and safe enums. Also, provide a "fromString" function for each enum used, that can be used to turn any string into your enum.
- Suppress dead code warnings in most places when running
reanalyzeon arescript-relaycode base. Still a few things left to fix, that requires changes to reanalyze. But this should be much better than before.
- Revert JSON.parse micro optimization experiment.
- Fix issue with duplicate keys being printed in the conversion instructions.
- Get rid of the need of nullability conversion instructions, and infer them instead.
- Fix issue with recursive input objects not being converted correctly.
Here's a commit showing a project being upgraded to this version
Finally, a new release! This brings the Relay version to 12, and the React version to 18 (in rc.1 at the time of writing). This release has a few breaking changes which are necessary as we're slowly approaching version 1.0.0 of RescriptRelay. Check the new "Migrations" section below for a few scripts you can run to help the migration.
react-relayto12.0.0relay-compilerto12.0.0relay-configto12.0.0relay-runtimeto12.0.0
React to React 18 rc:
reacttorc(yarn add react@rc)react-domtorc(yarn add react-dom@rc)
Want help migrating most of the changes in this release? Install comby and run the migrations below (paste them into your terminal at the root of your project). Comby will guide you through the proposed changes.
comby 'ReactExperimental.unstable_useDeferredValue(:[1])' 'ReactExperimental.useDeferredValue(:[1])' .res -matcher .re -exclude-dir node_modules -reviewcomby 'ReactExperimental.renderConcurrentRootAtElementWithId' 'ReactDOMExperimental.renderConcurrentRootAtElementWithId' .res -matcher .re -exclude-dir node_modules -reviewcomby 'let (:[1], :[2]) = ReactExperimental.unstable_useTransition()' 'let (:[2], :[1]) = ReactExperimental.useTransition()' .res -matcher .re -exclude-dir node_modules -review
- Remove
reason-promise(unless you're using it for something else yourself and want to keep it). We're waiting for the official new Promise bindings, but since they seem to be quite far away, we'll have to revert back to stockJs.Promisefor now. This is becausereason-promiseclashes with other Promise bindings that people might want to use before the new official ones are actually shipped. ReactExperimental.unstable_useTransitionis now calledReactExperimental.useTransition, and the order of the tuple that's returned has been reversed to align with the underlying API. This means that what was beforelet (startTransition, isTransitioning) = ReactExperimental.unstable_useTransition()is nowlet (isTransitioning, startTransition) = ReactExperimental.useTransition()(migration available above).ReactExperimental.unstable_useDeferredValueis now calledReactExperimental.useDeferredValue(migration available above).ReactExperimental.renderConcurrentRootAtElementWithIdhas moved toReactDOMExperimental:ReactDOMExperimental.renderConcurrentRootAtElementWithId(migration available above).
- You're now allowed to configure Relay via
package.json.
This release brings a few rescript-relay-cli improvements under the hood, as well as the breaking (but very easily fixable) change of uncurrying the sink methods received back from RescriptRelay.Observable.make.
- Uncurry
sinkmethods. What was previouslysink => sink.error(err)etc should now instead besink => sink.error(. err).
- Improvements to the
remove-unused-fieldsCLI.
- A few bug fixes to the
remove-unused-fieldscommand in the CLI.
- Adds
rescript-relay-cli, a CLI for removing unused fields and formatting GraphQL in your project. Read more here (especially look atremove-unused-fields).
Quick patch release fixing the Linux binaries that broke with the last release.
Here's a commit showing a project being upgraded to this version
Other than bug fixes, the major thing about this release is the fact that we've now moved to the new rescript package 🎉!
getConnectioNodesis now also generated for aliased connections.- Fix bug with type gen for refetchable queries without arguments not working properly.
.mjsextensions in Rescript are now handled properly (kudos @sgrove).- We've now moved from
bs-platformtorescript.
A quick release with a few fixes. More details below.
- Turn off various warnings to ease creation of interface files. (@tsnobip)
- Fix multiple
fragmentRefsappearing in generated object maker functions when multiple fragment refs are present.
Another small patch release, fixing an annoying warning in the generated files, and adding bindings from Relay's missing field handlers.
- Turn off warnings for unused opens in generated files.
- Bind
missingFieldHandlersonEnvironment. Read this section of the Relay docs for more information. Add custom ones by passingarray<MissingFieldHandler.t>toEnvironment.make.
Minor patch release, removing an inline require to further enhance ES modules compability.
Here's a commit showing a project being upgraded to this version
- Support ES6 imports for
@refetchablequeries. This for example allows the use of Vite and similar bundlers.
Small patch release, mainly fixing the broken getConnectionID binding.
- Fix broken
getConnectionIDbinding. It's now properly exposed onConnectionHandler.getConnectionID, so use that instead. - Remove
getConnectionIDgeneration from PPX. PreferConnectionHandler.getConnectionID. Even though it's slightly more cumbersome, it's guaranteed to not give you dependency cycles.
Small release, mainly bringing stable references to functions produced by the PPX, and a fix for enums in input positions.
- Every enum now gets an exact version output of itself too, and that exact version is now wired up to be used in variables and inputs, where it doesn't make sense to use the open enum we use for responses/fragments (that is open to enforce adding a catch-all case for any enums that the server might add in the future).
- All hooks produced by the PPX now have stable references (or as stable as they can be), meaning you won't get a new function on each render for most of the callbacks and functions the PPX returns.
Here's a commit showing a project being upgraded to this version
Finally, we've renamed to RescriptRelay! In addition to that, Relay has also released their hook APIs as stable, which means that we for the first time in history can depend on a stable Relay version. Weehoo!
In general, this release will involve quite some renaming etc for you, but other than that, the actual breaking changes are minimal. Read the full changelog below for instructions and information about what exactly has changed.
react-relayto11.0.0relay-compilerto11.0.0relay-configto11.0.0relay-runtimeto11.0.0
ReasonRelayis now calledRescriptRelay🎉. Just search-and-replaceReasonRelaytoRescriptRelay, andreason-relaytorescript-relay, and you should be fine.defaultRenderPolicyonEnvironmentis gone. It defaults toPartialand will be removed in Relay centrally. Migration strategy: Just remove the config.renderPolicyis now 100% gone from the API. Relay will remove this in the next release (everything will always be what as previouslyPartial), and there should be no practical downsides to usingPartialas opposed toFull. Migration strategy: Remove any usage ofrenderPolicy.
- Any fragment with a
@connectiondirective now also exposes aFragment.getConnectionID(parentDataId, maybeFilters)function for making it very simple to construct a connectiondataIdfor that particular fragment that can be used with things like@appendNodeand friends. - A
ReasonRelay.getConnectionID(parentDataId, connectionKey, 'filters)is also exposed for the same reason as above, but should be avoided in any situation where the generated function from the fragment can be used. - All generated modules (so
SomeFragment_user_graphql.resthat's generated by the compiler) SuspenseListis now bound viaReactExperimentalagain since the current RescriptReact bindings to that is broken.
Here's a commit showing a project being upgraded to this version
This is the final release before ReasonRelay will rename to RescriptRelay! Do this to upgrade:
- We now depend on
@rescript/reactinstead ofreason-react. Removereason-reactand add@rescript/react@0.10.0. - The compiler now outputs
resinstead ofre. For this to work smoothly, you should delete your entire__generated__directory and re-run the ReasonRelay compiler.
Remove reason-react and add @rescript/react@0.10.0.
- Internal functions generated by the PPX are now actually marked as private. This should not be a breaking change unless you somehow rely on things from the
Internalmodule generated by each extension node, which you shouldn't be anyway.
- Bind
Environment.retain(a way to ensure a specific query is not garbage collected). @webican - Add
Query.retain(~environment, ~variables)as a way of retaining a query so it's not garbade collected. More info in the Relay docs here on what that means.
- Binaries are now statically linked on Linux, which means that build issues on things like Vercel and Netlify should now be gone. @fakenickels (and honorary mention bdj)
- The compiler now outputs
resfiles and syntax instead ofresyntax. In order to make this work smoothly, make sure you remove all contents of your__generated__folder before you re-run the Relay compiler after upgrading. - Fix a bug where store updater directives on scalars (like
deletedUserId) would not have their connection array arg type transformed fromstringtodataId.
Here's a commit showing a project being upgraded to this version
This release brings new versions of Relay and React, and a few other minor changes.
reactto0.0.0-experimental-4e08fb10creact-domto0.0.0-experimental-4e08fb10creact-relayto0.0.0-experimental-4c4107ddrelay-compilerto10.1.3relay-configto10.1.3relay-runtimeto10.1.3
- BREAKING CHANGE Lists of connection ids passed into the store updater directives (@appendEdge, @appendNode, etc) are now properly typed a
array<ReasonRelay.dataId>rather thanarray<string>.
/* @generated */JS comment is now preserved in the output, helping various tooling understand that the generated files are indeed generated.- Prebuilt JS files are now shipped with the package to simplify building a project without needing to build your ReScript project again. Warning: This is not "officially" supported in the sense that if you use this, you're on your own. We still recommend you to always build your ReScript project before delivering it, and not relying on prebuilt files.
- Added comment to generated connection record types, giving a hint to use the generated
getConnectionNodeshelper for turning a connection into a list of non-nullable nodes.
Here's a commit showing a project being upgraded to this version
Make sure you read the breaking changes below!
This release marks the start of ReasonRelay's journey towards two things:
- Supporting the new Relay Rust compiler. While this release still uses the JS based compiler, it takes steps needed to support the Rust based compiler in the future.
- Fully embracing ReScript.
Point 1 is something that you as a user will hopefully notice a minimal amount of churn from. But point 2 is important to address. In sum, the following will happen in the coming months:
- ReasonRelay will be renamed, probably to ReScriptRelay.
- ReasonML and ReScript syntax will continue to be supported for the foreseeable future, but I will focus my tooling and documentation efforts on ReScript.
- Docs will be converted to ReScript (this is 90% done).
- A dedicated VSCode extension I'm working on will be released, only supporting ReScript syntax (sneak peak already released).
- Source files emitted by the compiler will eventually be converted to
.resfiles rather than.refiles.
The reason for all of this is simply that I believe ReScript is where the future is at, and I don't have the resources to focus my efforts on tooling etc for two syntaxes. I love ReasonML and its syntax, but I've still come to the conclusion that ReScript syntax is what will the most powerful alternative in the future.
Check out the sneak peak release of the dedicated VSCode extension.
- BREAKING CHANGE Operations are now defined through a single extension node rather than multiple per operation type.
relay.fragment,relay.queryetc are now gone. What was previously[%relay.fragment {| fragment Blabla on Blabla {....|}]should now instead be:[%relay {| fragment Blabla on Blabla {....|}].
Migration path: Install comby, and run this command in your root (for .re files): comby '%relay.:[~(fragment|subscription|mutation|query)]' '%relay' -i .re -exclude-dir node_modules, or this command for .res files: comby '%relay.:[~(fragment|subscription|mutation|query)]' '%relay' -i .res -matcher .re -exclude-dir node_modules. That will take care of migrating all of your extension points.
- BREAKING CHANGE Add binding for passing
uploadablesto network fetch functions. This is breaking because it changes the signature offetchFunctionPromiseandfetchFunctionObservableto include another argumentuploadables. Migration path: What was previously something likelet fetchQuery: ReasonRelay.Network.fetchFunctionPromise = (operation, variables, _cacheConfig) => {...}should now belet fetchQuery: ReasonRelay.Network.fetchFunctionPromise = (operation, variables, _cacheConfig, _uploadables) => {...}. Read more in the API reference section of the docs. (@hariroshan)
- Add back
Query.fetchPromisedto simplify working with SSR. - Bind
idinoperationto allow using persisted queries. (@hariroshan)
- Almost the entire Reason codegen has moved from being JS based to Reason native. As a user you shouldn't really notice anything other than the builds being a bit quicker. This is mainly a preparation for the upcoming Relay Rust compiler.
A quick patch with a bug fix.
- Fix a bug where
@raw_response_typetogether with unions would crash the type generation.
This release packs a bunch of new, cool things! Full list of details below, but some highlights:
- Support for using ReasonRelay with ReScript (@sorenhoyer)
- Relay
10.1.0
Check out this for an example diff of upgrading a project.
This version also reverts back to shipping our own bindings for ReactExperimental. It's likely that React will remain in experimental for a while longer with concurrent mode, and we don't want to be tied to the bindings in ReasonReact, since they usually take a while to update. Hence this change.
A big thanks to all contributors who's helped pack this release with great changes. It contains a bit of churn (and the coming releases probably will too), but hopefully nothing that isn't easily handled.
reactto0.0.0-experimental-4ead6b530react-domto0.0.0-experimental-4ead6b530react-relayto0.0.0-experimental-c818bac3relay-compilerto10.1.0relay-configto10.1.0relay-runtimeto10.1.0bs-platformto8.3.3(recommended, but not required)
- If you get an error with
bs-platform>8.3.0for code looking like thislet ReasonRelay.{data, hasNext} = ..., just removeReasonRelay.from that code and the error should be gone. Later versions ofbs-platformnow properly infer record destruction, which prior versions did not do.
- BREAKING CHANGE Replace unsetValue with setValueToUndefined and setValueToNull #105 (@tsnobip)
- BREAKING CHANGE Replace
React.useTransition(~config={timeoutMs: 5000}, ())withReactExperimental.unstable_useTransition()#121 (@sorenhoyer) - BREAKING CHANGE Replace
React.useDeferredValuewithReactExperimental.unstable_useDeferredValue#121 (@sorenhoyer) - BREAKING CHANGE Replace
ReactDOMRe.Experimental.createRootwithReactDOMExperimental.unstable_createRoot#121 (@sorenhoyer) - BREAKING CHANGE Remove
Query.fetchPromised. Users can convert the fetch to a promise themselves if needed. (@zth) - BREAKING CHANGE Remove
Mutation.commitMutationPromised. Users can convert the mutation to a promise themselves if needed. (@zth)
- Bind
Store.publish(), which allows you to publish aRecordSourceto your current store. Useful for various SSR cases (think Next.js and similar). (@zth) - Bind
readInlineDatafor fragments annotated with@inline#117 (@zth) - Clean bindings, renamed internal raw types and functions with names ending with
Raw#105 (@tsnobip)
- Relay upgraded to
10.1.0(@zth) - Generate a
commitLocalPayloadfor any query annotated with@raw_response_type, to allow comitting local only payloads in a type safe way. #118 (@zth) - Use abstract records instead of Js.t objects for a more robust type-check and to avoid undefined fields #105 (@tsnobip)
- Add support for parsing ReScript (.res) files #115 (@sorenhoyer)
- Move a bunch of things from the bindings to the PPX. This will simplify a lot of things, improve the type safety some, and pave the way for some pretty interesting upcoming editor tooling. (@zth)
- Remove
internal_cleanVariablesRaw, sincebs-platformsince7.3does what that did by default. (@zth)
Another release, primarily to enable zero cost enums via bs-platform 8.2.0. No new Relay version, and hopefully a managable amount of breaking changes.
Check out this for an example diff of upgrading a project.
bs-platform@^8.2.0Note this must be8.2.0as we rely on things from that release.
- BREAKING CHANGE All enums are now zero cost as
bs-platform>8.2.0models polyvariants without payloads as strings. This does however force us to remove theFutureAddedValue(string)case, but it's worth it in the long run. Migration path: Where you previously matched onFutureAddedValue(_), now instead match on a default_. SoFutureAddedValue(_) => ...becomes_ => .... But hey, maybe you were using that stringFutureAddedValueprovided?! You can still get it, every module with enums will now containtoStringfunctions for turning your enum into an actual string. If you have an enum calledOnlineStatus, your module will have a function likeFragment.onlineStatus_toString(enumGoesHere). - BREAKING CHANGE All
getConnectionNodes_path_to_connectiongenerated functions are now named justgetConnectionNodes, since Relay only allows a single@connectionper operation/fragment, which makes name clashes impossible. Migration path: Rename all calls togetConnectionNodes_some_path_hereto justgetConnectionNodes. - BREAKING CHANGE All
refetchfunctions now properly return aDisposable.t. Migration path: Handle the new return properly, vialet _ = refetch(...)orrefetch(...)->ignorefor example.
No new bindings this release.
- Fixed a bug where
fragmentRefswould produce a circular reference which can't be stringified. - Types are now always emitted as recursive, fixing a bug where types wouldn't/can't be printed in the right order.
A new, fresh release! This brings Relay to version 10.0.1, binds a bunch of new things, and changes a few APIs (and their implementations) to be more ergonomic.
I'd like to highlight contributions from Arnarkari93, tsnobip and wokalski, who all have made significant and great contributions for this release.
Check out this for an example diff of upgrading a project.
reason-react@^0.9.1bs-platform@^8.0.3(although anything >7should work)react-relayto0.0.0-experimental-8058ef82, the rest of the Relay packages to10.0.1
- Bindings in
ReactExperimentalforSuspense,SuspenseList,ConcurrentModeRoot.render,createRootanduseTransitionhave been moved to the official community bindings in Reason-React. Migration path: ChangeReactExperimentalto justReactfor said modules and functions. - Fragment refs are now typed through polymorphic variants. Previously, all fragment refs for an object would be retrieved by doing
someObject.getFragmentRefs(). That call would return aJs.tobject containing all fragment references, which would then be structurally matched to ensure fragment type safety. This is now replaced with a regular prop calledfragmentRefsthat'll appear on any object with fragments spread. This improves the experience of using fragments immensely. Migration path: Where you previously didsomeObj.getFragmentRefs()now dosomeObj.fragmentRefsinstead. - The top level
nodefield is now enhanced by a) collapsing the union it was previously typed as if there's only one selection anyway, and b) automatically resolve any existing node from the cache through thenoderoot field. Query.fetchandQuery.fetchPromisednow need to be applied with()unless all args are specified. Two new args have been added:fetchPolicy, which controls cache behavior at the store level, andnetworkCacheConfigwhich controls caching at the network layer. Migration path: Add a trailing()to allQuery.fetchandQuery.fetchPromisedcalls.- What was previously called
Query.preloadis now calledQuery.load, to align with Relay's naming. The return type ofQuery.loadhas also been renamed toqueryRef(frompreloadToken), and all names related to that have been changed accordingly. Migration path: Change allQuery.preloadtoQuery.load. Observable.makereturns the optional subscription object. Thesinkprovided byObservablenow also has the correctcompleteprop (completed->complete). And,Observable.tnow correctly takes a type param for the'response;Observable.t('response).
- Add
toPromisebinding forObservable, allowing for an easy way of turning an observable into a promise. - Bindings for
queryCacheExpirationTime(setting an expiration time for all cache items inms) when creating the store. - Bind
useSubscribeToInvalidationState, which allows listening and reacting to invalidations of records in the store. - Bind and document
Query.useLoader. - Bind
RelayFeatureFlags.
- Cleaned up the bindings to Relay and their interface files to reduce runtime size
- Fix refetching with pagination when the parent queries have variables that are left unchanged in the refetch
- Automatic conversion of custom scalars! Heavily inspired by the upcoming
graphql_ppxrelease which also has this, it's now possible to have ReasonRelay automatically convert your custom scalars at runtime. More info in the docs for custom scalars.
- Fix bug with
bs-platform >7.3.0.
- BREAKING CHANGE
preloadis now only exposed via the generated module, not via what's generated by the PPX. This is to reduce confusion of which one to use. If you previously usedQuery.preload, you should now useOperationNameOfYourQuery_graphql.preload. preloadTokencan now be converted to an observable and a promise. This is paving the way for doing SSR efficiently.- Fragments can now be on unions, which previously wasn't supported in ReasonRelay (but has always been valid in Relay itself). Thanks to Arnar Kári Ágústsson for finding this!
- BREAKING CHANGE All variants of doing mutations will no longer get an optional
'responsein itsonCompletehandlers (or in theBelt.Result.tforcommitMutationPromised). Thanks to Renan for finding this issue, and for the initial fix. - Fragments now have a
Fragment.useOptthat take an optional fragment ref object, and returns an optional'fragment. This is useful for scenarios where you haven't fetched data for a fragment yet, but it still makes sense to have the fragment hook present in your render body. PassNonetoFragment.useOptand you'll getNoneback.
preloadfor queries are now exposed right on the raw generated GraphQL module coming from the Relay compiler, in addition to on the module generated from the PPX. This primarily paves the way for effective code splitting.
- Fix subscriptions function bindings, which was previously wrong (thanks @ Arnarkari93 !)
- Fix bug when input objects contain circular dependencies.
- Fix "unused varible this" warning introduced in
0.8.0.
- Enum + union definitions are now also inlined in the record they appear, to improve editor integrations/hints in the editor.
- BREAKING CHANGE Tons of changes to APIs for interacting with the store. Too many to list, but they're mostly about changing APIs taking
optionsto allow omitting the optional prop if you apply the function with(). - BREAKING CHANGE All generated types now reside in
YourModule.Typesand are named according to at what path they were found. This includes unions as well. So, if you were previously relying on using the generated types manually for annotation, you can now find them all inside ofYourModule.Types, named after the path in the fragment/operation where they are located. - A promise based version of
Query.fetchcalledfetchPromisedadded. Also a promise based version ofMutation.commitMutationcalledcommitMutationPromisedadded. commitMutationresult type changed to the actual'responserather thanJs.Json.t. However, this is actually unsafe, because'responsemay have been altered by theupdaterof the mutation. However, this case is so uncommon that it's better to support the broad use case of accessing the actual'responsein the complete handler.reason-promiseis now a peer dependency.
- BREAKING CHANGE
SchemaAssets.rehas been retired. If you were relying on code from there for converting enums to/from strings, you can now find equivalent functions attached on yourModuleName.Operation.unwrap_enum_EnumName(for string -> polymorphic variant) andModuleName.Operation.wrap_enum_EnumName(polymorphic variant -> string). You may need to remove the oldSchemaAssets.remanually. - BREAKING CHANGE
commitMutationno longer returns a promise, but aDisposable.tinstead. It now uses callbacks (which is how Relay handles this natively anyway)onCompletedandonErrorto indicate done/error states. - BREAKING CHANGE The
fetchfunction generated by[%relay.query]no longer returns a promise, but rather uses a new callbackonResultto deliver the result as a properResult.t. If you previously didQuery.fetch(~environment, ~variables=...) |> Js.Promise.then_(res => ...)you should now doQuery.fetch(~environment, ~variables=..., ~onResult=res => switch(res) { | Ok(res) => ... | Error(_) => ... })and handleResult.taccordingly. This is part of an ongoing effort to remove the dependencies on promises, and to improve type inference which wasn't working out here before. - BREAKING CHANGE
FutureAddedValue(Js.Json.t)for unions/interfaces is nowUnselectedUnionMember(string)wherestringis the__typename, because... well, this makes more sense.
- Rename object properties if reserved words are encountered. E.g.
input SomeGraphQLInput { and: String! }will now produce this type:type someGraphQLInput = { [@bs.as "and"] and_: string }. - Emit maker functions for any input object with at least one optional prop. This is to greatly simplify working with complex input objects with lots of properties.
- Fix bug with
nullinputs wouldn't be properly filtered when refetching connections. - BREAKING CHANGE Rename unknown enum and union values to
FutureAddedValue(payload)to align with convention discussed with the folks behindgraphql_ppx. - BREAKING CHANGE Bind
RenderPolicyfor control over whether Relay is allowed to partially render the UI with the data it already has while fetching. This is a breaking change because it changes the signature forQuery.usePreloadedfromusePreloaded(token)tousePreloaded(~token: token, ~renderPolicy: renderPolicy=?, ()). - Bind APIs for invalidating store records and the full store for forcing refetches etc.
RecordProxy.invalidateRecordandRecordSourceProxy.invalidateStore. - Bind
useMutationfrom Relay experimental, giving us a cleaner and nicer hooks based API for doing mutations, rather than justcommitMutation. - POTENTIALLY BREAKING CHANGE All record types for all GraphQL operations are now emitted with their name as the path they're found at joined together. Previously, I was being smart and setting the name to the simplest possible, but this will enable some smart tooling down the line.
- Fix bug where complex inputs (nested objects) were not automatically converted.
RecordProxynow has functions for unsetting valuesunsetValue/unsetLinkedRecord/unsetLinkedRecords, for more fine-grained control of the cache.
- Inlines enum definition in generated files to improve code lens/view definition in editors. Previously, all that would show up when hovering an enum would be
SchemaAssets.Enum_enumName.t, but now the full enum definition will show. This will work fine withSchemaAssetssince polymorphic variants match structurally, so the definitions will be equivalent. - Inlines union definition and references that in the local types, for the same reason as enums - improving code lens/view definition.
- Autogenerate helper function for turning a @connection into an array of nodes. This replaces the functionality of the previous
ReasonRelayUtils.collectConnectionNodesthat's no longer usable after moving fromJs.tto records. - BREAKING CHANGE Move from manually unwrapping fragments via a unique function per record (Like
user->Fragment.unwrapFragment_user) to instead using a function to each record calledgetFragmentRefs()that extracts the fragments refs needed. This meansuser->Fragment.unwrapFragment_useris now instead simplyuser.getFragmentRefs(). Should be much more ergonomic, and hopefully make more sense.
- Fix nasty bug with new record types generation and autodecoding where things nested inside of unions would not be autodecoded.
- Adds validation for illegal field names (reserved words and capitalized words are illegal as field names in Reason) to the Relay compiler.
- Moves validation of explicit
__typenameselection to Relay compiler, from the PPX. - Upgrade to BuckleScript 7, and convert lots of things to use records instead of
Js.tunder the hood. - BREAKING CHANGE Add
'responseas second parameter to mutation/subscriptionupdaterfunctions. This was simply not bound before in ReasonRelay, but Relay has always provided it. - BREAKING CHANGE Change signature of
loadNext/loadPreviouspagination functions to follow the convention of providing only the arguments wanted and applying the function manually viaunit. This:loadNext(~count=2, ~onComplete=None)will now instead be applied likeloadNext(~count=2, ()). - BREAKING CHANGE Replace module
SuspenseConfigwith simple recordsuspenseConfig. - BREAKING CHANGE Bump Relay versions to
8.0.0andreact-relayto0.0.0-experimental-5f1cb628. - Fix bug with unused generated files not being deleted by the Relay compiler.
- Bind
generateClientID,generateUniqueClientIDandisClientIDhelpers. - SUPER BREAKING CHANGE All emitted types are now records instead of Js.t, and
Js.Nullable.t/enums/unions are now autoconverted with no manual intervention needed. This should greatly simplify working with ReasonRelay. - BREAKING CHANGE Remove
collectConnectionNodesfromReasonRelayUtils, since it operated onJs.tand nothing is typed asJs.tanymore.
- Moved
ReactSuspenseConfigmodule toReactExperimentaland renamed it to simplySuspenseConfig. - Added abstract type
recordSourceRecordsto represent the records from the store serialized to a saveable format. - Allow passing initial
recordSourceRecordstoRecordSource.make(). - Add full chain of methods needed to serialize the records from the store of the current environment, like:
environment->Environment.getStore->Store.getSource->RecordSource.toJSON.
- BREAKING CHANGE Added
gcReleaseBufferSizeto creation of store, which is breaking because it turns the signature formakefromRecordSource.t => tto(~source: RecordSource.t, ~gcReleaseBufferSize: option(int), ()) => t.
ReactExperimentalis now included in the distributed package.
- ReasonRelay now depends on
react@experimentalandreact-dom@experimental. - Added
useTransition,useDeferredValue,<Suspense />,<SuspenseList />,createRootandcreateRootAtElementWithIdexperimental API bindings toReactExperimental. - Added
ReactExperimentalmodule for binding experimental React APIs.