Babel plugin for Relay Classic which works out of the box with your GraphQL endpoint
Switch branches/tags
Clone or download
Latest commit 8e03fb4 Aug 17, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Stringify schema errors Jan 13, 2017
.babelrc WIP Mar 4, 2016
.gitignore WIP Mar 4, 2016
LICENSE Initial commit Mar 4, 2016 Update Aug 17, 2017
package.json new relay version Jan 13, 2017
yarn.lock new relay version Jan 13, 2017

babel-plugin-react-relay npm version

Babel plugin for Relay Classic which works out of the box with your GraphQL endpoint

DEPRECATED: Given the new relay-compiler setup (for Relay Modern) this babel plugin is no longer necessary.

How does this relate to babel-relay-plugin?

This package uses babel-relay-plugin internally but makes usage more convenient and extends its functionality. For example you no longer need to have a build/babelRelayPlugin.js script.

(The version is the same as babel-relay-plugin by the way.)


$ npm install -D babel-plugin-react-relay


Note: We recently switched over to graphql-config, so this might be a breaking change for you.

Step 1: Add plugin to .babelrc

Add the following to your .babelrc file or the corresponding babel configuration.

	"plugins": ["react-relay"]

Step 2: Configure your GraphQL schema

This plugin uses the graphql-config format and already works out of the box if you're using another GraphQL dev tool such as this great IntelliJ Plugin.

Add one of the following source options to your package.json file. See here for more configuration details.

For your convenience, here is the easiest way to configure your GraphQL endpoint:

export GRAPHQL_ENDPOINT="https://your.api/graphql"


Using graphql-js as configuration option

For those intending to directly reference their backend schema.js, you will need to ensure a single version of graphql exists in node_modules. However as of this writing, babel-relay-plugin and graphql-config-parser reference incompatible versions of graphql (context). A workaround is to force the graphql dependency within npm-shrinkwrap.json at your project's root (make sure to adapt as currently relevant):

  "dependencies": {
    "babel-relay-plugin": {
      "version": "0.9.3",
      "from": "babel-relay-plugin@0.9.3",
      "dependencies": {
        "graphql": {
          "version": "0.7.1",
          "from": "graphql@0.6.2"

Then run npm prune, npm install and npm dedupe for good measure.


MIT License

Help & Community Slack Status

Join our Slack community if you run into issues or have questions. We love talking to you!