graphql-jerky 1.0.4 → 1.0.6
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/build/bin/jerky.cjs +16 -8
- package/build/bin/jerky.mjs +17 -9
- package/build/lib.cjs +532 -221
- package/build/lib.d.ts +1 -0
- package/build/lib.mjs +532 -221
- package/package.json +3 -2
package/build/bin/jerky.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
+
var path = require('path');
|
|
5
6
|
var commander = require('commander');
|
|
6
7
|
var fs = require('fs/promises');
|
|
7
|
-
var path = require('path');
|
|
8
8
|
var lib = require('../lib.cjs');
|
|
9
9
|
|
|
10
10
|
commander.program
|
|
@@ -19,7 +19,7 @@ commander.program
|
|
|
19
19
|
.option("--subscribers <module>", "subscriber module import specifier.")
|
|
20
20
|
.option("--field-directives <module>", "field directives module import specifier.")
|
|
21
21
|
.option("--input-directives <module>", "input directives module import specifier.")
|
|
22
|
-
.option("--ext <mode>",
|
|
22
|
+
.option("--ext <mode>", 'whether "keep", "replace", or "omit" the .ts extension in import statements.')
|
|
23
23
|
.showHelpAfterError(true);
|
|
24
24
|
commander.program.parse();
|
|
25
25
|
const { out = "schema_gen.ts", graphql = "graphql", scalars, resolvers, subscribers, fieldDirectives, inputDirectives, ext = "omit", } = commander.program.opts();
|
|
@@ -45,25 +45,33 @@ const [schema = "."] = commander.program.args;
|
|
|
45
45
|
outfile += ".ts";
|
|
46
46
|
}
|
|
47
47
|
switch (ext) {
|
|
48
|
-
default:
|
|
49
|
-
throw new Error(`invalid mode for --ext: ${ext}`);
|
|
50
48
|
case "keep":
|
|
51
49
|
case "replace":
|
|
52
50
|
case "omit":
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
throw new Error(`invalid mode for --ext: ${ext}`);
|
|
53
54
|
}
|
|
54
55
|
await fs.writeFile(outfile, lib.generate(await lib.parseSchema(path.resolve(schema)), outfile.pathname, {
|
|
55
56
|
scalarsInfo: scalars ? await lib.parseScalars(scalars) : undefined,
|
|
56
|
-
fieldDirectivesInfo: fieldDirectives
|
|
57
|
-
|
|
57
|
+
fieldDirectivesInfo: fieldDirectives
|
|
58
|
+
? await lib.parseTypeResolvers("", fieldDirectives)
|
|
59
|
+
: undefined,
|
|
60
|
+
inputDirectivesInfo: inputDirectives
|
|
61
|
+
? await lib.parseTypeResolvers("", inputDirectives)
|
|
62
|
+
: undefined,
|
|
58
63
|
resolversInfo: resolvers ? await lib.parseResolvers(resolvers) : undefined,
|
|
59
|
-
subscribersInfo: subscribers
|
|
64
|
+
subscribersInfo: subscribers
|
|
65
|
+
? await lib.parseTypeResolvers("Subscription", subscribers)
|
|
66
|
+
: undefined,
|
|
60
67
|
graphqlModuleSpecifier: graphql,
|
|
61
68
|
extMode: ext,
|
|
62
69
|
}));
|
|
63
70
|
})().catch((err) => {
|
|
64
71
|
console.error(err.message);
|
|
65
72
|
console.log();
|
|
66
|
-
if (process.argv.length === 2 ||
|
|
73
|
+
if (process.argv.length === 2 ||
|
|
74
|
+
(process.argv.length === 3 && process.argv[2] === "help")) {
|
|
67
75
|
commander.program.outputHelp();
|
|
68
76
|
}
|
|
69
77
|
});
|
package/build/bin/jerky.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import path from 'path';
|
|
3
4
|
import { program } from 'commander';
|
|
4
5
|
import fs from 'fs/promises';
|
|
5
|
-
import path from 'path';
|
|
6
6
|
import { generate, parseScalars as parse, parseTypeResolvers, parseResolvers as parse$1, parseSchema as parse$2 } from '../lib.mjs';
|
|
7
|
+
import 'url';
|
|
7
8
|
import 'graphql';
|
|
8
9
|
import 'jennifer-js';
|
|
9
10
|
import 'jennifer-js/format';
|
|
10
11
|
import 'just-partition';
|
|
11
12
|
import 'just-pascal-case';
|
|
12
|
-
import 'url';
|
|
13
13
|
import 'typescript';
|
|
14
14
|
import 'glob';
|
|
15
15
|
import 'picomatch';
|
|
@@ -27,7 +27,7 @@ program
|
|
|
27
27
|
.option("--subscribers <module>", "subscriber module import specifier.")
|
|
28
28
|
.option("--field-directives <module>", "field directives module import specifier.")
|
|
29
29
|
.option("--input-directives <module>", "input directives module import specifier.")
|
|
30
|
-
.option("--ext <mode>",
|
|
30
|
+
.option("--ext <mode>", 'whether "keep", "replace", or "omit" the .ts extension in import statements.')
|
|
31
31
|
.showHelpAfterError(true);
|
|
32
32
|
program.parse();
|
|
33
33
|
const { out = "schema_gen.ts", graphql = "graphql", scalars, resolvers, subscribers, fieldDirectives, inputDirectives, ext = "omit", } = program.opts();
|
|
@@ -53,25 +53,33 @@ const [schema = "."] = program.args;
|
|
|
53
53
|
outfile += ".ts";
|
|
54
54
|
}
|
|
55
55
|
switch (ext) {
|
|
56
|
-
default:
|
|
57
|
-
throw new Error(`invalid mode for --ext: ${ext}`);
|
|
58
56
|
case "keep":
|
|
59
57
|
case "replace":
|
|
60
58
|
case "omit":
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`invalid mode for --ext: ${ext}`);
|
|
61
62
|
}
|
|
62
63
|
await fs.writeFile(outfile, generate(await parse$2(path.resolve(schema)), outfile.pathname, {
|
|
63
64
|
scalarsInfo: scalars ? await parse(scalars) : undefined,
|
|
64
|
-
fieldDirectivesInfo: fieldDirectives
|
|
65
|
-
|
|
65
|
+
fieldDirectivesInfo: fieldDirectives
|
|
66
|
+
? await parseTypeResolvers("", fieldDirectives)
|
|
67
|
+
: undefined,
|
|
68
|
+
inputDirectivesInfo: inputDirectives
|
|
69
|
+
? await parseTypeResolvers("", inputDirectives)
|
|
70
|
+
: undefined,
|
|
66
71
|
resolversInfo: resolvers ? await parse$1(resolvers) : undefined,
|
|
67
|
-
subscribersInfo: subscribers
|
|
72
|
+
subscribersInfo: subscribers
|
|
73
|
+
? await parseTypeResolvers("Subscription", subscribers)
|
|
74
|
+
: undefined,
|
|
68
75
|
graphqlModuleSpecifier: graphql,
|
|
69
76
|
extMode: ext,
|
|
70
77
|
}));
|
|
71
78
|
})().catch((err) => {
|
|
72
79
|
console.error(err.message);
|
|
73
80
|
console.log();
|
|
74
|
-
if (process.argv.length === 2 ||
|
|
81
|
+
if (process.argv.length === 2 ||
|
|
82
|
+
(process.argv.length === 3 && process.argv[2] === "help")) {
|
|
75
83
|
program.outputHelp();
|
|
76
84
|
}
|
|
77
85
|
});
|