Releases: facebook/relay
v11.0.1
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
withloadQuery
(#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
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 lazyObservable
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 fromreact-relay
now has updated behavior and function signature. To access previous version offetchQuery
, importfetchQuery_DEPRECATED
fromreact-relay
orreact-relay/legacy
.relay-runtime
:fetchQuery
exported fromrelay-runtime
now has updated behavior and function signature. To access previous version offetchQuery
, importfetchQuery_DEPRECATED
fromrelay-runtime
.
- New: New version of
getDataID
was 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
gcReleaseBufferSize
is now 10 (previously 0).- When a query is manually released, for example when a query component unmounts (
QueryRenderer
oruseLazyLoadQuery
), 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.
- When a query is manually released, for example when a query component unmounts (
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
andreact-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 afetchPolicy
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 anundefined
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
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 lazyObservable
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 afetchPolicy
to check data cached in the Relay Store. - Deprecated: Previous version of
fetchQuery
renamed tofetchQuery_DEPRECATED
. Previous behavior returns a Promise (can’t be observed). No request de-duping. - Changes in Exports:
react-relay
:fetchQuery
exported fromreact-relay
now has updated behavior and function signature. To access previous version offetchQuery
, importfetchQuery_DEPRECATED
fromreact-relay
orreact-relay/legacy
.relay-runtime
:fetchQuery
exported fromrelay-runtime
now has updated behavior and function signature. To access previous version offetchQuery
, importfetchQuery_DEPRECATED
fromrelay-runtime
.
- New: New version of
getDataID
was 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
gcReleaseBufferSize
is now 10 (previously 0).- When a query is manually released, for example when a query component unmounts (
QueryRenderer
oruseLazyLoadQuery
), 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.
- When a query is manually released, for example when a query component unmounts (
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
andreact-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 afetchPolicy
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 anundefined
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
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
10.1.1
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
Added
- Added
@appendNode
and@prependNode
declarative mutation directives for inserting a node to connections (#3155) [0fe732d]- Usage:
comments @appendNode(connections: $connections, edgeTypeName: "CommentEdgeType") { id }
- Usage:
- Added
@deleteEdge
directive for removing the edge from connections (#3177) [01d65b3]- Usage:
deletedCommentId @deleteEdge(connections: $connections)
- Usage:
- Added plural support for
@deleteRecord
directive (#3135) [27f938c]- Usage:
deletedCommentIds @deleteRecord
- Usage:
- 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 apeerDependency
.
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
v10.0.0
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
9.1.0
Added
- Add option in Environment to handle stripped nulls in payload by [email protected], 2020-04-21 (7a798d1)
- Added queryCacheExpirationTime option to RelayModernStore. Query data in the Relay store will be treated as stale after expiration (add maxTtl to relay store by [email protected], 2020-04-06 (bb88806))
- Change toPromise to complete Observable by [email protected], 2020-04-02 (9ef158d)
- make the relay environment not responsible for determining whether it is a server environment by [email protected], 2020-04-01 (d11e649)
- sort object keys alphabetically by [email protected], 2020-03-19 (d3ccdf0)
- Allow duplicate 3D selections w identical fragment+module by [email protected], 2020-03-19 (7b4870f)
- Expose query id in preloaded query references by [email protected], 2020-03-10 (98e5cb6)
- MockPayloadGenerator: do not generate data for CLIENT_EXTENSIONS by [email protected], 2020-03-04 (b9f14db)
Fixed
- rework persisted query re-using by [email protected], 2020-04-02 (adaa938)
- Visit SplitOperation in ApplyFragmentArgumentTransform and SkipUnreachableNodeTransform by [email protected], 2020-04-02 (8cfd01d)
- sort object keys in missing cases by [email protected], 2020-03-31 (3d218a7)
- Move SplitModuleImport transform to Relay Query Transforms Pipeline by [email protected], 2020-03-31 (eb06184)
- remove loggerProvider from RelayModernMockEnvironment by [email protected], 2020-03-27 (fa1320c)
- Relay Modern Store: always update the root entry fetch time in notify by [email protected], 2020-03-27 (62a229a)
- fix inverted case of sorted object keys rollout by [email protected], 2020-03-25 (6d1d830)
- fix missing sort of operation object keys by [email protected], 2020-03-24 (4d62e24)
- Avoid removing directives on inlineFragment in FlattenTransform for printing by [email protected], 2020-03-24 (3b18897)
- Stop wrapping FragmentSpread on client type in ClientExtension by [email protected], 2020-03-24 (e8e99c9)
- Fixed feature flag for containers suspending which should be off by default by [email protected], 2020-03-23 (061a680)
- Fix generated aliases for 3D fields with keys by [email protected], 2020-03-20 (84df7a4)
- Enforce that multiple 3D selections per document use a unique key by [email protected], 2020-03-18 (0ace9d3)
- Fix validation of
handler
arg in @connection validation by [email protected], 2020-03-09 (62a10d8) - Add flow types for ReactTestRenderer by [email protected], 2020-03-05 (7be1a84)
- Allow client-side schema extensions in optimisticResponse by [email protected], 2020-03-03 (b00736e)
- Remove existingFragmentNames compat feature by [email protected], 2020-02-27 (a49b208)
- Refactor store release buffer management by [email protected], 2020-02-20 (c8471bf)
- Disallow typename on Root by [email protected], 2020-02-18 (793729e)
Misc
- cleanup @relayRequestID header rollout by [email protected], 2020-04-02 (8d71ae1)
- remove redundant check for node type by [email protected], 2020-04-02 (2edce9f)
- remove sort-object-keys rollout by [email protected], 2020-04-02 (640cf9c)
- Use React.useTransition for relay-experimental tests instead of copied version by [email protected], 2020-03-26 (1befdc0)
- easy: fix typos in relay modern store by [email protected], 2020-03-23 (a9d8910)
- add test for explicit null argument (#3047) by [email protected], 2020-03-13 (027fbd1)
- Add more snapshots for printing conditions to match Rust tests by [email protected], 2020-03-06 (24180d7)
- Add 2 JS snapshot tests to SkipRedundantNodesTransform by [email protected], 2020-03-06 (9883c81)
- add profilerContext to queryresource.fetch event by [email protected], 2020-02-28 (ac22671)
- update getModuleName to skip all extra suffixes in the filename by [email protected], 2020-02-14 (4370cac)
Experimental
- add useSubscription hook by [email protected], 2020-02-26 (42056a7)
- add fetchPolicy support in fetchQuery by [email protected], 2020-04-06 (7395010)
- Remove unsafe cancelation of query in flight in concurrent mode by [email protected], 2020-04-03 (b96441b)
- Fix recycling of data in FragmentResource::subscribe by [email protected], 2020-02-19 (2093478)
- Fix unsafe tracking of refetch generation in useRefetchableFragment for concurrent mode by [email protected], 2020-04-06 (a8614dd)
- Clean up useBlockingPaginationFragment tests for latest React Suspense fixes by [email protected], 2020-03-31 (baa11ce)
- Minor cleanup of useBlockingPagination w/ Suspense test by [email protected], 2020-03-31 (754c64f)
- Re-enable Suspense useBlockingPagination test which was accidentally disabled by [email protected], 2020-03-30 (dc47d6f)
- Disallow user defined object to be used in fragmentRef arguments by [email protected], 2020-03-18 (084e165)
- Disallow user defined object to be used as key in useFragment by [email protected], 2020-03-17 (b1442b9)
- Minor refactor of useLazyLoadQuery test by [email protected], 2020-03-06 (5ec8737)
- Fix useMutation with fast refresh by [email protected], 2020-02-24 (86f5456)
- Rename useIsParentQueryInFlight to useIsParentQueryActive by [email protected], 2020-02-19 (3794f0b)
- Fix concurrent mode data race when calling loadNext and checking for active request by [email protected], 2020-02-19 (251701d)
- Remove extraneous
extraOptions
field. by [email protected], 2020-02-12 (2b86977) - add queryresource.retain event by [email protected], 2020-03-30 (cc57287)