Releases: facebook/relay
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)
v9.0.0
9.0.0
Breaking
- Rename
getModernOperationVariables
togetOperationVariables
Added
- Added
queuePendingOperation
toRelayModernMockEnvironment
in testing tools. This allows the caller to manually register an operation that should be pending. - Optionally output eager es modules (#2781).
- Expose a way to override isGeneratedFile function via language plugin (#2810).
- Allow language plugin to specify how generated files should be named (#2866).
- Allow language plugin to specify how to check for presence of
graphql
strings (#2811). - Setup external config for Relay Compiler.
Fixed
- Ensure root record is always created upon store initialization, even before initial query has been processed.
- Fix disposable of optimistic updates: 87ef4ed
- Fix various issues in docs.
- Fix loading external config for Relay Compiler (#2999).
Misc
DataChecker::check
now returns the operation fetch time.- Removed
getRelayDefaultMissingFieldHandlers.js
Experimental
- Fix leaking environments when using Relay Hooks (#3014).
- Fix support of Fast Refresh when used with Relay Hooks.
- Fix recycling data for plural fragments; i.e. return an array with the sam object identity if the data hasn’t changed.
- Add support for batched
@stream
’ed responses. - Internally renamed
useLegacyPaginationFragment
tousePaginationFragment
. - Potentially Breaking
preloadQuery
will error if called during render.- Remove new connection model experimental code.
- We know check for “active” instead of queries in “flight” when determining when to suspend. An operation may be indefinitely in flight (e.g. a live query, or a GraphQL Subscription), but it’s only “active” if it’s actively receiving payloads, e.g. during
@stream
ing or@defer
.
v8.0.0
8.0.0
Commits: v7.1.0...v8.0.0
Breaking
- Relay Compiler no longer relies on the
graphql-js
schema representation. And consumes only SDL file that represents the schema. This means that all custom implementations relay compiler runners that were depended on the specifics of thegraphql-js
may not work as expected. Specifically, custom Enum values are no longer available in the relay-compiler - as they cannot be expressed via SDL. Also, custom functionparseValue
,parseLiteral
andserialize
that can be defined for a graphql type viagraphql-js
primitives are not accessible in the relay compiler: this may break serialization of custom scalars. 860c23c - Babel plugin no longer produces thunks: 490c89d
- Mutations are committed to unique root ids #2349. In mutation updaters, fields in the mutation will no longer be available in the store root returned from
store.getRoot
. Usages likestore.getRoot().getLinkedRecord('create_comment_mutation')
will break. - Removed internally unused
RelayRecordSourceProxy::commitPayload()
. Note that this method was not part of the public interface. - Signature of
RelayStore.retain()
changed to directly accept anOperationDescriptor
. An operation descriptor to pass toRelayStore.retain
()can be constructed using
createOperationDescriptoravailable in
relay-runtime`.
Added
- Allow language plugin to add schema extensions. #2935
- In
relay-compiler
we added support for variables in complex objects and arrays: 5da3be0 isClientID
helper is available to use inrelay-runtime
dac614c
Fixed
-
Remove the
clientMutationId
requirement by creating a new root id for each executed mutation: #2349 -
validateMutation
correctly handles lists of scalar fields in the optimistic payloads: 56795ba -
DissalowIDAsAlias
this validation had a bug, there it wasn't traversing LinkedFields, hence wasn't reporting violations in their selections. c4547f9 -
RelayModernFragmentSpecResolver
only holds on to fragment references as opposed to all props passed to product code to reduce amount of leaked memory when rendering in React concurrent mode. -
Fixed detecting whether the execution environment is a server: #2960
Misc
- Relay codebase is using explicit inexact objects: 4e2cc2f
- Added an
options
property onIEnvironment
for attaching extra information to the environment instance - Updated docs to consider Relay server specifications GraphQL best practices and not purely a Relay spec: #2603
- https://relay.dev has a new landing page redesign: #2953
Experimental
- Data Invalidation: Added new Data Invalidation primitives to allow marking data in the Relay Store as stale. When data is marked as stale, queries that reference that data will also be stale; stale queries will indicate to Relay that they need to be refetched the next time they are evaluated.
- Deprecate
LazyLoadEntryPointContainer
=>LazyLoadEntryPointContainer_DEPRECATED
: 08bde91 - Removed Unused types from RelayStoreTypes 76354e9
usePreloadedQuery
now takes an unstableUNSTABLE_renderPolicy
likeuseLazyLoadQuery
: fc1b88buseMutation
Hook was added: 96d9703- Export a
JSResource
Flow interface from Relay. - Fixed subscribing to plural fragments with missing data when using
useFragment
.
v7.1.0
7.1.0
Added
- New warning in RelayPublishQueue if if RelayPublishQueue::run() is called again during a run(): 3823534
- Support for the new configuration option in the compiler (aa1453b) writerConfig.writeQueryParameters - that can accept the function:
writeQueryParams: (
dir: CodegenDirectory,
filename: string,
moduleName: string,
params: RequestParameters,
) => void
Fixed
- Compiler: fix validation of required fields with default values #2903 by @mrtnzlml
- [Allow non-nullable Viewer field in ViewerQueryGenerator #2924 by @janicduplessis
- Add exports to relay-runtime to make available in relay-experimental: a0fc101
Misc
- Renaming/cleanup in the compiler: Moving some parts of the new codegen runner to OSS, removed redundant prefixes.
Experimental
- Allow an extraOptions object on PreloadOptions: 68e893e
- Allows passing a raw query to
preloadQuery()
, which makes it usable without the special $Parameters file: edb4670 getModuleIfRequired
replaced withqueryResource
in the EntryPoints: 32f4a71- Added new Relay Experimental Docs: 3f7ba11
- Added Step-by-step guide to Relay Hooks: 2d1473f
- Add support for loading 3D resources in optimistic responses: bef3551
v7.0.0
7.0.0
Commits: v6.0.0...v7.0.0
Breaking
-
Variables are no longer set in Relay Context when using a
QueryRenderer
. This means that any product code that was relying on reading variables fromRelayContext
will break. If you need to access the variables that were set at a query root, the recommended approach is to manually pass them down through the component tree in product code. -
Removed old RelayNetworkLogger, and
relay-runtime
no longer exportscreateRelayNetworkLogger
. This logger is being replaced with event based logging on theEnvironment
which will allow us to have richer and more contextual events logged with more detail on what's going on. Wrapping the actual network request doesn't work well as some "requests" might never actually end up on the network when they can be fulfilled completely from the store. -
The constructor signature of
Store
constructor changed; specifically the second argument to the constructor is now an options object. Any product code directly constructing aStore
and passing a second argument will need to be updated. -
Relay Compiler no longer relies on
graphql-js
for query validation. Most of the validation rules we used previous are now part of the RelayParser itself, while the remainder and implemented as transforms (15e8d22). Additionally, we've removed the concept of RelayIRValidations (da01bf3), which ran after IR transformation. -
@defer
is no longer allowed on inline fragments, since we can’t communicate a loading state with Suspense when used on an inline fragment.@defer
is now only supported on fragment spreads.
Added
- RelayCompiler: added a new directive (3dd79e8)
@DEPRECATED__relay_ignore_unused_variables_error
to suppress errors that were surfaced after we've migrated from GraphQLNoUnusedVariablesRule
to RelayIRTransform validation. GraphQLNoUnusedVariablesRule
was not aware of the difference between root (operation) variables and local fragment variables (defined by @argumentDefinitions) - because of that, it was considering the local fragment variables that have the same name as the root variable as used and did not report the violation. But in Relay compiler, we know this distinction, and we already keep track of the root variables and can report those invalid cases. Unfortunately, this revealed multiple violations that weren't possible to fix without product team involvement. For this purpose, we added a directive that can be used to temporarily suppress the error while teams fix their queries.
Improved
- Relaxed the constraint for
@refetchable
directive on a fragment: we no longer enforce that the argument for thenode
field is calledid
; it can be called anything as long as it’s anID
type. - Developers can now select the
__id
field anywhere that__typename
can be selected, in order to fetch the internal cache key of an entity. The primary use-case for this is updating records that don’t have anid
. Before, updating or deleting such entities would require writing an updater function that traversed from the nearest strong entity (w an id); now, developers can directly target records with e.g.store.get(record.__id)
in an updater function.
Fixed
- RelayCompiler: Usage of $variables in Complex objects (or as List Items) is now disabled by RelayParser: 6946e85 This was already unsupported, but Relay previously threw an error later in compilation.
- MockPayloadGenerator: allow
null
as default value of enum: 6946e85 - Fix display names for containers.
- Fixed
@refetchable
connection metadata for custom handlers. - Fixed missing field handler behavior for plural linked fields.
- Fixed getRefetchMetadata to handle both commonjs and esmodules. (#2875)
- Fixed printing require module dependency in generated artifacts. (#2861)
Misc
- Upgraded React peer dependency to
16.9.0
. - Upgraded
babel-preset-fbjs
to 3.3.0 - RelayCompiler: We've changed the field
type
andtypeCondition
in GraphQL IR types to use Relay internal representation of GraphQL type (2606f32). Before this change, we were directly usinggraphql-js
type instances. But eventually, our goal in Relay compiler is to get rid of the dependency on thegraphql-js
schema representation and use a faster/less memory intensive representation of the schema. We also build a Schema wrapper: 9e6d919 - that should help us during this migration.
Experimental
- Several performance improvements to the internal implementation of
useFragment
were shipped. - Fixed issue to stop tracking mutations as in flight in the RelayOperationTracker when applying the optimistic update; this caused issues with suspending unexpectedly.
- Fixed issue to stop tracking GraphQL subscriptions as indefinitely in flight in the RelayOperationTracker; instead, subscriptions should only be tracked as in flight when they’re waiting for incremental or module payloads. This caused issues with suspending indefinitely in some cases.
- Fixed issue to correctly dispose of ongoing requests when unmounting a
useQuery
hook; this might happen whenuseQuery
starts a long-lived request, e.g. to poll for real time data. - Fixed issue in
useQuery
to not suspend indefinitely when server response doesn’t return all of the requested data. This might occur for example when making selections on abstract types. - Fixed re-establishing store subscriptions when using
useBlockingPagination
. - Fixed pagination with Relay Hooks when using fragments that contain
@argumentDefitions
. - Pagination with Relay Hooks is now allowed even if server returns value for
hasNextPage
as false. - Several improvements to new experimental representation of connections.
- Temporarily exposed new option for useQuery:
renderPolicy_UNSTABLE
, which determines whether data should be eagerly or lazily rendered.
v6.0.0
Commits: v5.0.0...v6.0.0
Breaking
- Environment no longer supports a configurable PublishQueue, this is a prerequisite for upcoming changes to support a new connection representation and the Store interface changes (see below): 44edf14
- Changed the Store interface, adding snapshot() and restore() methods and changing the way that PublishQueue/Store coordinate to revert/rebase optimistic updates: a5c903d
- Note: this should have no impact on users who use the default Store implementation; the main impact is to alternate store implementations and consumers thereof.
- Removed the unused RecordSource interface load() method: bd15d4e
- Changed dataFrom prop in ReactRelayQueryRenderer to fetchPolicy, changed 'STORE_THEN_NETWORK' to 'store-and-network'.
- Changed $key in flow type for plural fragments to plural ($ReadOnlyArray<>)
- environment.unstable_internal has been removed, since we no longer need to support Relay Compat.
- Minimum required React version is now 16.9.0
Added
- Added unreleased relay-experimental package which contains experimental version of Relay Hooks using React Suspense.
- Added a LocalQueryRenderer that has the same API as QueryRenderer, and only renders from data in the store.
- @inline directive and readInlineData() function that enables data masking for functions instead of React components.
- Added an @raw_response_type directive on query, mutation and subscription. With the directive, a new flow type will be added to the generated artifact that represents the shape of the server response.
- New documentation for Client Schema extensions and managing local data was added.
Improved
- Validate that required arguments are provided in compiler.
- Don't include (70453f2) @babel (https://github.com/babel) packages in generated bundles ( (70453f2f0aa356b46225161f05be35594d366e35)#2764 (#2764)) (70453f2)
- Made several performance optimizations for our compiler transforms.
- Allow RelayFileWriter to specify the filesystem object (#2837)
- Can now configure persistFunction with relay config.
Fixed
- Various fixes to the MockPayloadGenerator
- Fix edge case in ConnectionHandler when field is unset
- Fixed relay-compiler babel polyfill problem.
- Use reporter to report changes (#2838)
- Use global state for persisted queries to fix --watch (#2625 (#2625))
Misc
- v6.0.0 should now be compatible with React 16.9.0.
- Experimental: work-in-progress support for a new approach to representing connections, with changes starting in 6f01295. The new connection representation is not feature complete and disabled by a feature flag. The APIs are highly likely to change.
- Added a new implementation of the RelayRecordsSource (available behind a feature flag)
v5.0.0
Commits: v4.0.0...v5.0.0
Breaking
react-relay
containers no longer consume variables from React context, but instead from fragment owners passed through fragment refs. This means that if you have a custom QueryRenderer or other component that set Relay Context, setting variables on that context will no longer affect descendant components.
Added
- Expose ability to pass custom scalar configuration to compiler (#2745 by @alloy)
- Add relay-config package to manage compiler configs (#2746 by @alloy)
Improved
- Improved DX for working on Relay as non-FB dev (#2749 by @alloy)
- Added Support for getDataID() function: 311412b
- Updated Internal Testing Tools to explicitly mark fixtures that should throw: https://github.com/facebook/relay/commit/a6b388b598c18f83811699ef1eea00887b5d217
- Added Memoization for Compiler Transforms:
- Relay Testing Tools Update: Handle Arrays in MockResolvers
- Refetchable fragments are allowed on abstract types not directly implementing Node: 87930e1
- ID field is now automatically added to @refetchable fragments on types implementing Node: 3efecaa
Fixed
- Updated default compiler configuration to include files from
__tests__
directories: 033a4bb - Fixed a bug in flow type generation that fields on inline fragments with duplicated names are only included once:
[088afdf](https://github.com/facebook/relay/commit/088afdf347582533b9956adbc5b2a5e37fe9cfaf)
- Deduplicate connection edges based on DataID (not just id field)
- Fixed a bug that mutations on viewer field “overwriting” existing fields in the store: Add hardcoded ID to
viewer
field
Misc
- Website is moved to https://relay.dev
- Upgrade Docusaurus to 1.9.0
- crossenv for jest script (#2732) by @anikethsaha
v4.0.0
Commits: v3.0.0...v4.0.0
Breaking
- Fragment Container, Refetch Container, Pagination Container now always expect an object as the fragment declaration (single
graphql
tag is no longer valid input), sincegraphql
tags no longer implicitly produce object wrappers during our babel transform: 1f26086.- Codemod to update to new signature: https://gist.github.com/kassens/3e2ef9af1e5e1128f8fba3362bb92f98
- ConnectionTransform will generate additional selections under the existing edges/pageInfo fields. A side-effect of this is that if edges/pageInfo were aliased, the generated fields now show up under the alias rather than as non-aliased sibling selections: 50008ab -
- Compiler no longer allows directives to be used in locations not defined in the schema. Previously the compiler doesn't check the directives' locations, it causes directives being used on wrong places, e.g.
@connection
on a fragment definition. - Compiler now validates that all
@arguments
are defined on the callee
Improved
-
Updates in testing tools:
- There are two main modules that you may use in your tests:
- createMockEnvironment(options): RelayMockEnvironment
- MockPayloadGenerator and @relay_test_operation directive
- With
createMockEnvironment,
you will be able to create an instance ofRelayMockEnvironment
, a Relay environment specifically for your tests. The instance created bycreateMockEnvironment
is implementing the Relay Environment Interface and it also has an additional Mock layer, with methods that allow to resolve/reject and control the flow of operations (queries/mutations/subscriptions). - The main purpose of
MockPayloadGenerator
is to improve the process of creating and maintaining the mock data for tested components.
- There are two main modules that you may use in your tests:
-
Added full support for client schema extensions: now full GraphQL types can be defined in the client schema (as opposed to just extending existing server types), and they will be properly retained during garbage collection when rendered.
-
Using new fetchQuery implementation inside QueryRenderer which de-dupes identical requests in flight.
-
Add config support for babel-plugin-relay/macro (#2646) @sgwilym
Fixed
- Fixed compiler error when watchman cli was missing: 2958b97
Misc
- Changed
main
entry point inpackage.json
forreact-relay
andrelay-test-utils
createRelayContext
now in relay-runtime package to prevent multiple instances of packages that have "peerDependencies".- RelayCompat is removed.
Experimental
- Added experimental support from
@stream
and@stream_connection
- Improved support for
@match
directive - Fixed passing down and comparing fragment owners in a few places that were missing.
- Added experimental scheduler to QueryExecutor.
v3.0.0
3.0.0
Commits: v2.0.0...v3.0.0
Breaking
- Removed Relay Classic and Compat.
react-relay/modern
has been moved toreact-relay/
.
Fixed
- Fixes an issue with schemas with internal enum values (ie, printing as a string but internally represented as an int), these enum values will now correctly print as the enum name instead of the internal value. #2638
- Changes commitMutation() to call onCompleted with null errors if there were no errors (instead of an empty array). c80a0fa
- Fixed issue with sequential optimistic mutation payloads: 55ce137
- Disabled a built-in
graphql-js
validation rule (checking that variables are used in allowed positions) in the compiler which could incorrectly report errors when an argument in the @arguments directive conflicted with the nearest parent field argument. Relay-compiler already implements the same validation internally and is aware of @arguments/@argumentDefinitions.
Improved
- Remove
validateNames
option in compiler which was always true. - Flow types are properly generated for refetchable queries.
Experimental
- Added partial support @stream and @defer in QueryExecutor. Note that this feature is experimental and subject to change. No public API is provided yet.
- Added support for using @module outside of @match, enabling new use-cases for data-driven dependencies. No public API is provided yet.
- Added fragment ownership under a feature flag. Fragment ownership is a new constraint that we're rolling out in the internal model of Relay where every instantiation of a fragment at runtime (i.e. a fragment for a given dataID) is associated with an operation that "owns" it; this operation will usually be a query. This is similar to how fragments work in GraphQL, where they need to be a part of a query in order to actually be fetched. This has a few benefits:
- It allows us to stop relying on React Context to propagate query variables through the tree (which are needed in order to read fragments), and instead can be accessed directly on the fragment owner associated with a fragment.
- Not using React Context also allows fragment results to be context-free and allows us to deal better with complicated edge cases like nested context (which occurred with refetch and pagination containers). E.g. if you pass a fragment reference from "above" a RefetchContainer/PaginationContainer/QueryRenderer and try to use it somewhere within one of those, it will probably not do what you expect since the variables will be wrong. With ownership, you always get the right variables.
- This in turn also allows us to specify behavior like refetching (which has historically been confusing) more precisely: refetching a fragment simply means reparenting it under a new owning operation.