- Add
@live
annotations to generated JSXv4 dynamic import compat modules, so they don't show up in dead code analysis (which they shouldn't).
- 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-relay
andrelay-runtime
to>=15.0.0
@rescript/react
to>=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.t
from the store. Check out the changelog for Relay 15.
- Experimental support for allowing
null
in operation variables. Add@rescriptRelayNullableVariables
to your operation (query, mutation, subscription) and you'll be allowed to passJs.null
(via theJs.Null
module) to your server. zth/rescript-relay#426 - 🎉 M1 support for the PPX! This should speed up builds some. zth/rescript-relay#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. zth/rescript-relay#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.ignore
for more ergonomic handling of ignoring disposables.
- Fix the
remove-unused-fields
script for CI with Node.js version >14 in #409
private
is now correctly marked as a reserved word.
- Add ReScript 10 compat in peerDependencies zth/rescript-relay#397 @MoOx
makeConnectionId
helpers are now marked as@live
to not trigger the dead code analysis.
- Fix issue with custom scalar of JSON values being accidentally mangled zth/rescript-relay#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-relay
andrelay-runtime
to>=14.1.0
react
andreact-dom
to>=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-config
relay-compiler
graphql
(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
__typename
on interfaces and unions for RescriptRelay's sake, unless you actually want to use it yourself. - We now support the
@required
directive 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
reanalyze
as all false positive dead code results from generated code are now suppressed. - Bindings for
requiredFieldLogger
for logging when missing fields are encountered (kudos Emilios1995). - Improved utils for dealing with enums.
recordSourceRecords
is now typed asJs.Json.t
rather than being abstract.- Project now works in
"type": "module"
mode inpackage.json
(kudos cometkim) - The field name of the
id
field of theNode
interface 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
@rescriptRelayIgnoreUnused
directive on fragment definitions to insert annotations that makesreanalyze
consider all fields in the fragment used, even if they aren't. - Support
@rescriptRelayAllowUnsafeEnum
directive 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.res
is 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
@connection
now emits amakeConnectionId
function 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 pinto
as a reserved word, and rename it for you. But,to
isn'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.
-
refetchVariables
now works as intended with regards to supplying only the variables you want changed when refetching, as detailed undervariables
here. 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 changesomeValue
to123
.makeRefetchVariables(~someValue=None, ())
means refetch, use the same values for all variables that was used in the last fetch, but changesomeValue
tonull
(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
,setLinkedRecordsToNull
andsetLinkedRecordsToUndefined
methods by binding them tosetValue
instead ofsetLinkedRecord/s
. Previously they were throwing an error becausesetLinkedRecord/s
did 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
@include
or@skip
directive would not be found. - Move
getConnectionNodes
back into generated and auto includedUtils
module. 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
[email protected]
.
- 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
null
couldn'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
getConnectionNodes
andconnectionKey
is now located directly in the generated module, and not in a nestedUtils
module.connectionKey
is also no longer exposed on theFragment
module, 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
,setLinkedRecordsToNull
andsetLinkedRecordsToUndefined
methods by binding them tosetValue
instead ofsetLinkedRecord/s
. Previously they were throwing an error becausesetLinkedRecord/s
did not support "deleting" values using them. (@reck753) - A
RelaySchemaAssets_graphql.res
is 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
@connection
now emits amakeConnectionId
function 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.deferredComponent
so jump-to-definition, hover etc works as expected (pointing to the dynamically imported module rather than what the PPX produces). - Add links for
Operation
module inQuery
,Mutation
,Subscription
andFragment
(XiNiHa)
- Support formatting commented out operations in the CLI (reck753).
- Support
@rescriptRelayIgnoreUnused
directive on fragment definitions to insert annotations that makesreanalyze
consider all fields in the fragment used, even if they aren't. - Support
@rescriptRelayAllowUnsafeEnum
directive 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
useTransition
bindings, wherestartTransition
broke 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.
refetchVariables
now works as intended with regards to supplying only the variables you want changed when refetching, as detailed undervariables
here. 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
.
recordSourceRecords
is now typed asJs.Json.t
rather than being abstract.- The field name of the
id
field of theNode
interface 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
reanalyze
as all false positive dead code results from generated code are now suppressed. - Bindings for
requiredFieldLogger
for 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
__typename
not 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
reanalyze
on arescript-relay
code 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-relay
to12.0.0
relay-compiler
to12.0.0
relay-config
to12.0.0
relay-runtime
to12.0.0
React to React 18 rc:
react
torc
(yarn add react@rc
)react-dom
torc
(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 -review
comby 'ReactExperimental.renderConcurrentRootAtElementWithId' 'ReactDOMExperimental.renderConcurrentRootAtElementWithId' .res -matcher .re -exclude-dir node_modules -review
comby '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.Promise
for now. This is becausereason-promise
clashes with other Promise bindings that people might want to use before the new official ones are actually shipped. ReactExperimental.unstable_useTransition
is 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_useDeferredValue
is now calledReactExperimental.useDeferredValue
(migration available above).ReactExperimental.renderConcurrentRootAtElementWithId
has 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
sink
methods. What was previouslysink => sink.error(err)
etc should now instead besink => sink.error(. err)
.
- Improvements to the
remove-unused-fields
CLI.
- A few bug fixes to the
remove-unused-fields
command 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 🎉!
getConnectioNodes
is now also generated for aliased connections.- Fix bug with type gen for refetchable queries without arguments not working properly.
.mjs
extensions in Rescript are now handled properly (kudos @sgrove).- We've now moved from
bs-platform
torescript
.
A quick release with a few fixes. More details below.
- Turn off various warnings to ease creation of interface files. (@tsnobip)
- Fix multiple
fragmentRefs
appearing 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
missingFieldHandlers
onEnvironment
. 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
@refetchable
queries. This for example allows the use of Vite and similar bundlers.
Small patch release, mainly fixing the broken getConnectionID
binding.
- Fix broken
getConnectionID
binding. It's now properly exposed onConnectionHandler.getConnectionID
, so use that instead. - Remove
getConnectionID
generation 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-relay
to11.0.0
relay-compiler
to11.0.0
relay-config
to11.0.0
relay-runtime
to11.0.0
ReasonRelay
is now calledRescriptRelay
🎉. Just search-and-replaceReasonRelay
toRescriptRelay
, andreason-relay
torescript-relay
, and you should be fine.defaultRenderPolicy
onEnvironment
is gone. It defaults toPartial
and will be removed in Relay centrally. Migration strategy: Just remove the config.renderPolicy
is 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 usingPartial
as opposed toFull
. Migration strategy: Remove any usage ofrenderPolicy
.
- Any fragment with a
@connection
directive now also exposes aFragment.getConnectionID(parentDataId, maybeFilters)
function for making it very simple to construct a connectiondataId
for that particular fragment that can be used with things like@appendNode
and 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.res
that's generated by the compiler) SuspenseList
is now bound viaReactExperimental
again 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/react
instead ofreason-react
. Removereason-react
and add@rescript/[email protected]
. - The compiler now outputs
res
instead 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/[email protected]
.
- 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
Internal
module 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
res
files and syntax instead ofre
syntax. 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 fromstring
todataId
.
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.
react
to0.0.0-experimental-4e08fb10c
react-dom
to0.0.0-experimental-4e08fb10c
react-relay
to0.0.0-experimental-4c4107dd
relay-compiler
to10.1.3
relay-config
to10.1.3
relay-runtime
to10.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
getConnectionNodes
helper 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
.res
files rather than.re
files.
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.query
etc 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
uploadables
to network fetch functions. This is breaking because it changes the signature offetchFunctionPromise
andfetchFunctionObservable
to 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.fetchPromised
to simplify working with SSR. - Bind
id
inoperation
to 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_type
together 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.
react
to0.0.0-experimental-4ead6b530
react-dom
to0.0.0-experimental-4ead6b530
react-relay
to0.0.0-experimental-c818bac3
relay-compiler
to10.1.0
relay-config
to10.1.0
relay-runtime
to10.1.0
bs-platform
to8.3.3
(recommended, but not required)
- If you get an error with
bs-platform
>8.3.0
for code looking like thislet ReasonRelay.{data, hasNext} = ...
, just removeReasonRelay.
from that code and the error should be gone. Later versions ofbs-platform
now 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.useDeferredValue
withReactExperimental.unstable_useDeferredValue
#121 (@sorenhoyer) - BREAKING CHANGE Replace
ReactDOMRe.Experimental.createRoot
withReactDOMExperimental.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 aRecordSource
to your current store. Useful for various SSR cases (think Next.js and similar). (@zth) - Bind
readInlineData
for 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
commitLocalPayload
for 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-platform
since7.3
does 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.0
Note this must be8.2.0
as we rely on things from that release.
- BREAKING CHANGE All enums are now zero cost as
bs-platform
>8.2.0
models 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 stringFutureAddedValue
provided?! You can still get it, every module with enums will now containtoString
functions 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_connection
generated functions are now named justgetConnectionNodes
, since Relay only allows a single@connection
per operation/fragment, which makes name clashes impossible. Migration path: Rename all calls togetConnectionNodes_some_path_here
to justgetConnectionNodes
. - BREAKING CHANGE All
refetch
functions now properly return aDisposable.t
. Migration path: Handle the new return properly, vialet _ = refetch(...)
orrefetch(...)->ignore
for example.
No new bindings this release.
- Fixed a bug where
fragmentRefs
would 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.1
bs-platform@^8.0.3
(although anything >7
should work)react-relay
to0.0.0-experimental-8058ef82
, the rest of the Relay packages to10.0.1
- Bindings in
ReactExperimental
forSuspense
,SuspenseList
,ConcurrentModeRoot.render
,createRoot
anduseTransition
have been moved to the official community bindings in Reason-React. Migration path: ChangeReactExperimental
to justReact
for 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.t
object containing all fragment references, which would then be structurally matched to ensure fragment type safety. This is now replaced with a regular prop calledfragmentRefs
that'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.fragmentRefs
instead. - The top level
node
field 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 thenode
root field. Query.fetch
andQuery.fetchPromised
now 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, andnetworkCacheConfig
which controls caching at the network layer. Migration path: Add a trailing()
to allQuery.fetch
andQuery.fetchPromised
calls.- What was previously called
Query.preload
is now calledQuery.load
, to align with Relay's naming. The return type ofQuery.load
has also been renamed toqueryRef
(frompreloadToken
), and all names related to that have been changed accordingly. Migration path: Change allQuery.preload
toQuery.load
. Observable.make
returns the optional subscription object. Thesink
provided byObservable
now also has the correctcomplete
prop (completed
->complete
). And,Observable.t
now correctly takes a type param for the'response
;Observable.t('response)
.
- Add
toPromise
binding 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_ppx
release 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
preload
is 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
. preloadToken
can 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
'response
in itsonComplete
handlers (or in theBelt.Result.t
forcommitMutationPromised
). Thanks to Renan for finding this issue, and for the initial fix. - Fragments now have a
Fragment.useOpt
that 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. PassNone
toFragment.useOpt
and you'll getNone
back.
preload
for 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
options
to allow omitting the optional prop if you apply the function with()
. - BREAKING CHANGE All generated types now reside in
YourModule.Types
and 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.fetch
calledfetchPromised
added. Also a promise based version ofMutation.commitMutation
calledcommitMutationPromised
added. commitMutation
result type changed to the actual'response
rather thanJs.Json.t
. However, this is actually unsafe, because'response
may have been altered by theupdater
of the mutation. However, this case is so uncommon that it's better to support the broad use case of accessing the actual'response
in the complete handler.reason-promise
is now a peer dependency.
- BREAKING CHANGE
SchemaAssets.re
has 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.re
manually. - BREAKING CHANGE
commitMutation
no longer returns a promise, but aDisposable.t
instead. It now uses callbacks (which is how Relay handles this natively anyway)onCompleted
andonError
to indicate done/error states. - BREAKING CHANGE The
fetch
function generated by[%relay.query]
no longer returns a promise, but rather uses a new callbackonResult
to 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.t
accordingly. 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)
wherestring
is 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
null
inputs 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
RenderPolicy
for 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.usePreloaded
fromusePreloaded(token)
tousePreloaded(~token: token, ~renderPolicy: renderPolicy=?, ())
. - Bind APIs for invalidating store records and the full store for forcing refetches etc.
RecordProxy.invalidateRecord
andRecordSourceProxy.invalidateStore
. - Bind
useMutation
from 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.
RecordProxy
now 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 withSchemaAssets
since 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.collectConnectionNodes
that's no longer usable after moving fromJs.t
to 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_user
is 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
__typename
selection to Relay compiler, from the PPX. - Upgrade to BuckleScript 7, and convert lots of things to use records instead of
Js.t
under the hood. - BREAKING CHANGE Add
'response
as second parameter to mutation/subscriptionupdater
functions. This was simply not bound before in ReasonRelay, but Relay has always provided it. - BREAKING CHANGE Change signature of
loadNext
/loadPrevious
pagination 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
SuspenseConfig
with simple recordsuspenseConfig
. - BREAKING CHANGE Bump Relay versions to
8.0.0
andreact-relay
to0.0.0-experimental-5f1cb628
. - Fix bug with unused generated files not being deleted by the Relay compiler.
- Bind
generateClientID
,generateUniqueClientID
andisClientID
helpers. - 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
collectConnectionNodes
fromReasonRelayUtils
, since it operated onJs.t
and nothing is typed asJs.t
anymore.
- Moved
ReactSuspenseConfig
module toReactExperimental
and renamed it to simplySuspenseConfig
. - Added abstract type
recordSourceRecords
to represent the records from the store serialized to a saveable format. - Allow passing initial
recordSourceRecords
toRecordSource.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
gcReleaseBufferSize
to creation of store, which is breaking because it turns the signature formake
fromRecordSource.t => t
to(~source: RecordSource.t, ~gcReleaseBufferSize: option(int), ()) => t
.
ReactExperimental
is now included in the distributed package.
- ReasonRelay now depends on
react@experimental
andreact-dom@experimental
. - Added
useTransition
,useDeferredValue
,<Suspense />
,<SuspenseList />
,createRoot
andcreateRootAtElementWithId
experimental API bindings toReactExperimental
. - Added
ReactExperimental
module for binding experimental React APIs.