Skip to content

Version 18.2.0 Release Notes

Latest
Compare
Choose a tag to compare
@captbaritone captbaritone released this 21 Nov 18:42
· 46 commits to main since this release

Relay version 18.2.0 comes with several bug fixes and improvements!

New compiler capability: Relay Codemods

Codemods are tools which enable you to programmatically update your code. These are especially helpful if you want to upgrade an API across your whole codebase without needing to manually change each call site. The Relay compiler, with its understanding of your GraphQL snippets, is well positioned to help with these kinds of tasks. In Relay 18.2.0 we are introducing Relay Codemods.

We currently support two different codemods:

  • mark-dangerous-conditional-fragment-spreads marks places where @alias is required to make a fragment spread safe. This can enable you to turn on the enforce_fragment_alias_where_ambiguous feature flag. Learn more in the @alias docs.
  • remove-unnecessary-required-directives identifies places where @required is unnecessary because it's used on a non-nullable field within a fragment or query that is @throwOnFieldError, and removes the @required directive.

We are looking forward to helping Relay users with more codemods in the future!

New experimental hook for pagination with prefetching

It is often possible to speed up list pagination by pre-loading one or more pages of results ahead of what the user is currently viewing. Our previous APIs made this difficult to fetch the next page of data without also rendering it at the same time. We are currently exploring an experimental API to make it easy to manage paginated lists with prefetching.

Read more in the docs: usePrefetchableForwardPaginationFragment

Expand places where @catch can be used

The @catch directive can now be used on fragments, queries, mutations and aliased inline fragments. This enables more flexibility in controlling how field errors are handled.

Bug fixes

  • [682ac5a]: Include Relay resolver import type when field is selected on query as well (#4820) by Ernie Turner
  • [d6cb5a2]: Update required-on-non-null validation to also work within @catch by Gordy French
  • [356327c]: Fix bug in Connections with errors by Evan Yeung
  • [9571d80]: Fix result type generic for Error to not double-nest by Itamar Kestenbaum
  • [af35418]: Ignore @dangerously_unaliased_fixme when comparing structs by Jordan Eldredge
  • [f166d6b]: Fix dangling resolver artifact by Tianyu Yao

Improvements

  • [81eab03]: Remove unused fieldPath from resolver suspense objects by Jordan Eldredge
  • [d982b5b]: Add feature flag to opt in/out of including the path field in @required reader nodes by Jordan Eldredge
  • [460508a]: Remove path from @catch codegen by Jordan Eldredge
  • [a88c013]: Derive @required fieldPath at runtime by Jordan Eldredge
  • [7c9aebb]: Add support for @catch on fragments/queries/mutations and aliased inline fragments (#4838) by Jordan Eldredge
  • [08fef89]: Cleanup resolver cache implementation only used in tests by Jordan Eldredge
  • [2c3b915]: Cleanup AVOID_CYCLES_IN_RESOLVER_NOTIFICATION by Jordan Eldredge
  • [2705e3d]: Add support for handling field errors on noncompliant lists by Ryan Holdren
  • [402aa97]: Update message in handlePotentialSnapshotErrors for payload errors by Itamar Kestenbaum
  • [8421851]: Improve error message when directive is used in wrong location by Jordan Eldredge
  • [3eb627d]: Add fieldPath to missing data field error logs (#4835) by Jordan Eldredge
  • [bac814f]: Use prefetchable metadata in the prefetchable pagination hook by Tianyu Yao
  • [d079b29]: Allow @required on connection fields by Jordan Eldredge
  • [733cc27]: Add schema name to project config by Monica Tang
  • [ebf028b]: Use directive location where it makes sense by Gordy French
  • [d3eb42f]: Don't require @alias on plural fragments spread into plural selections by Jordan Eldredge
  • [e21e162]: Allow codemod to specify rollout percentage by Gordy French
  • [e4facf3]: Allow granular FeatureFlag gating of @alias enforcement by Jordan Eldredge
  • [deb7b09]: Allow users to return ID built in scalar using DataID by Jordan Eldredge
  • [3c92504]: Fix slow typegen in adslab by Tianyu Yao
  • [6e4c120]: Update error message for clarity by Jordan Eldredge
  • [5c548bd]: Allow @dangerously_unaliased on @inline fragments by Jordan Eldredge
  • [2cf6c7f]: Codemod command runs and collects code actions by Gordy French
  • [ad26284]: Make required-on-non-null-within-throwOnFieldError an LSP warning by Gordy French
  • [b41ae4c]: Support semantic non-nullable RelayResolverValue by Jordan Eldredge
  • [eba1d97]: Allow strong resolvers to reference opaque types by Jordan Eldredge

Documentation Improvements

  • [9401e69]: - add new client 3D page in 3D docs by Lynn Yu
  • [6a51b39]: - 3D docs starting point by Lynn Yu
  • [caa040a]: - document all top level functions in relay compiler by Lynn Yu
  • [1306086]: - document all top level structs in relay compiler by Lynn Yu
  • [86301c7]: - document all modules in relay compiler by Lynn Yu
  • [bdbe7e0]: Add rust docs for all top level enums in relay compiler by Lynn Yu
  • [5600502]: - document semantic nullability support in resolvers by Lynn Yu
  • [c3b0dd5]: Docs: Fix fragments tutorial thumbnail typo (#4841) by Daniel Stocks
  • [5b7dc1f]: Add docs for usePrefetchableForwardPaginationFragment by Tianyu Yao
  • [5cccb7b]: - adding docs for abstract types in relay resolvers by Lynn Yu
  • [ebc4936]: Minor updates to docs on enabling relay resolvers (#4824) by Arthur
  • [4776175]: Update docusaurus to 2.4.3 by Gordy French
  • [0b4920d]: - delete old relay doc versions older than 2 years by Lynn Yu
  • [b8967d2]: Add documentation for codemods (#4826) by gordyf
  • [7c2b460]: Update description of dangerously_unaliased_fixme directive by Jordan Eldredge

Miscellaneous

  • [9eb9c94]: Update to latest react@experimental (#4847) by Lauren Tan
  • [7e258ca]: Add @relayRequiredVariables to metadata section of generated .graphql files by Jean Zhang
  • [4360f69]: Deprecate GK relay_enable_load_query_request_deduping by Nithik Balachandran
  • [15a19e9]: Update metadata generation for Live Query in Relay compiler by Xiangxin Sun

Experimental Changes

  • [30af003]: Add a runtime feature flag for prefixing read-time resolver storageKeys by Evan Yeung
  • [195d9a2]: Fix usePrefetchablePagination bug by Tianyu Yao
  • [57756e6]: Allow reusing fetching options in usePrefetchableForwardPaginationFragment by Tianyu Yao
  • [023b875]: Support dynamic switching of read vs exec time resolvers in reader by Evan Yeung
  • [53cef9d]: Update hook to expose data in UNSTABLE_extraVariables by Lynn Yu
  • [d036d49]: Update normalization artifacts for exec time resolver strong ids by Evan Yeung
  • [9035b32]: Generate prefetchable pagination ASTs by Tianyu Yao
  • [dececd1]: Generate metadata for prefetchable pagination by Tianyu Yao
  • [4a67ddd]: Create a separate edge fragment for prefetchable pagination by Tianyu Yao