babel-plugin-relay
Relay requires a Babel plugin to convert GraphQL tags to runtime artifacts.
A very simplified example of what this plugin is doing:
// It converts this code
const fragment = graphql`
fragment User_fragment on User {
name
}
`;
// To require generated ASTs for fragments and queries
const fragment = require('__generated__/User_fragment.graphql');
Plugin Configuration
babel-plugin-relay will discover the config if:
- There is a
relay.config.json,relay.config.jsfile at the root of the project (i.e. in the same folder as thepackage.jsonfile). - The
package.jsonfile contains a"relay"key.
Supported configuration options for babel-plugin-relay
artifactDirectoryA specific directory to output all artifacts to. When enabling this the babel plugin needsartifactDirectoryto be set as well. [string]eagerEsModulesThis option enables emitting ES modules artifacts. [boolean][default: false]codegenCommandThe command to run to compile Relay files. [string]isDevVariableNameName of the global variable for dev mode (e.g.__DEV__). [string]jsModuleFormatFormatting style for generated files.commonjsorhaste. Default iscommonjs. [string]