forked from BerndWessels/babel-relay-plugin-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (27 loc) · 856 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var fs = require('fs');
var path = require('path');
var getbabelRelayPlugin = require('babel-relay-plugin');
var config = require('../../package.json');
try {
var schemaPath = path.join(__dirname, '../../', config.metadata.graphql.schema);
var stats = fs.lstatSync(schemaPath);
if (stats.isFile()) {
var schema = require(schemaPath);
}
}
catch (e) {
console.log(e);
}
if (schema) {
// console.log(`babel-relay-plugin-loader: using schema at [${schemaPath}]`);
module.exports = getbabelRelayPlugin(schema.data);
} else {
// console.log(`babel-relay-plugin-loader: no schema found at [${schemaPath}]`);
// console.log('babel-relay-plugin-loader: babel will continue without the babel-relay-plugin!');
module.exports = function () {
return {
visitor: {
}
};
};
}