Migrating React Relay from v16 to v17
Relay 17 adds schema validation and editor enhancements.
Key changes
- The compiler now validates your schema and client extensions. This can be disabled via
disable_schema_validation. - Edge type names in directives like
@appendNodeand@prependNodeare validated. - A new efficient hooks implementation reduces memory usage.
- Significant improvements to the VSCode extension, including rename refactoring and inlay hints.
Enabling schema validation
By default the compiler validates server schema and client extensions.
Example relay.config.json feature flag:
{ "featureFlags": { "disable_schema_validation": false }}Disable validation if necessary:
{ "featureFlags": { "disable_schema_validation": true }}Migration steps
- Upgrade
react-relayandrelay-compilerto^17.0.0. - Run the compiler and fix any schema validation errors or opt out with:
{"featureFlags": { "disable_schema_validation": true }}
- Ensure edge type names in connection directives are correct or disable with
disable_edge_type_name_validation_on_declerative_connection_directives. - Verify the new hooks work with your project and update tests as needed.