babel-plugin-react-relay
Advanced tools
Comparing version 0.9.2 to 0.9.3
@@ -8,2 +8,23 @@ 'use strict'; | ||
exports.default = function (babel) { | ||
var wait = true; | ||
var schema = void 0, | ||
error = void 0; | ||
(0, _graphqlConfigParser.resolveSchema)(config).then(function (result) { | ||
schema = result; | ||
wait = false; | ||
}).catch(function (err) { | ||
error = err; | ||
wait = false; | ||
}); | ||
// TODO find a cleaner way to do this | ||
(0, _deasync.loopWhile)(function () { | ||
return wait; | ||
}); | ||
if (error) { | ||
throw error; | ||
} | ||
if (schema.data) { | ||
@@ -29,22 +50,1 @@ return (0, _babelRelayPlugin2.default)(schema.data)(babel); | ||
var config = (0, _graphqlConfigParser.parse)(); | ||
var wait = true; | ||
var schema = void 0, | ||
error = void 0; | ||
(0, _graphqlConfigParser.resolveSchema)(config).then(function (result) { | ||
schema = result; | ||
wait = false; | ||
}).catch(function (err) { | ||
error = err; | ||
wait = false; | ||
}); | ||
// TODO find a cleaner way to do this | ||
(0, _deasync.loopWhile)(function () { | ||
return wait; | ||
}); | ||
if (error) { | ||
throw error; | ||
} |
{ | ||
"name": "babel-plugin-react-relay", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "Babel plugin for Relay (react-relay) with easy schema configuration in .babelrc", | ||
@@ -38,10 +38,10 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"babel-cli": "^6.11.4", | ||
"babel-preset-es2015": "^6.13.2" | ||
"babel-cli": "^6.16.0", | ||
"babel-preset-es2015": "^6.16.0" | ||
}, | ||
"dependencies": { | ||
"babel-relay-plugin": "^0.9.2", | ||
"babel-relay-plugin": "0.9.3", | ||
"deasync": "^0.1.7", | ||
"graphql-config-parser": "^0.1.1" | ||
"graphql-config-parser": "^1.1.1" | ||
} | ||
} |
# babel-plugin-react-relay [![npm version](https://badge.fury.io/js/babel-plugin-react-relay.svg)](https://badge.fury.io/js/babel-plugin-react-relay) | ||
Babel plugin for [Relay](https://github.com/facebook/relay) with support for multiple source types | ||
Babel plugin for [Relay](https://github.com/facebook/relay) which works out of the box with your GraphQL endpoint | ||
@@ -8,2 +8,4 @@ #### How does this relate to [babel-relay-plugin](https://www.npmjs.com/package/babel-relay-plugin)? | ||
(The version is the same as `babel-relay-plugin` by the way.) | ||
## Install | ||
@@ -17,4 +19,6 @@ | ||
### Step 1: Add babel plugin | ||
> Note: We recently switched over to [graphql-config](https://github.com/graphcool/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. | ||
@@ -28,53 +32,14 @@ | ||
### Step 2: Configure schema source | ||
### Step 2: Configure your GraphQL schema | ||
Add one of the following source options to your `package.json` file. | ||
This plugin uses the [graphql-config](https://github.com/graphcool/graphql-config) format and already works out of the box if you're using another GraphQL dev tool such as [this great IntelliJ Plugin](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin). | ||
#### JSON | ||
Add one of the following source options to your `package.json` file. **See [here](https://github.com/graphcool/graphql-config#usage) for more configuration details.** | ||
Imports a static GraphQL schema exported as a JSON file | ||
For your convenience, here is the easiest way to configure your GraphQL endpoint: | ||
```json | ||
{ | ||
"react-relay-schema": "./exported-schema.json" | ||
} | ||
```sh | ||
export GRAPHQL_ENDPOINT="https://your.api/graphql" | ||
``` | ||
#### URL | ||
You can also provide a URL to a schema endpoint. Use this method if you're using [graph.cool](https://graph.cool/). | ||
```json | ||
{ | ||
"react-relay-schema": "http://localhost:3000/schema.json" | ||
} | ||
``` | ||
#### Schema | ||
[graphql-js](https://github.com/graphql/graphql-js) schema definition is also supported. | ||
```json | ||
{ | ||
"react-relay-schema": "./schema-definition.js" | ||
} | ||
``` | ||
### Options | ||
#### Environment Variables | ||
Sometimes you need the flexibility to dynamically configure your GraphQL schema source via environment variables. You can easily do that using the following syntax (works for all source types): | ||
```json | ||
{ | ||
"react-relay-schema": { | ||
"env": "SCHEMA_ENDPOINT" | ||
} | ||
} | ||
``` | ||
This example uses the `$SCHEMA_ENDPOINT` environment variable. | ||
## License | ||
@@ -81,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5233
52
+ Addedgraphql@0.13.2(transitive)
+ Addedgraphql-config-parser@1.2.1(transitive)
+ Addediterall@1.3.0(transitive)
- Removedgraphql-config-parser@0.1.1(transitive)
Updatedbabel-relay-plugin@0.9.3
Updatedgraphql-config-parser@^1.1.1