1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = getSchemaSource;
|
7 |
|
8 | var _fs = _interopRequireDefault(require("fs"));
|
9 |
|
10 | var _graphql = require("graphql");
|
11 |
|
12 | var _path = _interopRequireDefault(require("path"));
|
13 |
|
14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15 |
|
16 |
|
17 | function getSchemaSource(schemaPath) {
|
18 | let source = _fs.default.readFileSync(schemaPath, 'utf8');
|
19 |
|
20 | if (_path.default.extname(schemaPath) === '.json') {
|
21 | source = (0, _graphql.printSchema)((0, _graphql.buildClientSchema)(JSON.parse(source).data));
|
22 | }
|
23 |
|
24 | source = `
|
25 | directive @include(if: Boolean) on FRAGMENT_SPREAD | FIELD
|
26 | directive @skip(if: Boolean) on FRAGMENT_SPREAD | FIELD
|
27 |
|
28 | ${source}
|
29 | `;
|
30 | return new _graphql.Source(source, schemaPath);
|
31 | } |
\ | No newline at end of file |