Relay is a JavaScript framework for building data-driven React applications.
MIT License
Bot releases are visible (Hide)
Published by alunyov over 3 years ago
areEqual{OSS => ArgValues}
[b8d2694dbe]fbjs/lib/ErrorUtils
Dependency [5ed076ee7a]fbjs/lib/invariant
with invariant
(#3448) [3982f9dca4]Published by alunyov over 3 years ago
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.
preloadQuery
with loadQuery
(#3412)<p>
(#3385)Published by jstejada over 3 years ago
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.
fetchQuery
:
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.fetchQuery
renamed to **** fetchQuery_DEPRECATED
. Previous behavior returns a Promise (can’t be observed). No request de-duping.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.gcReleaseBufferSize
is now 10 (previously 0).
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.store-or-network
. to actually reuse cached data when navigating back to previously visited views.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.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.fetchQuery
added. See description in Breaking Changes.ConnectionHandler.getConnectionID
to make it easier to get a connection ID for usage in updaters or declarative connection mutations (@kyarik: https://github.com/facebook/relay/pull/3332)loadQuery
accepts a fetchPolicy
of 'store-only'
loadQuery
now warns, instead of throwing, if called during the render phase.getDataID
is now a stable config option. See description in Breaking Changes.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
. (https://github.com/facebook/relay/pull/3278)graphql
with Rust Compiler.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.Published by jstejada over 3 years ago
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.
fetchQuery
:
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.fetchQuery
renamed to fetchQuery_DEPRECATED
. Previous behavior returns a Promise (can’t be observed). No request de-duping.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.gcReleaseBufferSize
is now 10 (previously 0).
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.store-or-network
to actually reuse cached data when navigating back to previously visited views.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.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.fetchQuery
added. See description in Breaking Changes.ConnectionHandler.getConnectionID
to make it easier to get a connection ID for usage in updaters or declarative connection mutations (@kyarik: https://github.com/facebook/relay/pull/3332)loadQuery
accepts a fetchPolicy
of 'store-only'
loadQuery
now warns, instead of throwing, if called during the render phase.getDataID
is now a stable config option. See description in Breaking Changes.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
. (https://github.com/facebook/relay/pull/3278)graphql
with Rust Compiler.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.Published by poteto over 3 years ago
Published by alunyov almost 4 years ago
null
[9d31dfbd5]Published by alunyov almost 4 years ago
Published by alunyov almost 4 years ago
@appendNode
and @prependNode
declarative mutation directives for inserting a node to connections (#3155) [0fe732dab]
comments @appendNode(connections: $connections, edgeTypeName: "CommentEdgeType") { id }
@deleteEdge
directive for removing the edge from connections (#3177) [01d65b3]
deletedCommentId @deleteEdge(connections: $connections)
@deleteRecord
directive (#3135) [27f938c2a]
deletedCommentIds @deleteRecord
^16.9.0 || ^17
as a peerDependency
.loadQuery
API.useQueryLoader
now accepts an initial query reference.usePreloadedQuery
from consuming stale cached query refsThe 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 (https://github.com/facebook/relay/pull/3182)
Published by rbalicki2 about 4 years ago
type
from the schema (b63815b82)label
arg from @stream_connection (2e2be4cac)onLoad
support to PreloadableQueryRegistry (8242adca0)Published by rbalicki2 over 4 years ago
handler
arg in @connection validation by [email protected], 2020-03-09 (62a10d806)extraOptions
field. by [email protected], 2020-02-12 (2b8697733)Published by jstejada over 4 years ago
getModernOperationVariables
to getOperationVariables
queuePendingOperation
to RelayModernMockEnvironment
in testing tools. This allows the caller to manually register an operation that should be pending.graphql
strings (https://github.com/facebook/relay/pull/2811).DataChecker::check
now returns the operation fetch time.getRelayDefaultMissingFieldHandlers.js
@stream
’ed responses.useLegacyPaginationFragment
to usePaginationFragment
.preloadQuery
will error if called during render.@stream
ing or @defer
.Published by jstejada almost 5 years ago
Commits: https://github.com/facebook/relay/compare/v7.1.0...v8.0.0
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 the graphql-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 function parseValue
, parseLiteral
and serialize
that can be defined for a graphql type via graphql-js
primitives are not accessible in the relay compiler: this may break serialization of custom scalars. https://github.com/facebook/relay/commit/860c23cbb445e04fd14e5d05ed53a026d4f63357
store.getRoot
. Usages like store.getRoot().getLinkedRecord('create_comment_mutation')
will break.RelayRecordSourceProxy::commitPayload()
. Note that this method was not part of the public interface.RelayStore.retain()
changed to directly accept an OperationDescriptor
. An operation descriptor to pass to RelayStore.retain
()can be constructed using
createOperationDescriptoravailable in
relay-runtime`.relay-compiler
we added support for variables in complex objects and arrays: https://github.com/facebook/relay/commit/5da3be070283c6dcd42774ba33c1590db65fe3c7
isClientID
helper is available to use in relay-runtime
https://github.com/facebook/relay/commit/dac614c4812fc48db9c00d69d81dc1aa0c6231db
Remove the clientMutationId
requirement by creating a new root id for each executed mutation: https://github.com/facebook/relay/pull/2349
validateMutation
correctly handles lists of scalar fields in the optimistic payloads: https://github.com/facebook/relay/commit/56795ba6f839e4d770d19b0d921940515db98475
DissalowIDAsAlias
this validation had a bug, there it wasn't traversing LinkedFields, hence wasn't reporting violations in their selections. https://github.com/facebook/relay/commit/c4547f9a0fd41c28851490d2ba499e0f30831175
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: https://github.com/facebook/relay/pull/2960
options
property on IEnvironment
for attaching extra information to the environment instanceLazyLoadEntryPointContainer
=> LazyLoadEntryPointContainer_DEPRECATED
: https://github.com/facebook/relay/commit/08bde918325336bdaacb444b249ed1dd5a81d30c
usePreloadedQuery
now takes an unstable UNSTABLE_renderPolicy
like useLazyLoadQuery
: https://github.com/facebook/relay/commit/fc1b88b9cd59b646444562c8c597308c8cb9f8cd
useMutation
Hook was added: https://github.com/facebook/relay/commit/96d9703761e222a740cbefbed567e6cfe8015e69
JSResource
Flow interface from Relay.useFragment
.Published by alunyov almost 5 years ago
writeQueryParams: (
dir: CodegenDirectory,
filename: string,
moduleName: string,
params: RequestParameters,
) => void
preloadQuery()
, which makes it usable without the special $Parameters file: https://github.com/facebook/relay/commit/edb46706085a35699197300e6238f022982a2bad
getModuleIfRequired
replaced with queryResource
in the EntryPoints: https://github.com/facebook/relay/commit/32f4a71df153b0ea1b0eb40cf8b164db6cbff2d3
Published by jstejada almost 5 years ago
Commits: https://github.com/facebook/relay/compare/v6.0.0...v7.0.0
Variables are no longer set in Relay Context when using a QueryRenderer
. This means that any product code that was relying on reading variables from RelayContext
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 exports createRelayNetworkLogger
. This logger is being replaced with event based logging on the Environment
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 a Store
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 (https://github.com/facebook/relay/commit/15e8d2201fdad47596e1acfb3a5daa3fb7511a8e). Additionally, we've removed the concept of RelayIRValidations (https://github.com/facebook/relay/commit/da01bf3fc18774115821fc4a33558b51e04a82e4), 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.
@DEPRECATED__relay_ignore_unused_variables_error
to suppress errors that were surfaced after we've migrated from GraphQL NoUnusedVariablesRule
to RelayIRTransform validation. GraphQL NoUnusedVariablesRule
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.@refetchable
directive on a fragment: we no longer enforce that the argument for the node
field is called id
; it can be called anything as long as it’s an ID
type.__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 an id
. 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.null
as default value of enum: https://github.com/facebook/relay/commit/6946e85da4f2646db7901790f3ade406c753fd03
@refetchable
connection metadata for custom handlers.16.9.0
.babel-preset-fbjs
to 3.3.0type
and typeCondition
in GraphQL IR types to use Relay internal representation of GraphQL type (https://github.com/facebook/relay/commit/2606f32674f75513726207ceb198c906c276e90c). Before this change, we were directly using graphql-js
type instances. But eventually, our goal in Relay compiler is to get rid of the dependency on the graphql-js
schema representation and use a faster/less memory intensive representation of the schema. We also build a Schema wrapper: https://github.com/facebook/relay/commit/9e6d9192d6516e16f0383e7b9094ecded77f1348 - that should help us during this migration.useFragment
were shipped.useQuery
hook; this might happen when useQuery
starts a long-lived request, e.g. to poll for real time data.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.useBlockingPagination
.@argumentDefitions
.hasNextPage
as false.renderPolicy_UNSTABLE
, which determines whether data should be eagerly or lazily rendered.Published by jstejada about 5 years ago
Commits: https://github.com/facebook/relay/compare/v5.0.0...v6.0.0
Published by alunyov over 5 years ago
Commits: https://github.com/facebook/relay/compare/v4.0.0...v5.0.0
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.__tests__
directories: https://github.com/facebook/relay/commit/033a4bbc332e3d18c2bd37ebfde5f9f930d9c9e3
[088afdf](https://github.com/facebook/relay/commit/088afdf347582533b9956adbc5b2a5e37fe9cfaf)
viewer
field
Published by alunyov over 5 years ago
Commits: https://github.com/facebook/relay/compare/v3.0.0...v4.0.0
graphql
tag is no longer valid input), since graphql
tags no longer implicitly produce object wrappers during our babel transform: https://github.com/facebook/relay/commit/1f260861c08545fd3f6c390f5c9e2692665449be.
@connection
on a fragment definition.@arguments
are defined on the calleeUpdates in testing tools:
createMockEnvironment,
you will be able to create an instance of RelayMockEnvironment
, a Relay environment specifically for your tests. The instance created by createMockEnvironment
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).MockPayloadGenerator
is to improve the process of creating and maintaining the mock data for tested components.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
main
entry point in package.json
for react-relay
and relay-test-utils
createRelayContext
now in relay-runtime package to prevent multiple instances of packages that have "peerDependencies".@stream
and @stream_connection
@match
directivePublished by jstejada over 5 years ago
Commits: https://github.com/facebook/relay/compare/v2.0.0...v3.0.0
react-relay/modern
has been moved to react-relay/
.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.validateNames
option in compiler which was always true.Published by jstejada over 5 years ago
Commits: https://github.com/facebook/relay/compare/v1.7.0...v2.0.0
graphql
to 14.0.0
react
to 16.5.0
inputFieldWhitelist
to optionalInputFields
.environment.unstable_internal.getSelector(...)
has changed.ReactRelayContext
is now exported from react-relay
.PayloadError
in RelayNetwork interface.missingFieldHandlers
in the Relay environment. These handlers allow developers to provide a fallback for missing data for a query when environment.check()
is called.@connection
. This is useful for products that want to customize the way newly fetched items are merged into an existing connection.recycleNodesInto
no longer produces runtime error in DEV mode trying to mutate frozen objects (#2193)ConcreteRequest
to provide more flexibility for our fetching apis.RelayMarkSweepStore
to RelayModernStore
.Viewer
, Query
, or a type that implements Node
). No user api is provided yet.