Skip to content

Releases: facebook/relay

v11.0.1

24 Mar 14:00
Compare
Choose a tag to compare

Fixed

  • Fixed several broken website redirects
  • Store updater directives: do not insert existing node again in connection (#3373)

Documentation Improvements:

This release contains a set of updates to the new Relay website. Some of the PRs are listed here explicitly.
Thank you for your contributions.

  • Replace preloadQuery with loadQuery (#3412)
  • Remove mutation from the server specification (#3381)
  • Fix markdown issue in fragments.md (#3408)
  • Fix typos in loading-states.md (#3411)
  • Fix typos in docs (#3400)
  • Fix typo in the code example in "Introducing Relay Hooks" (#3399)
  • Update use-mutation.md (#3393)
  • Updated load-query.md (#3391)
  • Update use-pagination-fragment.md (#3392)
  • Fix typos in the "Introducing Relay Hooks" blog post (#3394)
  • Thinking-in-graphql.md small typo (#3386)
  • Fixes typo in docs (#3389)
  • Switch text under headings to be <p> (#3385)
  • Fix markdown issue in use-preloaded-query.md (#3384)
  • Use updated Flow object syntax (#3387)

v11.0.0

09 Mar 14:56
Compare
Choose a tag to compare

For our announcement on Relay Hooks, check out our blog posts on relay.dev and Facebook Open Source. For docs, see our updated docs website at relay.dev/docs, and for an update on our upcoming releases, see this issue.

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 Layercaching by default, but supports a [fetchPolicy](https://relay.dev/docs/en/experimental/a-guided-tour-of-relay#fetch-policies) 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 releases.

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.

v11.0.0-rc.0

26 Feb 21:09
Compare
Choose a tag to compare
v11.0.0-rc.0 Pre-release
Pre-release

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.

10.1.3

22 Jan 18:43
Compare
Choose a tag to compare

Improvements

  • Improve testing documentation grammar (#3296)
  • Support multiple edges in @appendEdge and @prependEdge [2425572]

Fixed

  • Display code context for single error, fixes #3318 (#3322)
  • Fix accidental cancelation of network request when using loadQuery APIs [20e8b6b]
  • loadQuery dedupes requests even before AST is available [4527a5b]

Misc

  • Documentation fixes and improvements (#3327)
  • Remove "use strict" directive from ES modules [5d555a4]
  • Bump node-notifier from 8.0.0 to 8.0.1 (#3301)
  • Convert RelayReader-test.js to use new compiler [c0f0f10]
  • Convert ReactRelayFragmentContainer-WithFragmentOwnership-test.js to use the new compiler [ff0ad17]
  • Convert ReactRelayPaginationContainer-test.js to use the new compiler [bede32d]
  • Convert ReactRelayRefetchContainer-WithFragmentOwnership-test to use the new compiler [20051f6]

10.1.2

15 Dec 20:22
Compare
Choose a tag to compare

Improvements

  • Avoid throwing in the DeclarativeMutationHandler when the server returns null [9d31dfb]
  • Remove old network event names [5075851]

Fixed

  • Bump ini from 1.3.5 to 1.3.7 (#3293)
  • Bump ini from 1.3.5 to 1.3.7 in /website (#3292)
  • Fix code example typo in homepage (#3290)

10.1.1

07 Dec 21:42
Compare
Choose a tag to compare

Improvements

  • Mark failed network requests on preloaded query references (f59d71249)
  • Refactor notifying store subscriptions for better consistency update perf (under feature flag) (ad6532807)

Fixed

  • Require babel helpers instead of inlining (#3188)
  • Ensure network requests are always logged (95606c5ed)
  • Memoize the cache config in useMemoOperationDescriptor (81d24d21a)
  • Remove unstable_next from useLoadMoreFunction (3242c5800)

Misc

  • Add missing peer dependency in website/package.json (#3262)
  • Add missing copyright headers (bc55eb6c8)
  • Refine typescript type generation (#3239)
  • Extract store subscription management into separate module (d64b57987)
  • Remove link to GraphCool from prerequisites page (#3173)
  • Update website/i18n/en.json (#3261)

10.1.0

16 Nov 15:40
Compare
Choose a tag to compare

Added

  • Added @appendNode and @prependNode declarative mutation directives for inserting a node to connections (#3155) [0fe732d]
    • Usage: comments @appendNode(connections: $connections, edgeTypeName: "CommentEdgeType") { id }
  • Added @deleteEdge directive for removing the edge from connections (#3177) [01d65b3]
    • Usage: deletedCommentId @deleteEdge(connections: $connections)
  • Added plural support for @deleteRecord directive (#3135) [27f938c]
    • Usage: deletedCommentIds @deleteRecord
  • Made scheduleGC a public function inside RelayModernStore (#3167) [97401cb]
  • Added cacheConfig in RequestDescriptor (#3070) … [eb256a3]

Improvements

  • Remove fragment naming enforcement from JS compiler [ff1c10b]

Fixed

  • Docs: fix typos of the 'A Guided Tour' page (#3236) [e4413bf]
  • Fix prependNode and prependEdge in declarative connection [7c836df]
  • Fix warning for plural fragment ref pointing to null data [c1a6831]
  • Don't setTimeout in loadQuery in SSR [2da0325]
  • Fix @match with __typename: other in MatchContainer [92c8d68]
  • Fix conflicting field value warning [7e3deb4]
  • Bugfix for validating optimistic updates containing undefined fields … [6a1586d]
  • Dispose nested entrypoints when calling dispose() [d5352a2]

Misc

  • In @relay/react-relay, we now use ^16.9.0 || ^17 as a peerDependency.

Experimental

  • Added various minor improvements and fixes to the loadQuery API.
  • useQueryLoader now accepts an initial query reference.
  • Prevent usePreloadedQuery from consuming stale cached query refs
  • Stop caching errors at fragment boundaries, which prevented
  • Warn when attempting to use an already disposed PreloadedQuery or PreloadedEntryPoint [187bd34]
  • Make sure loadQuery requests are deduped when started (vs at render time) [a21b1cb]
  • Add Relay log event for when an EntryPointContainer uses an entrypoint component resource [7818bfb]
  • Create type utility EntryPointElementConfig [7d02240]
  • Unsubscribe network requests when releasing temporary retains [933b280]
  • Optimize getFragmentIdentifier [ac3a252]
  • holdGC for incremental responses in QueryExecutor [b3ecce2]

Relay Compiler in Rust

The Relay team is actively working on the new compiler implemented in Rust. The majority of recent changes you can see in the repo are related to the compiler. This new version won't be included in the release, as we are still working on the migration strategies for our OSS customers.

Thank you for all outstanding contribution to the Relay compiler (#3182)

v10.0.1

23 Jul 22:20
Compare
Choose a tag to compare

Experimental

  • Remove persisted query id invariant from loadQuery (4b88a13)
  • Dispose nested entrypoints when calling dispose() (d5352a2)

v10.0.0

13 Jul 19:30
Compare
Choose a tag to compare

Breaking

  • Change missing field handlers for “linked” fields to treat null as null. Previously, returning either null or undefined indicated that a value could not be determined, and there was no way to indicate that the field value should be set to null. To indicate "no value can be provided", return undefined instead (f106ca0)

Added

  • New Declarative connection mutations: we added several directives to make common store updates in mutations easier. An updater is no longer required for following cases: @deleteRecord (applied to a field of type ID) will delete the record with the given id from the store. @appendEdge and @prependEdge (applied to a connection edge field) will append or prepend the edge to the listed connections (07ccab7, 687d89b, 2719324)
  • Precise type refinement: gated by RelayFeatureFlags.ENABLE_PRECISE_TYPE_REFINEMENT. With this feature enabled Relay more accurately models GraphQL semantics around inline fragments and fragment spreads which have a different type than their parent selection. This helps Relay to more accurately determine if a query can be fulfilled from the cache (ie with the ‘store-or-network’ fetch policy) and also more accurately determine if data is missing and that a component should suspend. Generally speaking, the change is observable as fewer false positives where Relay thinks data is “missing” when it isn’t. This feature will be enabled by default in a subsequent release; we recommend enabling it now. (00985e1, 11bf467, ef93983, 1e0dba0, 3318719, f7ba970, 08ba6f0, 7c67b47, 2cf9ac9)
  • Warn if a single GraphQL response contains conflicting values for a given field on the same entity (same DataID) (87520d3)
  • Optimize RequestIdentifier. Previously if the query was not persisted this used the full query text, now a hash of the query is used instead (a3acc08)
  • Enable parsing of Flow enums (bcd7a81)
  • Add the referenced DataIDs in the store.gc log event (adb64b7)
  • Garbage collection is now yieldy: the GC mark/sweep yields after processing each unit, restarting if a write to the store occurs (687e332)
  • PreloadableQueryRegistry is moved from experimental to relay-runtime (6fe4323)

Fixed

  • Fixed fatal in joinArgumentDefinitions (85b44e7)
  • Generate a static storageKey on field nodes for lists and objects whose values are all static (34b1dc0)
  • Fix @refetchable query generation for interfaces without own id field (d307b37)
  • Avoid a memory leak that can occur in some JS runtimes where Error objects can retain data on the call stack until its stack property is evaluated (2859aa8)
  • Fix bug with treatMissingFieldsAsNull flag and client extensions (5085aea)
  • Fix a memory leak (8c1e91b)

Misc

  • Added internal utility types PreloadPropsOf and VariablesOf (796950e, f1f784f)
  • Use isMountedRef internal hook in query and EntryPoint loaders (61c8627)
  • Emit LogEvents for Store publish/notify (60b339b)
  • Flow updates: add codes to error suppressions, don’t mix import/require in flowtests (fba7930, 232dd95)
  • Removed unused request parameter in ResponseNormalizer options (651ced5)
  • Make RelayError messages parameterized (0e72854)
  • Print the @defer and @stream directives last (this helps with parity between the JS and Rust compiler output) (7271283)
  • Run the SkipRedundantNodes transform on SplitOperation nodes (used for data-driven dependencies) (1bc049e)
  • Sort test metadata object keys (9a5cd5c)
  • Use scheduler to schedule consistency updates outside of QueryExecutor (8af3355, 315bcf9)
  • Fixed spelling mistakes: (564310d, c472ba3)
  • Cleanup unused code: (fba7c8a, 92b110b, 56dc1d6, 681f0cd, a9cbabe, 37ae1e7, 292b1e8, 8bb5809)
  • Update generated label for defer/stream nodes (2ae19c3)
  • Sort keys of objects appearing as default values in arguments (3b8a288)
  • Remove plural: false metadata in generated artifacts (487016f)
  • Sort type spreads in the generate id transform (3de995a)
  • Sort metadata on generated artifacts by key (bf5484c)
  • Remove nonStrictEnums setting for defaultValues (78847c6)
  • Sort argumentDefinitions in queries generated by RefetchableTransform (c4ec34b)
  • Add environmentProviderOptions to PreloadedQuery (2365b01)
  • Remove unused type in argument definitions (812e0f4)
  • Sort fragment arguments, updated artifacts (b065ae2)
  • Remove number of arguments check for fetch queries (9e29299)
  • Generated ID fields now have the type from the schema (b63815b)
  • Rename cacheTime property to fetchTime (57719cc)
  • Remove unused fragmentRefPathInResponse argument (251703e)
  • Ensure cursor/count metadata check is limited to extraVariables in getPaginationVariables (84565d4)
  • GenerateTypeNameTransform generates non-nullable String type for __typename (b128d82)
  • Fix check for whether a type is client type (1ccf069)
  • Fix printing indentation of conditions (cdd2c47)
  • Apply fragment arguments on Defer/Stream node (8d8ba8b)
  • Remove ValidateServerOnlyDirectivesTransform from IRTransforms (9593d57)
  • Remove label arg from @stream_connection (2e2be4c)
  • Strip compiler-only metadata from generated files (2299878, fddd31b)
  • Also create a proxy for executeWithSource in RelayModernMockEnvironment (8b3df8c)
  • fetchQueryDeduped accepts a RequestIdentifier instead of an OperationDescriptor (041c6ec)
  • remove type condition from @defer fragments (23300a9)
  • Add onLoad support to PreloadableQueryRegistry (8242adc)

Experimental

  • New useQueryLoader() and useEntryPointLoader() hooks for loading queries and EntryPoints from a component. These hooks wrap the internal loadQuery() and loadEntryPoint() APIs to manage the lifecycle of returned resources (ie, disposing the resources when the component un-mounts) (676660d, f512c9f, c819d41, d64fe26)
  • Misc
    • Relay Hooks: useDebugValue to show fragment/query values (e913579)
    • Expose networkCacheConfig in preloaded query references (605ac7f)
    • Handle case where loadQuery result is rendered under a different environment (08bb2d2)
    • Don't expose preloadQuery from relay-experimental (d1c8cb5)
    • Remove PreloadableQueryRegistry from relay-experimental (not a public API) (52ccd26)
    • prepareEntryPoint returns void and is deprecated (a5534ea)
    • Removed (internal) variant of PreloadedEntryPoint (09b8236)

v9.1.0

28 Apr 18:40
Compare
Choose a tag to compare

9.1.0

Added

Fixed

Misc

Experimental