@snowtop/ent 0.1.0-alpha97 → 0.1.0-alpha98-5dd3b3b0-9b44-11ed-83bb-45feb44f884b
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/core/config.d.ts +1 -0
- package/graphql/graphql.d.ts +2 -0
- package/package.json +1 -1
- package/scripts/custom_graphql.js +42 -1
package/core/config.d.ts
CHANGED
package/graphql/graphql.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@ const graphql_1 = require("../graphql/graphql");
|
|
|
36
36
|
const readline = __importStar(require("readline"));
|
|
37
37
|
const imports_1 = require("../imports");
|
|
38
38
|
const process_1 = require("process");
|
|
39
|
+
const child_process_1 = require("child_process");
|
|
39
40
|
// need to use the GQLCapture from the package so that when we call GQLCapture.enable()
|
|
40
41
|
// we're affecting the local paths as opposed to a different instance
|
|
41
42
|
// life is hard
|
|
@@ -115,6 +116,8 @@ function processTopLevel(l, l2) {
|
|
|
115
116
|
args: transformArgs(custom),
|
|
116
117
|
results: transformResultType(custom),
|
|
117
118
|
description: custom.description,
|
|
119
|
+
extraImports: custom.extraImports,
|
|
120
|
+
functionContents: custom.functionContents,
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
}
|
|
@@ -134,6 +137,43 @@ function processCustomFields(fields, gqlCapture, nodeName) {
|
|
|
134
137
|
}
|
|
135
138
|
m.set(nodeName, results);
|
|
136
139
|
}
|
|
140
|
+
async function captureDynamic(filePath, gqlCapture) {
|
|
141
|
+
if (!filePath) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return await new Promise((resolve, reject) => {
|
|
145
|
+
// TODO tsconfig-paths?
|
|
146
|
+
const r = (0, child_process_1.spawn)("ts-node", [filePath]);
|
|
147
|
+
const datas = [];
|
|
148
|
+
r.stdout.on("data", (data) => {
|
|
149
|
+
datas.push(data.toString());
|
|
150
|
+
});
|
|
151
|
+
r.stderr.on("data", (data) => {
|
|
152
|
+
reject(new Error(data.toString()));
|
|
153
|
+
});
|
|
154
|
+
r.on("close", (code) => {
|
|
155
|
+
if (code !== 0) {
|
|
156
|
+
reject(new Error(`error code ${code} on dynamic path`));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
let json = json5_1.default.parse(datas.join(""));
|
|
160
|
+
for (const k in json) {
|
|
161
|
+
const v = json[k];
|
|
162
|
+
switch (k) {
|
|
163
|
+
case "queries":
|
|
164
|
+
processTopLevel(v, gqlCapture.getCustomQueries());
|
|
165
|
+
break;
|
|
166
|
+
case "mutations":
|
|
167
|
+
processTopLevel(v, gqlCapture.getCustomMutations());
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
reject(new Error(`key ${k} is unsupported in dynamic custom graphql. only queries and mutations are supported`));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
resolve(undefined);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
137
177
|
async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
|
|
138
178
|
if (jsonPath !== undefined) {
|
|
139
179
|
let json = json5_1.default.parse(fs.readFileSync(jsonPath, {
|
|
@@ -297,9 +337,10 @@ async function main() {
|
|
|
297
337
|
gqlCapture = r.GQLCapture;
|
|
298
338
|
gqlCapture.enable(true);
|
|
299
339
|
}
|
|
300
|
-
const [inputsRead, _, imports] = await Promise.all([
|
|
340
|
+
const [inputsRead, _, __, imports] = await Promise.all([
|
|
301
341
|
readInputs(),
|
|
302
342
|
captureCustom(options.path, options.files, options.json_path, gqlCapture),
|
|
343
|
+
captureDynamic(options.dynamic_path, gqlCapture),
|
|
303
344
|
parseImports(options.path),
|
|
304
345
|
]);
|
|
305
346
|
const { nodes, nodesMap } = inputsRead;
|