Skip to content

Migrating React Relay from v19 to v20

Relay 20 includes documentation generation tooling and minor breaking changes.

Key changes

  • The eslint-plugin-relay package has released v2.0.0 with updated rules.
  • Generated documentation for compiler config and API pages.
  • Returning non-model weak types from resolvers is deprecated. Use strong or weak objects instead, or enable allow_output_type_resolvers.

Resolver return type example

Old style returning a weak object:

function userResolver(root) {
return { name: root.name } as any; // deprecated
}

Return a strong object or enable the flag temporarily:

type UserOutput = { name: string };
function userResolver(root): UserOutput {
return { name: root.name };
}

Migration steps

  1. Upgrade react-relay and relay-compiler to ^20.0.0 and eslint-plugin-relay to ^2.0.0.
  2. Update any resolvers using @outputType to return strong or weak objects. If migration is not possible immediately, enable:
    {
    "featureFlags": { "allow_output_type_resolvers": true }
    }
  3. Review generated documentation and adjust your tooling if needed.
  4. Run the compiler and tests to ensure compatibility.