Incrementally modernize your Relay Classic app in these steps:
Follow the steps outlined in the Migration Setup guide.
Start converting your components and mutations to use the Relay Modern APIs from the
'react-relay/compat' module (
commitMutation). It will be easier to go from the leaf components up. The conversion scripts should make this step less tedious.
If a fragment uses variables that are determined at runtime, see below.
Step 2: Introduce
Once all the components and mutations have been converted to use the Relay Modern APIs, convert to using
QueryRenderer instead of using
Relay.RootContainer. You may supply
'react-relay/classic' as the
environment for most cases.
Once a few or all of your views are using
'react-relay/classic' could be replaced with a
RelayModernEnvironment. Keep in mind that
Store do not share any data. You might want to hold off on this step until views that have significant data overlap can be switched over at the same time. This step is what unlocks the perf wins for your app. Apps using the
RelayModernEnvironment get to send persisted query IDs instead of the full query strings to the server, as well as much more optimized data normalizing and processing.
'react-relay/compat' references in your app to
'react-relay'. This is more of a clean-up step that prevents your app from pulling in unnecessary
There is currently only one supported way to set the initial value of a variable dynamically: using global variables defined on the query that includes the fragment (or via
variables on the
For example, if
currentDate is set in
variables, then $currentDate may be referenced in any fragment included in the
If you're using
createRefetchContainer then your
refetch method may also update these variables to render with new values.