babel-plugin-relay
babel-plugin-relay
Relay uses a Babel plugin to convert graphql
literals into requires of the code generated by Relay Compiler.
While you type queries as:
graphql` fragment MyComponent on Type { field } `
This gets converted into a "lazy" require of a generated file:
function () { return require('./__generated__/MyComponent.graphql'); }
Setting up babel-plugin-relay
First, install the plugin (typically as a devDependency
):
yarn add --dev babel-plugin-relay
Then, add "relay"
to the list of plugins in your .babelrc file. For example:
{ "