graphql-data-generator 0.4.0-alpha.4 → 0.4.0-alpha.5
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/esm/cli.js +2 -3
- package/esm/codegen.js +1 -1
- package/esm/index.js +1 -1
- package/esm/jest.js +1 -1
- package/esm/plugin.cjs +1 -2
- package/esm/util.js +0 -33
- package/package.json +1 -1
- package/script/cli.js +2 -3
- package/script/codegen.js +1 -1
- package/script/index.js +1 -2
- package/script/jest.js +1 -1
- package/script/plugin.cjs +1 -2
- package/script/util.js +1 -35
- package/types/index.d.ts +1 -1
- package/types/util.d.ts +0 -1
package/esm/cli.js
CHANGED
|
@@ -4,7 +4,6 @@ import { readFile } from "node:fs";
|
|
|
4
4
|
import fg from "fast-glob";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
import { codegen, loadFiles } from "./codegen.js";
|
|
7
|
-
import { formatCode } from "./util.js";
|
|
8
7
|
import process from "node:process";
|
|
9
8
|
(async () => {
|
|
10
9
|
const args = parseArgs({
|
|
@@ -80,14 +79,14 @@ import process from "node:process";
|
|
|
80
79
|
banner = args.banner;
|
|
81
80
|
}
|
|
82
81
|
try {
|
|
83
|
-
const file = banner +
|
|
82
|
+
const file = banner + codegen(schema, operations, {
|
|
84
83
|
enums: args.enums,
|
|
85
84
|
includeTypenames: !args.notypenames,
|
|
86
85
|
scalars,
|
|
87
86
|
exports,
|
|
88
87
|
typesFile: args.typesFile,
|
|
89
88
|
namingConvention: args.namingConvention,
|
|
90
|
-
})
|
|
89
|
+
});
|
|
91
90
|
if (args.outfile)
|
|
92
91
|
await dntShim.Deno.writeTextFile(args.outfile, file);
|
|
93
92
|
else
|
package/esm/codegen.js
CHANGED
|
@@ -604,6 +604,6 @@ export const loadFiles = async (schemaPath, operationDirs) => {
|
|
|
604
604
|
}
|
|
605
605
|
return [
|
|
606
606
|
await readFile(schemaPath, "utf-8"),
|
|
607
|
-
await Promise.all(operationPromises),
|
|
607
|
+
(await Promise.all(operationPromises)).sort((a, b) => a.path.localeCompare(b.path)),
|
|
608
608
|
];
|
|
609
609
|
};
|
package/esm/index.js
CHANGED
package/esm/jest.js
CHANGED
|
@@ -207,8 +207,8 @@ export const MockedProvider = ({ mocks, stack: renderStack, children, link: pass
|
|
|
207
207
|
});
|
|
208
208
|
return ApolloLink.from([
|
|
209
209
|
errorLoggingLink,
|
|
210
|
-
mockLink,
|
|
211
210
|
...(passedLink ? [passedLink] : []),
|
|
211
|
+
mockLink,
|
|
212
212
|
]);
|
|
213
213
|
}, [observableMocks, renderStack]);
|
|
214
214
|
if (_failRefetchWarnings) {
|
package/esm/plugin.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
module.exports = {
|
|
3
3
|
async plugin(schema, documents, config) {
|
|
4
4
|
const { codegen } = await import("./codegen.js");
|
|
5
|
-
|
|
6
|
-
return (config.banner ?? "") + await formatCode(codegen(schema, documents.map((d) => ({ path: d.location, content: d.rawSDL })), { namingConvention: "change-case-all#pascalCase", ...config }));
|
|
5
|
+
return (config.banner ?? "") + codegen(schema, documents.map((d) => ({ path: d.location, content: d.rawSDL })), { namingConvention: "change-case-all#pascalCase", ...config });
|
|
7
6
|
},
|
|
8
7
|
};
|
package/esm/util.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
1
|
export const raise = (error) => {
|
|
3
2
|
if (typeof error === "string") {
|
|
4
3
|
const err = new Error(error);
|
|
@@ -7,38 +6,6 @@ export const raise = (error) => {
|
|
|
7
6
|
}
|
|
8
7
|
throw error;
|
|
9
8
|
};
|
|
10
|
-
export const formatCode = async (input) => {
|
|
11
|
-
try {
|
|
12
|
-
return await new Promise((resolve, reject) => {
|
|
13
|
-
const process = spawn("deno", ["fmt", "-"], {
|
|
14
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
15
|
-
});
|
|
16
|
-
let output = "";
|
|
17
|
-
let errorOutput = "";
|
|
18
|
-
process.stdout.on("data", (data) => {
|
|
19
|
-
output += data.toString();
|
|
20
|
-
});
|
|
21
|
-
process.stderr.on("data", (data) => {
|
|
22
|
-
errorOutput += data.toString();
|
|
23
|
-
});
|
|
24
|
-
process.on("close", (code) => {
|
|
25
|
-
if (code !== 0 || errorOutput) {
|
|
26
|
-
reject(new Error(errorOutput || `Process exited with code ${code}`));
|
|
27
|
-
}
|
|
28
|
-
else
|
|
29
|
-
resolve(output);
|
|
30
|
-
});
|
|
31
|
-
process.on("error", (error) => {
|
|
32
|
-
reject(error);
|
|
33
|
-
});
|
|
34
|
-
process.stdin.write(input);
|
|
35
|
-
process.stdin?.end();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return input;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
9
|
export const absurd = (v) => {
|
|
43
10
|
const error = new Error(`Unexpected value: ${v}`);
|
|
44
11
|
Error.captureStackTrace(error, absurd);
|
package/package.json
CHANGED
package/script/cli.js
CHANGED
|
@@ -32,7 +32,6 @@ const node_fs_1 = require("node:fs");
|
|
|
32
32
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
33
33
|
const node_util_1 = require("node:util");
|
|
34
34
|
const codegen_js_1 = require("./codegen.js");
|
|
35
|
-
const util_js_1 = require("./util.js");
|
|
36
35
|
const node_process_1 = __importDefault(require("node:process"));
|
|
37
36
|
(async () => {
|
|
38
37
|
const args = (0, node_util_1.parseArgs)({
|
|
@@ -108,14 +107,14 @@ const node_process_1 = __importDefault(require("node:process"));
|
|
|
108
107
|
banner = args.banner;
|
|
109
108
|
}
|
|
110
109
|
try {
|
|
111
|
-
const file = banner +
|
|
110
|
+
const file = banner + (0, codegen_js_1.codegen)(schema, operations, {
|
|
112
111
|
enums: args.enums,
|
|
113
112
|
includeTypenames: !args.notypenames,
|
|
114
113
|
scalars,
|
|
115
114
|
exports,
|
|
116
115
|
typesFile: args.typesFile,
|
|
117
116
|
namingConvention: args.namingConvention,
|
|
118
|
-
})
|
|
117
|
+
});
|
|
119
118
|
if (args.outfile)
|
|
120
119
|
await dntShim.Deno.writeTextFile(args.outfile, file);
|
|
121
120
|
else
|
package/script/codegen.js
CHANGED
|
@@ -611,7 +611,7 @@ const loadFiles = async (schemaPath, operationDirs) => {
|
|
|
611
611
|
}
|
|
612
612
|
return [
|
|
613
613
|
await (0, promises_1.readFile)(schemaPath, "utf-8"),
|
|
614
|
-
await Promise.all(operationPromises),
|
|
614
|
+
(await Promise.all(operationPromises)).sort((a, b) => a.path.localeCompare(b.path)),
|
|
615
615
|
];
|
|
616
616
|
};
|
|
617
617
|
exports.loadFiles = loadFiles;
|
package/script/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toObject = exports.
|
|
3
|
+
exports.toObject = exports.proxy = exports.operation = exports.clear = exports.codegen = exports.init = void 0;
|
|
4
4
|
var init_js_1 = require("./init.js");
|
|
5
5
|
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_js_1.init; } });
|
|
6
6
|
var codegen_js_1 = require("./codegen.js");
|
|
@@ -10,5 +10,4 @@ Object.defineProperty(exports, "clear", { enumerable: true, get: function () { r
|
|
|
10
10
|
Object.defineProperty(exports, "operation", { enumerable: true, get: function () { return proxy_js_1.operation; } });
|
|
11
11
|
Object.defineProperty(exports, "proxy", { enumerable: true, get: function () { return proxy_js_1.proxy; } });
|
|
12
12
|
var util_js_1 = require("./util.js");
|
|
13
|
-
Object.defineProperty(exports, "formatCode", { enumerable: true, get: function () { return util_js_1.formatCode; } });
|
|
14
13
|
Object.defineProperty(exports, "toObject", { enumerable: true, get: function () { return util_js_1.toObject; } });
|
package/script/jest.js
CHANGED
|
@@ -237,8 +237,8 @@ const MockedProvider = ({ mocks, stack: renderStack, children, link: passedLink,
|
|
|
237
237
|
});
|
|
238
238
|
return client_1.ApolloLink.from([
|
|
239
239
|
errorLoggingLink,
|
|
240
|
-
mockLink,
|
|
241
240
|
...(passedLink ? [passedLink] : []),
|
|
241
|
+
mockLink,
|
|
242
242
|
]);
|
|
243
243
|
}, [observableMocks, renderStack]);
|
|
244
244
|
if (_failRefetchWarnings) {
|
package/script/plugin.cjs
CHANGED
|
@@ -25,7 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
module.exports = {
|
|
26
26
|
async plugin(schema, documents, config) {
|
|
27
27
|
const { codegen } = await Promise.resolve().then(() => __importStar(require("./codegen.js")));
|
|
28
|
-
|
|
29
|
-
return (config.banner ?? "") + await formatCode(codegen(schema, documents.map((d) => ({ path: d.location, content: d.rawSDL })), { namingConvention: "change-case-all#pascalCase", ...config }));
|
|
28
|
+
return (config.banner ?? "") + codegen(schema, documents.map((d) => ({ path: d.location, content: d.rawSDL })), { namingConvention: "change-case-all#pascalCase", ...config });
|
|
30
29
|
},
|
|
31
30
|
};
|
package/script/util.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toObject = exports.absurd = exports.
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
3
|
+
exports.toObject = exports.absurd = exports.raise = void 0;
|
|
5
4
|
const raise = (error) => {
|
|
6
5
|
if (typeof error === "string") {
|
|
7
6
|
const err = new Error(error);
|
|
@@ -11,39 +10,6 @@ const raise = (error) => {
|
|
|
11
10
|
throw error;
|
|
12
11
|
};
|
|
13
12
|
exports.raise = raise;
|
|
14
|
-
const formatCode = async (input) => {
|
|
15
|
-
try {
|
|
16
|
-
return await new Promise((resolve, reject) => {
|
|
17
|
-
const process = (0, node_child_process_1.spawn)("deno", ["fmt", "-"], {
|
|
18
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
19
|
-
});
|
|
20
|
-
let output = "";
|
|
21
|
-
let errorOutput = "";
|
|
22
|
-
process.stdout.on("data", (data) => {
|
|
23
|
-
output += data.toString();
|
|
24
|
-
});
|
|
25
|
-
process.stderr.on("data", (data) => {
|
|
26
|
-
errorOutput += data.toString();
|
|
27
|
-
});
|
|
28
|
-
process.on("close", (code) => {
|
|
29
|
-
if (code !== 0 || errorOutput) {
|
|
30
|
-
reject(new Error(errorOutput || `Process exited with code ${code}`));
|
|
31
|
-
}
|
|
32
|
-
else
|
|
33
|
-
resolve(output);
|
|
34
|
-
});
|
|
35
|
-
process.on("error", (error) => {
|
|
36
|
-
reject(error);
|
|
37
|
-
});
|
|
38
|
-
process.stdin.write(input);
|
|
39
|
-
process.stdin?.end();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return input;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
exports.formatCode = formatCode;
|
|
47
13
|
const absurd = (v) => {
|
|
48
14
|
const error = new Error(`Unexpected value: ${v}`);
|
|
49
15
|
Error.captureStackTrace(error, exports.absurd);
|
package/types/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { init } from "./init.js";
|
|
|
2
2
|
export type { DeepPartial, OperationMock, Patch } from "./types.js";
|
|
3
3
|
export { codegen } from "./codegen.js";
|
|
4
4
|
export { clear, operation, proxy } from "./proxy.js";
|
|
5
|
-
export {
|
|
5
|
+
export { toObject } from "./util.js";
|
package/types/util.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const raise: (error: Error | string) => never;
|
|
2
|
-
export declare const formatCode: (input: string) => Promise<string>;
|
|
3
2
|
export declare const absurd: (v: never) => never;
|
|
4
3
|
type StripFunctions<T> = {
|
|
5
4
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : T[K] extends object ? StripFunctions<T[K]> : T[K];
|