Skip to content

v11.0.0-rc.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@jstejada jstejada released this 26 Feb 21:09

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 fetchQuery now returns a lazy Observable which you can subscribe to. It will perform in-flight request de-duping of identical requests. Ignores any Network Layer caching by default, but supports a fetchPolicy to check data cached in the Relay Store.
    • Deprecated: Previous version of fetchQuery renamed to fetchQuery_DEPRECATED. Previous behavior returns a Promise (can’t be observed). No request de-duping.
    • Changes in Exports:
      • react-relay: fetchQuery exported from react-relay now has updated behavior and function signature. To access previous version of fetchQuery, import fetchQuery_DEPRECATED from react-relay or react-relay/legacy.
      • relay-runtime: fetchQuery exported from relay-runtime now has updated behavior and function signature. To access previous version of fetchQuery, import fetchQuery_DEPRECATED from relay-runtime.
  • getDataID was renamed from UNSTABLE_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 gcReleaseBufferSize is now 10 (previously 0).
    • When a query is manually released, for example when a query component unmounts (QueryRenderer or useLazyLoadQuery), 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-network to actually reuse cached data when navigating back to previously visited views.

If upgrading from experimental release

  • The default UNSTABLE_renderPolicy is 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-relay and react-relay/hooks. See this issue for more details.
    • relay-experimental has 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 fetchQuery added. See description in Breaking Changes.

General

  • Added ConnectionHandler.getConnectionID to 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.
  • loadQuery accepts a fetchPolicy of 'store-only'
  • loadQuery now warns, instead of throwing, if called during the render phase.

General

  • getDataID is now a stable config option. See description in Breaking Changes.
  • Default value for gcReleaseBufferSize is now 10. See description in Breaking Changes.
  • ConnectionHandler will no longer create edges with an undefined cursor field. This also applies to edges created via @appendNode or @prependNode. (#3278)
  • Several tests migrated to be compile their graphql with Rust Compiler.

Fixed

If upgrading from experimental release

  • If loadQuery is 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.
  • loadQuery now includes the network cache config in the operation descriptor that is executed against the environment.