@ttoss/graphql-api 0.4.1 → 0.4.2
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/dist/cli.js +9 -3
- package/dist/esm/cli.js +9 -3
- package/package.json +1 -1
- package/src/cli.ts +15 -5
package/dist/cli.js
CHANGED
|
@@ -43,6 +43,14 @@ var argv = (0, import_yargs.default)(process.argv.slice(2)).argv;
|
|
|
43
43
|
(async () => {
|
|
44
44
|
if (argv._.includes("build-schema")) {
|
|
45
45
|
import_npmlog.default.info(logPrefix, "Building schema...");
|
|
46
|
+
await fs.promises.mkdir("schema", {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
await fs.promises.access("schema/types.ts");
|
|
51
|
+
} catch {
|
|
52
|
+
await fs.promises.writeFile("schema/types.ts", "");
|
|
53
|
+
}
|
|
46
54
|
const {
|
|
47
55
|
schemaComposer
|
|
48
56
|
} = require(path.resolve(process.cwd(), "src", "schemaComposer.ts"));
|
|
@@ -65,10 +73,8 @@ var argv = (0, import_yargs.default)(process.argv.slice(2)).argv;
|
|
|
65
73
|
typescript: typescriptPlugin
|
|
66
74
|
}
|
|
67
75
|
};
|
|
68
|
-
await fs.promises.mkdir("schema", {
|
|
69
|
-
recursive: true
|
|
70
|
-
});
|
|
71
76
|
await fs.promises.writeFile("schema/schema.graphql", sdl);
|
|
77
|
+
import_npmlog.default.info(logPrefix, "Generating types...");
|
|
72
78
|
const typesOutput = await (0, import_core.codegen)(codegenConfig);
|
|
73
79
|
const typesOutputIgnore = ["/* eslint-disable */"].join("\n");
|
|
74
80
|
await fs.promises.writeFile("schema/types.ts", `${typesOutputIgnore}
|
package/dist/esm/cli.js
CHANGED
|
@@ -18,6 +18,14 @@ var argv = yargs(process.argv.slice(2)).argv;
|
|
|
18
18
|
(async () => {
|
|
19
19
|
if (argv._.includes("build-schema")) {
|
|
20
20
|
log.info(logPrefix, "Building schema...");
|
|
21
|
+
await fs.promises.mkdir("schema", {
|
|
22
|
+
recursive: true
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
await fs.promises.access("schema/types.ts");
|
|
26
|
+
} catch {
|
|
27
|
+
await fs.promises.writeFile("schema/types.ts", "");
|
|
28
|
+
}
|
|
21
29
|
const {
|
|
22
30
|
schemaComposer
|
|
23
31
|
} = __require(path.resolve(process.cwd(), "src", "schemaComposer.ts"));
|
|
@@ -40,10 +48,8 @@ var argv = yargs(process.argv.slice(2)).argv;
|
|
|
40
48
|
typescript: typescriptPlugin
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
|
-
await fs.promises.mkdir("schema", {
|
|
44
|
-
recursive: true
|
|
45
|
-
});
|
|
46
51
|
await fs.promises.writeFile("schema/schema.graphql", sdl);
|
|
52
|
+
log.info(logPrefix, "Generating types...");
|
|
47
53
|
const typesOutput = await codegen(codegenConfig);
|
|
48
54
|
const typesOutputIgnore = ["/* eslint-disable */"].join("\n");
|
|
49
55
|
await fs.promises.writeFile("schema/types.ts", `${typesOutputIgnore}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -20,6 +20,19 @@ const argv: any = yargs(process.argv.slice(2)).argv;
|
|
|
20
20
|
if (argv._.includes('build-schema')) {
|
|
21
21
|
log.info(logPrefix, 'Building schema...');
|
|
22
22
|
|
|
23
|
+
await fs.promises.mkdir('schema', { recursive: true });
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create schema/types.ts if it doesn't exist. We need to do this because
|
|
27
|
+
* graphql-codegen will throw an error if the file doesn't exist and the
|
|
28
|
+
* code import the types from that file.
|
|
29
|
+
*/
|
|
30
|
+
try {
|
|
31
|
+
await fs.promises.access('schema/types.ts');
|
|
32
|
+
} catch {
|
|
33
|
+
await fs.promises.writeFile('schema/types.ts', '');
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
37
|
const { schemaComposer } = require(path.resolve(
|
|
25
38
|
process.cwd(),
|
|
@@ -53,13 +66,10 @@ const argv: any = yargs(process.argv.slice(2)).argv;
|
|
|
53
66
|
},
|
|
54
67
|
};
|
|
55
68
|
|
|
56
|
-
/**
|
|
57
|
-
* Save to schema/schema.graphql. schema folder might not exist.
|
|
58
|
-
*/
|
|
59
|
-
await fs.promises.mkdir('schema', { recursive: true });
|
|
60
|
-
|
|
61
69
|
await fs.promises.writeFile('schema/schema.graphql', sdl);
|
|
62
70
|
|
|
71
|
+
log.info(logPrefix, 'Generating types...');
|
|
72
|
+
|
|
63
73
|
const typesOutput = await codegen(codegenConfig);
|
|
64
74
|
|
|
65
75
|
const typesOutputIgnore = ['/* eslint-disable */'].join('\n');
|