Code Monkey home page Code Monkey logo

babel-plugin-react-relay's Introduction

babel-plugin-react-relay npm version

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

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.)

Install

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

Configuration

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"

Troubleshooting

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": "[email protected]",
      "dependencies": {
        "graphql": {
          "version": "0.7.1",
          "from": "[email protected]"
        }
      }
    }
  }
}

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

License

MIT License

Help & Community Slack Status

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

babel-plugin-react-relay's People

Contributors

cahnory avatar chentsulin avatar schickling avatar sedubois avatar sorenbs avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.