To install, run:
npm install react-relay@dev relay-runtime@dev
npm install relay-compiler@dev babel-plugin-relay@dev --dev
See this issue for more details on upcoming releases. We will publish our updated docs and website with the next stable release, along with additional external communications with the community.
The new docs will be more comprehensive, and are still are ongoing updates. In the meantime, in order to access some documentation for the APIs in this RC, you can access our current experimental docs, or manually build the docs in website-v2.
Breaking
- New version of
fetchQuery:- New: New version of
fetchQuerynow returns a lazyObservablewhich you can subscribe to. It will perform in-flight request de-duping of identical requests. Ignores any Network Layer caching by default, but supports afetchPolicyto check data cached in the Relay Store. - Deprecated: Previous version of
fetchQueryrenamed tofetchQuery_DEPRECATED. Previous behavior returns a Promise (can’t be observed). No request de-duping. - Changes in Exports:
react-relay:fetchQueryexported fromreact-relaynow has updated behavior and function signature. To access previous version offetchQuery, importfetchQuery_DEPRECATEDfromreact-relayorreact-relay/legacy.relay-runtime:fetchQueryexported fromrelay-runtimenow has updated behavior and function signature. To access previous version offetchQuery, importfetchQuery_DEPRECATEDfromrelay-runtime.
- New: New version of
getDataIDwas renamed fromUNSTABLE_DO_NOT_USE_getDataID. This config option is now stable. It can be passed to the Relay Environment and Relay Store as an option that will be used to compute the Data ID for the given record.- Default value for
gcReleaseBufferSizeis now 10 (previously 0).- When a query is manually released, for example when a query component unmounts (
QueryRendereroruseLazyLoadQuery), Relay will temporarily retain the query in the “release buffer” until the buffer is full. With a buffer size of 0, released queries would not go into the buffer and would be immediately removed from the store cache. - With a default buffer size of 10, this means that queries will remained cached in the store for a longer period of time after they unmount, which allows fetch policies like
store-or-networkto actually reuse cached data when navigating back to previously visited views.
- When a query is manually released, for example when a query component unmounts (
If upgrading from experimental release
- The default
UNSTABLE_renderPolicyis now always “partial”. We don’t expect this to produce any issues, and will only affect you if you are upgrading from an experimental release. This option can still be configured, but we will completely remove it in the upcoming stable release.
Added
Relay Hooks
- New Relay Hooks APIs added to
react-relayandreact-relay/hooks. See this issue for more details.relay-experimentalhas been removed from the source code, and no new experimental builds will be published to npm.- We will share more external communications with the community as well as publish our updated docs once a stable release is published.
- New version of
fetchQueryadded. See description in Breaking Changes.
General
- Added
ConnectionHandler.getConnectionIDto make it easier to get a connection ID for usage in updaters or declarative connection mutations (@kyarik: #3332)
Improvements
If upgrading from experimental release
- Hooks are now resilient to React effects being re-invoked (e.g. during Fast Refresh).
- Un-actionable warning that fired when fragment data was missing without being fetched has been removed.
loadQueryaccepts afetchPolicyof'store-only'loadQuerynow warns, instead of throwing, if called during the render phase.
General
getDataIDis now a stable config option. See description in Breaking Changes.- Default value for
gcReleaseBufferSizeis now 10. See description in Breaking Changes. ConnectionHandlerwill no longer create edges with anundefinedcursorfield. This also applies to edges created via@appendNodeor@prependNode. (#3278)- Several tests migrated to be compile their
graphqlwith Rust Compiler.
Fixed
If upgrading from experimental release
- If
loadQueryis called and no network request is made (i.e. if the data is available in the store and the fetch policy allows it), the query is retained in the environment. loadQuerynow includes the network cache config in the operation descriptor that is executed against the environment.