@stepzen/transpiler 0.21.0 → 0.22.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/merge.d.ts.map +1 -1
- package/lib/actions/merge.js +11 -2
- package/lib/actions/merge.js.map +1 -1
- package/lib/actions/stitch.d.ts.map +1 -1
- package/lib/actions/stitch.js +9 -2
- package/lib/actions/stitch.js.map +1 -1
- package/lib/actions/transpile.d.ts +10 -0
- package/lib/actions/transpile.d.ts.map +1 -1
- package/lib/actions/transpile.js +10 -0
- package/lib/actions/transpile.js.map +1 -1
- package/lib/utils/constants.d.ts +1 -0
- package/lib/utils/constants.d.ts.map +1 -1
- package/lib/utils/constants.js +2 -1
- package/lib/utils/constants.js.map +1 -1
- package/lib/utils/copy-workspace-content.d.ts +1 -0
- package/lib/utils/copy-workspace-content.d.ts.map +1 -1
- package/lib/utils/copy-workspace-content.js +8 -0
- package/lib/utils/copy-workspace-content.js.map +1 -1
- package/lib/utils/graphql-helpers.d.ts +4 -1
- package/lib/utils/graphql-helpers.d.ts.map +1 -1
- package/lib/utils/graphql-helpers.js +1 -3
- package/lib/utils/graphql-helpers.js.map +1 -1
- package/lib/utils/set-files-in-sdl.d.ts +5 -1
- package/lib/utils/set-files-in-sdl.d.ts.map +1 -1
- package/lib/utils/set-files-in-sdl.js +102 -18
- package/lib/utils/set-files-in-sdl.js.map +1 -1
- package/package.json +3 -2
- package/src/actions/merge.ts +11 -2
- package/src/actions/stitch.ts +10 -2
- package/src/actions/transpile.ts +10 -0
- package/src/utils/constants.ts +2 -0
- package/src/utils/copy-workspace-content.ts +7 -0
- package/src/utils/graphql-helpers.ts +3 -3
- package/src/utils/set-files-in-sdl.ts +131 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"mCA2CY,MAAM,YACN;IACR,MAAM,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,YACQ;IACP,OAAO,EAAE,GAAG,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;CACpC;AAdH,wBAoMC"}
|
package/lib/actions/merge.js
CHANGED
|
@@ -11,8 +11,14 @@ const print_1 = require("./print");
|
|
|
11
11
|
const set_files_in_sdl_1 = require("../utils/set-files-in-sdl");
|
|
12
12
|
const strip_empty_queries_and_mutations_1 = require("../utils/strip-empty-queries-and-mutations");
|
|
13
13
|
const copy_workspace_content_1 = require("../utils/copy-workspace-content");
|
|
14
|
+
const constants_1 = require("../utils/constants");
|
|
15
|
+
// It's safe to use this special placeholder value here: in case of a failure
|
|
16
|
+
// in the merge / import process it will not reach the workspace folder.
|
|
17
|
+
// All intermediary steps are carried out in a temp folder, and only when all
|
|
18
|
+
// merge / import steps are completed, the result it copied over to the
|
|
19
|
+
// workspace folder.
|
|
14
20
|
const BLANK_INDEX_TEMPLATE = `
|
|
15
|
-
schema @sdl(files: []) {
|
|
21
|
+
schema @sdl(files: ["${constants_1.ALL_GRAPHQL_FILES}"]) {
|
|
16
22
|
query: Query
|
|
17
23
|
}
|
|
18
24
|
`.trim();
|
|
@@ -66,6 +72,7 @@ exports.default = async (original, imported, options = {
|
|
|
66
72
|
const targetSubfolder = options.onConflict === 'overwrite'
|
|
67
73
|
? imported.name
|
|
68
74
|
: (0, merge_helpers_1.findNextAvailableSubfolder)(original, imported.name);
|
|
75
|
+
let importedGraphQLFiles = [];
|
|
69
76
|
if (options.mergeTypes) {
|
|
70
77
|
const merged = (0, merge_1.mergeTypeDefs)([
|
|
71
78
|
await (0, merge_helpers_1.getSchema)(options.output),
|
|
@@ -141,6 +148,7 @@ exports.default = async (original, imported, options = {
|
|
|
141
148
|
const deduped = (0, merge_helpers_1.dedupeTempFolder)(file);
|
|
142
149
|
fs.ensureFileSync(deduped);
|
|
143
150
|
fs.writeFileSync(deduped, (0, print_1.default)(a.ast));
|
|
151
|
+
importedGraphQLFiles.push(path.relative(options.output, deduped));
|
|
144
152
|
});
|
|
145
153
|
}
|
|
146
154
|
else {
|
|
@@ -149,10 +157,11 @@ exports.default = async (original, imported, options = {
|
|
|
149
157
|
const targetFullPath = path.join(options.output, targetSubfolder, relativePath);
|
|
150
158
|
fs.ensureDirSync(path.dirname(targetFullPath));
|
|
151
159
|
fs.copyFileSync(importedFullPath, targetFullPath);
|
|
160
|
+
importedGraphQLFiles.push(path.relative(options.output, targetFullPath));
|
|
152
161
|
});
|
|
153
162
|
}
|
|
154
163
|
// Make sure all files are referenced in @sdl
|
|
155
|
-
(0, set_files_in_sdl_1.default)(options.output);
|
|
164
|
+
(0, set_files_in_sdl_1.default)(options.output, importedGraphQLFiles);
|
|
156
165
|
// Generate configuration
|
|
157
166
|
const config = await (0, merge_helpers_1.getConfiguration)([options.output, imported.source], options.silent, options.answers);
|
|
158
167
|
if (config) {
|
package/lib/actions/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,6BAA4B;AAC5B,gDAAkD;AAClD,qCAAoC;AACpC,yBAAwB;AACxB,6BAA4B;AAE5B,0DAW+B;AAC/B,mCAA2B;AAC3B,gEAAqD;AACrD,kGAAsF;AACtF,4EAAkE;
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,6BAA4B;AAC5B,gDAAkD;AAClD,qCAAoC;AACpC,yBAAwB;AACxB,6BAA4B;A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,CAAA;KAC/C;IAED,0BAA0B;IAC1B,OAAO,OAAO,CAAC,MAAM,CAAA;AACvB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stitch.d.ts","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stitch.d.ts","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"iCAaU,MAAM,WACN,MAAM;AAFhB,wBAoGC"}
|
package/lib/actions/stitch.js
CHANGED
|
@@ -8,6 +8,8 @@ const os = require("os");
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const prettier = require("prettier");
|
|
10
10
|
const dedupe_query_and_mutation_types_1 = require("../utils/dedupe-query-and-mutation-types");
|
|
11
|
+
const constants_1 = require("../utils/constants");
|
|
12
|
+
const copy_workspace_content_1 = require("../utils/copy-workspace-content");
|
|
11
13
|
exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)) => {
|
|
12
14
|
// Ensure source and output directories exist
|
|
13
15
|
if (!fs.existsSync(source))
|
|
@@ -29,7 +31,12 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
29
31
|
if (list) {
|
|
30
32
|
const copy = (0, lodash_1.clone)(list.value);
|
|
31
33
|
for (const file of copy.values) {
|
|
32
|
-
|
|
34
|
+
if (file.value === constants_1.ALL_GRAPHQL_FILES) {
|
|
35
|
+
files = files.concat((0, copy_workspace_content_1.getAllGraphQLFiles)(source));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
files = files.concat(file.value);
|
|
39
|
+
}
|
|
33
40
|
}
|
|
34
41
|
const mutated = (0, lodash_1.cloneDeep)(node);
|
|
35
42
|
mutated.arguments = mutated.arguments.filter((arg) => arg.name.value !== 'files');
|
|
@@ -59,7 +66,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
59
66
|
for (const file of files) {
|
|
60
67
|
const find = path.join(source, file);
|
|
61
68
|
if (!fs.existsSync(find)) {
|
|
62
|
-
throw new Error(`Cannot find file ${
|
|
69
|
+
throw new Error(`Cannot find file ${file} referenced in the @sdl directive in index.graphql`);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
// Get all the files and stitch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":";;AAAA,mCAAuC;AACvC,qCAA2C;AAC3C,+BAA8B;AAC9B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,qCAAoC;AAEpC,8FAAkF;
|
|
1
|
+
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":";;AAAA,mCAAuC;AACvC,qCAA2C;AAC3C,+BAA8B;AAC9B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,qCAAoC;AAEpC,8FAAkF;AAClF,kDAAoD;AACpD,4EAAkE;AAElE,kBAAe,CACb,MAAc,EACd,SAAiB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,EACpE,EAAE;IACF,6CAA6C;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;IAC3D,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAExB,uBAAuB;IACvB,IAAI,GAAQ,CAAA;IACZ,IAAI,KAAK,GAAa,EAAE,CAAA;IAExB,qEAAqE;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAEtD,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC9B,MAAM,KAAK,GAAG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Q,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAA;IAEzD,yBAAyB;IACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACtD,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAEvC,6BAA6B;IAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAErD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAC/B,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;KAC5C;IAED,uBAAuB;IACvB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
3
|
+
* transformations, and return its effective GraphQL schema and configuration
|
|
4
|
+
* as in-memory strings.
|
|
5
|
+
*
|
|
6
|
+
* @param {*} source absolute path to a schema root folder
|
|
7
|
+
* @return {*} schema, configuration, and a "transpiled" flag indicating
|
|
8
|
+
* whether or not any StepZen-specific transformations have actually
|
|
9
|
+
* been applied.
|
|
10
|
+
*/
|
|
1
11
|
declare const _default: (source: string) => Promise<{
|
|
2
12
|
config: string | false;
|
|
3
13
|
schema: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;iCAC2B,MAAM;;;;;AAApC,wBAkDC"}
|
package/lib/actions/transpile.js
CHANGED
|
@@ -10,6 +10,16 @@ const print_1 = require("../actions/print");
|
|
|
10
10
|
const stitch_1 = require("../actions/stitch");
|
|
11
11
|
const configure_1 = require("./configure");
|
|
12
12
|
const config_1 = require("../mutations/config");
|
|
13
|
+
/**
|
|
14
|
+
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
15
|
+
* transformations, and return its effective GraphQL schema and configuration
|
|
16
|
+
* as in-memory strings.
|
|
17
|
+
*
|
|
18
|
+
* @param {*} source absolute path to a schema root folder
|
|
19
|
+
* @return {*} schema, configuration, and a "transpiled" flag indicating
|
|
20
|
+
* whether or not any StepZen-specific transformations have actually
|
|
21
|
+
* been applied.
|
|
22
|
+
*/
|
|
13
23
|
exports.default = async (source) => {
|
|
14
24
|
// Ensure source and output directories exist
|
|
15
25
|
if (!fs.existsSync(source)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,iCAAgC;AAChC,+BAA8B;AAC9B,yBAAwB;AACxB,6BAA4B;AAC5B,6BAA4B;AAE5B,4CAAoC;AACpC,8CAAsC;AACtC,2CAAmC;AAEnC,gDAAiD;AAEjD,kBAAe,KAAK,EAAE,MAAc,EAAE,EAAE;IACtC,6CAA6C;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;KAC1D;IAED,qDAAqD;IACrD,KAAK,CAAC,gBAAgB,CAAC,CACrB,qBAAqB,OAAO,CAAC,GAAG,EAAE,6CAA6C,CAChF,CAAA;IACD,MAAM,CAAC,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,gBAAgB,CAAC,CACrB,qBAAqB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzC,6CAA6C,CAChD,CAAA;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D,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAA,gBAAM,EAAC,MAAM,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;QAClD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC9C,MAAM,GAAG,IAAA,eAAK,EAAC,IAAA,eAAK,EAAC,OAAO,CAAC,CAAC,CAAA;KAC/B;IAED,OAAO;QACL,MAAM;QACN,MAAM;QACN,UAAU,EAAE,gBAAgB;KAC7B,CAAA;AACH,CAAC,CAAA"}
|
package/lib/utils/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const EXPERIMENTAL_EXTENSIONS = "\ndirective @experimental(\n debug: Boolean\n function: String\n mock: String\n setter: String\n) on OBJECT | FIELD_DEFINITION\n";
|
|
2
2
|
export declare const STEPZEN_DOMAIN: string;
|
|
3
|
+
export declare const ALL_GRAPHQL_FILES = "**/*.graphql";
|
|
3
4
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,uBAAuB,yIAOnC,CAAA;AAED,eAAO,MAAM,cAAc,QAAyC,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,uBAAuB,yIAOnC,CAAA;AAED,eAAO,MAAM,cAAc,QAAyC,CAAA;AAEpE,eAAO,MAAM,iBAAiB,iBAAiB,CAAA"}
|
package/lib/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STEPZEN_DOMAIN = exports.EXPERIMENTAL_EXTENSIONS = void 0;
|
|
3
|
+
exports.ALL_GRAPHQL_FILES = exports.STEPZEN_DOMAIN = exports.EXPERIMENTAL_EXTENSIONS = void 0;
|
|
4
4
|
const dotenv = require("dotenv");
|
|
5
5
|
const debug = require("debug");
|
|
6
6
|
debug('stepzen:dotenv')(`loading .env from ${process.cwd()}, at transpiler/src/utils/constants.ts`);
|
|
@@ -15,4 +15,5 @@ directive @experimental(
|
|
|
15
15
|
) on OBJECT | FIELD_DEFINITION
|
|
16
16
|
`;
|
|
17
17
|
exports.STEPZEN_DOMAIN = ENV_VAR_STEPZEN_DOMAIN || 'stepzen.io';
|
|
18
|
+
exports.ALL_GRAPHQL_FILES = '**/*.graphql';
|
|
18
19
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,+BAA8B;AAE9B,KAAK,CAAC,gBAAgB,CAAC,CACrB,qBAAqB,OAAO,CAAC,GAAG,EAAE,wCAAwC,CAC3E,CAAA;AACD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,EAAC,cAAc,EAAE,sBAAsB,EAAC,GAAG,OAAO,CAAC,GAAG,CAAA;AAE/C,QAAA,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAEY,QAAA,cAAc,GAAG,sBAAsB,IAAI,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,+BAA8B;AAE9B,KAAK,CAAC,gBAAgB,CAAC,CACrB,qBAAqB,OAAO,CAAC,GAAG,EAAE,wCAAwC,CAC3E,CAAA;AACD,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,EAAC,cAAc,EAAE,sBAAsB,EAAC,GAAG,OAAO,CAAC,GAAG,CAAA;AAE/C,QAAA,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAEY,QAAA,cAAc,GAAG,sBAAsB,IAAI,YAAY,CAAA;AAEvD,QAAA,iBAAiB,GAAG,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-workspace-content.d.ts","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-workspace-content.d.ts","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;kCACsB,MAAM,WAAW,MAAM;AAAhD,wBAgBC;AAED,eAAO,MAAM,kBAAkB,YAAa,MAAM,aAIjD,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllGraphQLFiles = void 0;
|
|
3
4
|
const fs = require("fs-extra");
|
|
4
5
|
const glob = require("glob");
|
|
5
6
|
const path = require("path");
|
|
6
7
|
const lodash_1 = require("lodash");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
7
9
|
const WORKSPACE_FILE_PATTERNS = [
|
|
8
10
|
'**/*.graphql',
|
|
9
11
|
'stepzen.config.json',
|
|
@@ -35,4 +37,10 @@ exports.default = (srcPath, dstPath) => {
|
|
|
35
37
|
fs.copyFileSync(srcFileFullPath, dstFileFullPath);
|
|
36
38
|
});
|
|
37
39
|
};
|
|
40
|
+
const getAllGraphQLFiles = (srcPath) => {
|
|
41
|
+
return glob
|
|
42
|
+
.sync(constants_1.ALL_GRAPHQL_FILES, { cwd: srcPath })
|
|
43
|
+
.filter(file => file !== 'index.graphql');
|
|
44
|
+
};
|
|
45
|
+
exports.getAllGraphQLFiles = getAllGraphQLFiles;
|
|
38
46
|
//# sourceMappingURL=copy-workspace-content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,6BAA4B;AAC5B,6BAA4B;AAC5B,mCAA8B;AAC9B,2CAA6C;AAE7C,MAAM,uBAAuB,GAAG;IAC9B,cAAc;IACd,qBAAqB;IACrB,aAAa;CACd,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,kBAAe,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;IAClD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAA;KAC3D;IAED,IAAA,gBAAO,EAAC,uBAAuB,EAAE,OAAO,CAAC,EAAE,CACzC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjB,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,gBAAgB;KACzB,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;QAC/C,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAEM,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,EAAE;IACpD,OAAO,IAAI;SACR,IAAI,CAAC,6BAAiB,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC;SACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;AAC7C,CAAC,CAAA;AAJY,QAAA,kBAAkB,sBAI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"graphql-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,CAAC,CAAC,IAAI;IAAC,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAA;AAC9E,eAAO,MAAM,SAAS,iCACW,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cloneDeep = void 0;
|
|
4
|
-
const cloneDeep = (obj) =>
|
|
5
|
-
return JSON.parse(JSON.stringify(obj));
|
|
6
|
-
};
|
|
4
|
+
const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
7
5
|
exports.cloneDeep = cloneDeep;
|
|
8
6
|
//# sourceMappingURL=graphql-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-helpers.js","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"graphql-helpers.js","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":";;;AACO,MAAM,SAAS,GAAG,CAAI,GAAM,EAAoB,EAAE,CACvD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;AADpB,QAAA,SAAS,aACW"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { DirectiveNode, SchemaDefinitionNode } from 'graphql';
|
|
2
|
+
import { DeepWriteable } from './graphql-helpers';
|
|
3
|
+
export declare const createOrUpdateSdlDirective: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[], origSdlDirective?: DeepWriteable<DirectiveNode>) => DeepWriteable<DirectiveNode>;
|
|
4
|
+
export declare const createSchemaElement: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[]) => DeepWriteable<SchemaDefinitionNode>;
|
|
5
|
+
declare const _default: (source: string, importedGraphQLFiles: readonly string[]) => void;
|
|
2
6
|
export default _default;
|
|
3
7
|
//# sourceMappingURL=set-files-in-sdl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-files-in-sdl.d.ts","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.d.ts","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAGb,oBAAoB,EAGrB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAY,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAK1D,eAAO,MAAM,0BAA0B,yBACf,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,qBACf,cAAc,aAAa,CAAC,iCAuDhD,CAAA;AAED,eAAO,MAAM,mBAAmB,yBACR,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,wCAuBnC,CAAA;iCAEuB,MAAM,wBAAwB,SAAS,MAAM,EAAE;AAAvE,wBA4CC"}
|
|
@@ -1,35 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchemaElement = exports.createOrUpdateSdlDirective = void 0;
|
|
3
4
|
const fs = require("fs");
|
|
4
|
-
const glob = require("glob");
|
|
5
5
|
const graphql_1 = require("graphql");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const graphql_helpers_1 = require("./graphql-helpers");
|
|
8
8
|
const print_1 = require("../actions/print");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const copy_workspace_content_1 = require("./copy-workspace-content");
|
|
11
|
+
const createOrUpdateSdlDirective = (importedGraphQLFiles, allGraphQLFiles, origSdlDirective) => {
|
|
12
|
+
let sdlDirective;
|
|
13
|
+
if (origSdlDirective) {
|
|
14
|
+
sdlDirective = (0, graphql_helpers_1.cloneDeep)(origSdlDirective);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
sdlDirective = {
|
|
18
|
+
kind: 'Directive',
|
|
19
|
+
name: {
|
|
20
|
+
kind: 'Name',
|
|
21
|
+
value: 'sdl',
|
|
22
|
+
},
|
|
23
|
+
arguments: [
|
|
24
|
+
{
|
|
25
|
+
kind: 'Argument',
|
|
26
|
+
name: {
|
|
27
|
+
kind: 'Name',
|
|
28
|
+
value: 'files',
|
|
29
|
+
},
|
|
30
|
+
value: {
|
|
31
|
+
kind: 'ListValue',
|
|
32
|
+
values: [
|
|
33
|
+
{
|
|
34
|
+
kind: 'StringValue',
|
|
35
|
+
value: constants_1.ALL_GRAPHQL_FILES,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
sdlDirective.arguments = sdlDirective.arguments?.map(arg => {
|
|
44
|
+
if (arg.name.value === 'files') {
|
|
45
|
+
const filesValueNodes = arg.value;
|
|
46
|
+
const fileset = new Set([
|
|
47
|
+
...filesValueNodes.values.map(value => value.value),
|
|
48
|
+
...importedGraphQLFiles,
|
|
49
|
+
]);
|
|
50
|
+
if (fileset.has(constants_1.ALL_GRAPHQL_FILES)) {
|
|
51
|
+
fileset.delete(constants_1.ALL_GRAPHQL_FILES);
|
|
52
|
+
allGraphQLFiles.forEach(file => fileset.add(file));
|
|
53
|
+
}
|
|
54
|
+
filesValueNodes.values = [...fileset].map(file => ({
|
|
55
|
+
kind: 'StringValue',
|
|
56
|
+
value: file,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
return arg;
|
|
60
|
+
});
|
|
61
|
+
return sdlDirective;
|
|
62
|
+
};
|
|
63
|
+
exports.createOrUpdateSdlDirective = createOrUpdateSdlDirective;
|
|
64
|
+
const createSchemaElement = (importedGraphQLFiles, allGraphQLFiles) => {
|
|
65
|
+
const schemaElement = {
|
|
66
|
+
kind: 'SchemaDefinition',
|
|
67
|
+
directives: [
|
|
68
|
+
(0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles),
|
|
69
|
+
],
|
|
70
|
+
operationTypes: [
|
|
71
|
+
{
|
|
72
|
+
kind: 'OperationTypeDefinition',
|
|
73
|
+
operation: 'query',
|
|
74
|
+
type: {
|
|
75
|
+
kind: 'NamedType',
|
|
76
|
+
name: {
|
|
77
|
+
kind: 'Name',
|
|
78
|
+
value: 'Query',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
return schemaElement;
|
|
85
|
+
};
|
|
86
|
+
exports.createSchemaElement = createSchemaElement;
|
|
87
|
+
exports.default = (source, importedGraphQLFiles) => {
|
|
88
|
+
const allGraphQLFiles = (0, copy_workspace_content_1.getAllGraphQLFiles)(source);
|
|
13
89
|
const output = path.join(source, 'index.graphql');
|
|
14
90
|
const index = fs.readFileSync(output, 'utf8');
|
|
91
|
+
let hasSchemaElement;
|
|
15
92
|
let ast = (0, graphql_1.parse)(index);
|
|
16
93
|
ast = (0, graphql_1.visit)(ast, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return arg;
|
|
28
|
-
});
|
|
29
|
-
return mutated;
|
|
94
|
+
SchemaDefinition(node) {
|
|
95
|
+
hasSchemaElement = true;
|
|
96
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
97
|
+
const idx = mutated.directives?.findIndex(directive => directive.name.value === 'sdl');
|
|
98
|
+
if (mutated.directives && idx !== undefined && idx > -1) {
|
|
99
|
+
mutated.directives[idx] = (0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles, mutated.directives[idx]);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
mutated.directives = mutated.directives || [];
|
|
103
|
+
mutated.directives.push((0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles));
|
|
30
104
|
}
|
|
105
|
+
return mutated;
|
|
31
106
|
},
|
|
32
107
|
});
|
|
108
|
+
if (!hasSchemaElement) {
|
|
109
|
+
ast = (0, graphql_1.visit)(ast, {
|
|
110
|
+
Document(node) {
|
|
111
|
+
const mutated = (0, graphql_helpers_1.cloneDeep)(node);
|
|
112
|
+
mutated.definitions.push((0, exports.createSchemaElement)(importedGraphQLFiles, allGraphQLFiles));
|
|
113
|
+
return mutated;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
33
117
|
fs.writeFileSync(output, (0, print_1.default)(ast));
|
|
34
118
|
};
|
|
35
119
|
//# sourceMappingURL=set-files-in-sdl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-files-in-sdl.js","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.js","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,qCAOgB;AAChB,6BAA4B;AAE5B,uDAA0D;AAC1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description": "The StepZen transpiler",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.0-beta.1",
|
|
5
5
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"clean": "rm -rf lib tsconfig.tsbuildinfo",
|
|
19
19
|
"build": "../../node_modules/.bin/tsc -b",
|
|
20
20
|
"test": "npm run build && nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
21
|
+
"test:single": "npm run build && mocha",
|
|
21
22
|
"posttest": "prettier . --check"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"nyc": "^14.1.1",
|
|
54
55
|
"ts-node": "^10.8.2"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3739f43046949449089e7483945efe1ac3008209"
|
|
57
58
|
}
|
package/src/actions/merge.ts
CHANGED
|
@@ -21,9 +21,15 @@ import print from './print'
|
|
|
21
21
|
import setFilesInSDL from '../utils/set-files-in-sdl'
|
|
22
22
|
import stripEmptyQueriesAndMutations from '../utils/strip-empty-queries-and-mutations'
|
|
23
23
|
import copyWorkspaceContent from '../utils/copy-workspace-content'
|
|
24
|
+
import {ALL_GRAPHQL_FILES} from '../utils/constants'
|
|
24
25
|
|
|
26
|
+
// It's safe to use this special placeholder value here: in case of a failure
|
|
27
|
+
// in the merge / import process it will not reach the workspace folder.
|
|
28
|
+
// All intermediary steps are carried out in a temp folder, and only when all
|
|
29
|
+
// merge / import steps are completed, the result it copied over to the
|
|
30
|
+
// workspace folder.
|
|
25
31
|
const BLANK_INDEX_TEMPLATE = `
|
|
26
|
-
schema @sdl(files: []) {
|
|
32
|
+
schema @sdl(files: ["${ALL_GRAPHQL_FILES}"]) {
|
|
27
33
|
query: Query
|
|
28
34
|
}
|
|
29
35
|
`.trim()
|
|
@@ -100,6 +106,7 @@ export default async (
|
|
|
100
106
|
? imported.name
|
|
101
107
|
: findNextAvailableSubfolder(original, imported.name)
|
|
102
108
|
|
|
109
|
+
let importedGraphQLFiles: string[] = []
|
|
103
110
|
if (options.mergeTypes) {
|
|
104
111
|
const merged = mergeTypeDefs([
|
|
105
112
|
await getSchema(options.output),
|
|
@@ -197,6 +204,7 @@ export default async (
|
|
|
197
204
|
|
|
198
205
|
fs.ensureFileSync(deduped)
|
|
199
206
|
fs.writeFileSync(deduped, print(a.ast))
|
|
207
|
+
importedGraphQLFiles.push(path.relative(options.output!, deduped))
|
|
200
208
|
})
|
|
201
209
|
} else {
|
|
202
210
|
glob.sync('**/*.graphql', {cwd: imported.source}).forEach(relativePath => {
|
|
@@ -208,11 +216,12 @@ export default async (
|
|
|
208
216
|
)
|
|
209
217
|
fs.ensureDirSync(path.dirname(targetFullPath))
|
|
210
218
|
fs.copyFileSync(importedFullPath, targetFullPath)
|
|
219
|
+
importedGraphQLFiles.push(path.relative(options.output!, targetFullPath))
|
|
211
220
|
})
|
|
212
221
|
}
|
|
213
222
|
|
|
214
223
|
// Make sure all files are referenced in @sdl
|
|
215
|
-
setFilesInSDL(options.output)
|
|
224
|
+
setFilesInSDL(options.output, importedGraphQLFiles)
|
|
216
225
|
|
|
217
226
|
// Generate configuration
|
|
218
227
|
const config = await getConfiguration(
|
package/src/actions/stitch.ts
CHANGED
|
@@ -7,6 +7,8 @@ import * as path from 'path'
|
|
|
7
7
|
import * as prettier from 'prettier'
|
|
8
8
|
|
|
9
9
|
import dedupeQueryAndMutationTypes from '../utils/dedupe-query-and-mutation-types'
|
|
10
|
+
import {ALL_GRAPHQL_FILES} from '../utils/constants'
|
|
11
|
+
import {getAllGraphQLFiles} from '../utils/copy-workspace-content'
|
|
10
12
|
|
|
11
13
|
export default (
|
|
12
14
|
source: string,
|
|
@@ -37,7 +39,11 @@ export default (
|
|
|
37
39
|
if (list) {
|
|
38
40
|
const copy: any = clone(list.value)
|
|
39
41
|
for (const file of copy.values) {
|
|
40
|
-
|
|
42
|
+
if (file.value === ALL_GRAPHQL_FILES) {
|
|
43
|
+
files = files.concat(getAllGraphQLFiles(source))
|
|
44
|
+
} else {
|
|
45
|
+
files = files.concat(file.value)
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
const mutated: any = cloneDeep(node)
|
|
43
49
|
mutated.arguments = mutated.arguments.filter(
|
|
@@ -69,7 +75,9 @@ export default (
|
|
|
69
75
|
for (const file of files) {
|
|
70
76
|
const find = path.join(source, file)
|
|
71
77
|
if (!fs.existsSync(find)) {
|
|
72
|
-
throw new Error(
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Cannot find file ${file} referenced in the @sdl directive in index.graphql`,
|
|
80
|
+
)
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
package/src/actions/transpile.ts
CHANGED
|
@@ -11,6 +11,16 @@ import configure from './configure'
|
|
|
11
11
|
|
|
12
12
|
import configMutations from '../mutations/config'
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
16
|
+
* transformations, and return its effective GraphQL schema and configuration
|
|
17
|
+
* as in-memory strings.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} source absolute path to a schema root folder
|
|
20
|
+
* @return {*} schema, configuration, and a "transpiled" flag indicating
|
|
21
|
+
* whether or not any StepZen-specific transformations have actually
|
|
22
|
+
* been applied.
|
|
23
|
+
*/
|
|
14
24
|
export default async (source: string) => {
|
|
15
25
|
// Ensure source and output directories exist
|
|
16
26
|
if (!fs.existsSync(source)) {
|
package/src/utils/constants.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as fs from 'fs-extra'
|
|
|
2
2
|
import * as glob from 'glob'
|
|
3
3
|
import * as path from 'path'
|
|
4
4
|
import {flatMap} from 'lodash'
|
|
5
|
+
import {ALL_GRAPHQL_FILES} from './constants'
|
|
5
6
|
|
|
6
7
|
const WORKSPACE_FILE_PATTERNS = [
|
|
7
8
|
'**/*.graphql',
|
|
@@ -39,3 +40,9 @@ export default (srcPath: string, dstPath: string) => {
|
|
|
39
40
|
fs.copyFileSync(srcFileFullPath, dstFileFullPath)
|
|
40
41
|
})
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
export const getAllGraphQLFiles = (srcPath: string) => {
|
|
45
|
+
return glob
|
|
46
|
+
.sync(ALL_GRAPHQL_FILES, {cwd: srcPath})
|
|
47
|
+
.filter(file => file !== 'index.graphql')
|
|
48
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type DeepWriteable<T> = {-readonly [P in keyof T]: DeepWriteable<T[P]>}
|
|
2
|
+
export const cloneDeep = <T>(obj: T): DeepWriteable<T> =>
|
|
3
|
+
JSON.parse(JSON.stringify(obj))
|
|
@@ -1,40 +1,149 @@
|
|
|
1
1
|
import * as fs from 'fs'
|
|
2
2
|
import * as glob from 'glob'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DirectiveNode,
|
|
5
|
+
ListValueNode,
|
|
6
|
+
parse,
|
|
7
|
+
SchemaDefinitionNode,
|
|
8
|
+
StringValueNode,
|
|
9
|
+
visit,
|
|
10
|
+
} from 'graphql'
|
|
4
11
|
import * as path from 'path'
|
|
5
12
|
|
|
6
|
-
import {cloneDeep} from './graphql-helpers'
|
|
13
|
+
import {cloneDeep, DeepWriteable} from './graphql-helpers'
|
|
7
14
|
import print from '../actions/print'
|
|
15
|
+
import {ALL_GRAPHQL_FILES} from './constants'
|
|
16
|
+
import {getAllGraphQLFiles} from './copy-workspace-content'
|
|
8
17
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
export const createOrUpdateSdlDirective = (
|
|
19
|
+
importedGraphQLFiles: readonly string[],
|
|
20
|
+
allGraphQLFiles: readonly string[],
|
|
21
|
+
origSdlDirective?: DeepWriteable<DirectiveNode>,
|
|
22
|
+
) => {
|
|
23
|
+
let sdlDirective: DeepWriteable<DirectiveNode>
|
|
24
|
+
if (origSdlDirective) {
|
|
25
|
+
sdlDirective = cloneDeep(origSdlDirective)
|
|
26
|
+
} else {
|
|
27
|
+
sdlDirective = {
|
|
28
|
+
kind: 'Directive',
|
|
29
|
+
name: {
|
|
30
|
+
kind: 'Name',
|
|
31
|
+
value: 'sdl',
|
|
32
|
+
},
|
|
33
|
+
arguments: [
|
|
34
|
+
{
|
|
35
|
+
kind: 'Argument',
|
|
36
|
+
name: {
|
|
37
|
+
kind: 'Name',
|
|
38
|
+
value: 'files',
|
|
39
|
+
},
|
|
40
|
+
value: {
|
|
41
|
+
kind: 'ListValue',
|
|
42
|
+
values: [
|
|
43
|
+
{
|
|
44
|
+
kind: 'StringValue',
|
|
45
|
+
value: ALL_GRAPHQL_FILES,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
}
|
|
13
53
|
|
|
14
|
-
|
|
54
|
+
sdlDirective.arguments = sdlDirective.arguments?.map(arg => {
|
|
55
|
+
if (arg.name.value === 'files') {
|
|
56
|
+
const filesValueNodes = arg.value as DeepWriteable<ListValueNode>
|
|
57
|
+
const fileset = new Set<string>([
|
|
58
|
+
...filesValueNodes.values.map(
|
|
59
|
+
value => (value as StringValueNode).value,
|
|
60
|
+
),
|
|
61
|
+
...importedGraphQLFiles,
|
|
62
|
+
])
|
|
63
|
+
if (fileset.has(ALL_GRAPHQL_FILES)) {
|
|
64
|
+
fileset.delete(ALL_GRAPHQL_FILES)
|
|
65
|
+
allGraphQLFiles.forEach(file => fileset.add(file))
|
|
66
|
+
}
|
|
67
|
+
filesValueNodes.values = [...fileset].map(file => ({
|
|
68
|
+
kind: 'StringValue',
|
|
69
|
+
value: file,
|
|
70
|
+
}))
|
|
71
|
+
}
|
|
72
|
+
return arg
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
return sdlDirective
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const createSchemaElement = (
|
|
79
|
+
importedGraphQLFiles: readonly string[],
|
|
80
|
+
allGraphQLFiles: readonly string[],
|
|
81
|
+
) => {
|
|
82
|
+
const schemaElement: DeepWriteable<SchemaDefinitionNode> = {
|
|
83
|
+
kind: 'SchemaDefinition',
|
|
84
|
+
directives: [
|
|
85
|
+
createOrUpdateSdlDirective(importedGraphQLFiles, allGraphQLFiles),
|
|
86
|
+
],
|
|
87
|
+
operationTypes: [
|
|
88
|
+
{
|
|
89
|
+
kind: 'OperationTypeDefinition',
|
|
90
|
+
operation: 'query',
|
|
91
|
+
type: {
|
|
92
|
+
kind: 'NamedType',
|
|
93
|
+
name: {
|
|
94
|
+
kind: 'Name',
|
|
95
|
+
value: 'Query',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return schemaElement
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default (source: string, importedGraphQLFiles: readonly string[]) => {
|
|
106
|
+
const allGraphQLFiles = getAllGraphQLFiles(source)
|
|
15
107
|
|
|
108
|
+
const output = path.join(source, 'index.graphql')
|
|
16
109
|
const index = fs.readFileSync(output, 'utf8')
|
|
17
110
|
|
|
111
|
+
let hasSchemaElement
|
|
18
112
|
let ast = parse(index)
|
|
19
113
|
ast = visit(ast, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
114
|
+
SchemaDefinition(node) {
|
|
115
|
+
hasSchemaElement = true
|
|
116
|
+
const mutated = cloneDeep(node)
|
|
117
|
+
const idx = mutated.directives?.findIndex(
|
|
118
|
+
directive => directive.name.value === 'sdl',
|
|
119
|
+
)
|
|
120
|
+
if (mutated.directives && idx !== undefined && idx > -1) {
|
|
121
|
+
mutated.directives[idx] = createOrUpdateSdlDirective(
|
|
122
|
+
importedGraphQLFiles,
|
|
123
|
+
allGraphQLFiles,
|
|
124
|
+
mutated.directives[idx],
|
|
125
|
+
)
|
|
126
|
+
} else {
|
|
127
|
+
mutated.directives = mutated.directives || []
|
|
128
|
+
mutated.directives.push(
|
|
129
|
+
createOrUpdateSdlDirective(importedGraphQLFiles, allGraphQLFiles),
|
|
130
|
+
)
|
|
35
131
|
}
|
|
132
|
+
return mutated
|
|
36
133
|
},
|
|
37
134
|
})
|
|
38
135
|
|
|
136
|
+
if (!hasSchemaElement) {
|
|
137
|
+
ast = visit(ast, {
|
|
138
|
+
Document(node) {
|
|
139
|
+
const mutated = cloneDeep(node)
|
|
140
|
+
mutated.definitions.push(
|
|
141
|
+
createSchemaElement(importedGraphQLFiles, allGraphQLFiles),
|
|
142
|
+
)
|
|
143
|
+
return mutated
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
39
148
|
fs.writeFileSync(output, print(ast))
|
|
40
149
|
}
|