@ttoss/graphql-api 0.7.8 → 0.8.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/README.md +16 -27
- package/dist/esm/index.js +2 -3
- package/dist/{index.d.mts → index.d.cts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -13
- package/package.json +8 -16
- package/bin/cli.js +0 -2
- package/dist/cli.d.mts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -120
- package/dist/esm/chunk-NT3ZWSM6.js +0 -8
- package/dist/esm/cli.js +0 -95
- /package/dist/{shield.d.mts → shield.d.cts} +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# @ttoss/graphql-api
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package offers an opinionated approach to building a GraphQL API using the **ttoss ecosystem modules**. It is designed to provide a resilient and scalable solution for creating complex GraphQL APIs while focusing on the following goals:
|
|
4
4
|
|
|
5
|
-
1. **Modular**:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
1. **
|
|
9
|
-
|
|
5
|
+
1. **Modular Design**:
|
|
6
|
+
Build your GraphQL API using modules to simplify and organize the development of large, complex APIs.
|
|
7
|
+
|
|
8
|
+
1. **Relay Compatibility**:
|
|
9
|
+
As **Relay** is the primary GraphQL client in the ttoss ecosystem, this package implements the [Relay Server Specification](https://relay.dev/docs/guides/graphql-server-specification/) for seamless client-server interaction.
|
|
10
|
+
|
|
11
|
+
1. **Schema Building**:
|
|
12
|
+
Generate the GraphQL schema required for Relay's introspection queries with [@ttoss/graphql-api-cli](https://ttoss.dev/docs/modules/packages/graphql-api-cli/).
|
|
13
|
+
|
|
14
|
+
1. **TypeScript Types Generation**:
|
|
15
|
+
Automatically generate TypeScript types for your GraphQL schema with [@ttoss/graphql-api-cli](https://ttoss.dev/docs/modules/packages/graphql-api-cli/).
|
|
16
|
+
|
|
17
|
+
1. **AWS AppSync Support**:
|
|
18
|
+
Create GraphQL APIs compatible with AWS AppSync. Additionally, this package includes support for running a local GraphQL API server for development and testing purposes.
|
|
10
19
|
|
|
11
20
|
## Installation
|
|
12
21
|
|
|
@@ -429,27 +438,7 @@ import { allow, deny, shield } from '@ttoss/graphql-api/shield';
|
|
|
429
438
|
|
|
430
439
|
## Building Schema and Types
|
|
431
440
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
```bash
|
|
435
|
-
ttoss-graphl-api build-schema
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
You can add the `build-schema` script to your `package.json`:
|
|
439
|
-
|
|
440
|
-
```json
|
|
441
|
-
{
|
|
442
|
-
"scripts": {
|
|
443
|
-
"build-schema": "ttoss-graphl-api build-schema"
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
If your `schemaComposer` is in a different directory, you can pass the `--directory`/`-d` option to `ttoss-graphl-api build-schema` command:
|
|
449
|
-
|
|
450
|
-
```bash
|
|
451
|
-
ttoss-graphl-api build-schema -d tests
|
|
452
|
-
```
|
|
441
|
+
Check [@ttoss/graphql-api-cli](https://ttoss.dev/docs/modules/packages/graphql-api-cli/) for more information about how to build the schema and types.
|
|
453
442
|
|
|
454
443
|
## How to Create Tests
|
|
455
444
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import "./chunk-NT3ZWSM6.js";
|
|
3
2
|
|
|
4
3
|
// src/composeWithRelay/composeWithRelay.ts
|
|
5
4
|
import { ObjectTypeComposer } from "graphql-compose";
|
|
@@ -135,7 +134,7 @@ import { schemaComposer } from "graphql-compose";
|
|
|
135
134
|
composeWithRelay(schemaComposer.Query);
|
|
136
135
|
|
|
137
136
|
// src/index.ts
|
|
138
|
-
import {
|
|
137
|
+
import { composeWithConnection } from "graphql-compose-connection";
|
|
139
138
|
export * from "graphql-compose";
|
|
140
139
|
|
|
141
140
|
// src/buildSchema.ts
|
|
@@ -158,4 +157,4 @@ var buildSchema = ({
|
|
|
158
157
|
}
|
|
159
158
|
return schema;
|
|
160
159
|
};
|
|
161
|
-
export { buildSchema,
|
|
160
|
+
export { buildSchema, composeWithConnection, composeWithRelay };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
2
2
|
export * from 'graphql-compose';
|
|
3
|
-
export {
|
|
3
|
+
export { composeWithConnection } from 'graphql-compose-connection';
|
|
4
4
|
import { GraphQLSchema } from 'graphql';
|
|
5
5
|
import { IMiddleware, IMiddlewareGenerator } from 'graphql-middleware';
|
|
6
6
|
export { IMiddleware as Middleware } from 'graphql-middleware';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
2
2
|
export * from 'graphql-compose';
|
|
3
|
-
export {
|
|
3
|
+
export { composeWithConnection } from 'graphql-compose-connection';
|
|
4
4
|
import { GraphQLSchema } from 'graphql';
|
|
5
5
|
import { IMiddleware, IMiddlewareGenerator } from 'graphql-middleware';
|
|
6
6
|
export { IMiddleware as Middleware } from 'graphql-middleware';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __export = (target, all) => {
|
|
11
9
|
for (var name in all) __defProp(target, name, {
|
|
@@ -23,15 +21,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
21
|
return to;
|
|
24
22
|
};
|
|
25
23
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
32
|
-
value: mod,
|
|
33
|
-
enumerable: true
|
|
34
|
-
}) : target, mod));
|
|
35
24
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
36
25
|
value: true
|
|
37
26
|
}), mod);
|
|
@@ -40,7 +29,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
40
29
|
var src_exports = {};
|
|
41
30
|
__export(src_exports, {
|
|
42
31
|
buildSchema: () => buildSchema,
|
|
43
|
-
composeWithConnection: () => import_graphql_compose_connection.
|
|
32
|
+
composeWithConnection: () => import_graphql_compose_connection.composeWithConnection,
|
|
44
33
|
composeWithRelay: () => composeWithRelay
|
|
45
34
|
});
|
|
46
35
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -179,7 +168,7 @@ var import_graphql_compose4 = require("graphql-compose");
|
|
|
179
168
|
composeWithRelay(import_graphql_compose4.schemaComposer.Query);
|
|
180
169
|
|
|
181
170
|
// src/index.ts
|
|
182
|
-
var import_graphql_compose_connection =
|
|
171
|
+
var import_graphql_compose_connection = require("graphql-compose-connection");
|
|
183
172
|
__reExport(src_exports, require("graphql-compose"), module.exports);
|
|
184
173
|
|
|
185
174
|
// src/buildSchema.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/graphql-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A library for building GraphQL APIs using ttoss ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"url": "https://github.com/ttoss/ttoss.git",
|
|
13
13
|
"directory": "packages/graphql-api"
|
|
14
14
|
},
|
|
15
|
+
"type": "module",
|
|
15
16
|
"exports": {
|
|
16
17
|
".": {
|
|
17
18
|
"import": "./dist/esm/index.js",
|
|
@@ -24,35 +25,26 @@
|
|
|
24
25
|
"types": "./dist/shield.d.ts"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
|
-
"bin": {
|
|
28
|
-
"ttoss-graphql-api": "./bin/cli.js"
|
|
29
|
-
},
|
|
30
28
|
"files": [
|
|
31
29
|
"dist"
|
|
32
30
|
],
|
|
33
31
|
"sideEffects": false,
|
|
34
32
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"@graphql-codegen/typescript": "^4.0.6",
|
|
37
|
-
"graphql-compose": "^9.0.10",
|
|
33
|
+
"graphql-compose": "^9.0.11",
|
|
38
34
|
"graphql-compose-connection": "^8.2.1",
|
|
39
35
|
"graphql-middleware": "^6.1.35",
|
|
40
36
|
"graphql-shield": "^7.6.5",
|
|
41
37
|
"npmlog": "^7.0.1",
|
|
42
|
-
"
|
|
43
|
-
"tsconfig-paths": "^4.2.0",
|
|
44
|
-
"yargs": "^17.7.2",
|
|
45
|
-
"@ttoss/ids": "^0.2.14"
|
|
38
|
+
"@ttoss/ids": "^0.3.0"
|
|
46
39
|
},
|
|
47
40
|
"peerDependencies": {
|
|
48
41
|
"graphql": "^16.6.0"
|
|
49
42
|
},
|
|
50
43
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
"graphql": "^16.8.1",
|
|
44
|
+
"graphql": "^16.9.0",
|
|
53
45
|
"jest": "^29.7.0",
|
|
54
46
|
"tsup": "^8.3.5",
|
|
55
|
-
"@ttoss/config": "^1.
|
|
47
|
+
"@ttoss/config": "^1.35.0"
|
|
56
48
|
},
|
|
57
49
|
"keywords": [
|
|
58
50
|
"api",
|
|
@@ -63,7 +55,7 @@
|
|
|
63
55
|
"provenance": true
|
|
64
56
|
},
|
|
65
57
|
"scripts": {
|
|
66
|
-
"build
|
|
67
|
-
"test": "jest"
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"test": "jest --projects tests/unit"
|
|
68
60
|
}
|
|
69
61
|
}
|
package/bin/cli.js
DELETED
package/dist/cli.d.mts
DELETED
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: () => from[key],
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
-
value: mod,
|
|
26
|
-
enumerable: true
|
|
27
|
-
}) : target, mod));
|
|
28
|
-
|
|
29
|
-
// src/cli.ts
|
|
30
|
-
var fs = __toESM(require("fs"));
|
|
31
|
-
var path = __toESM(require("path"));
|
|
32
|
-
var typescriptPlugin = __toESM(require("@graphql-codegen/typescript"));
|
|
33
|
-
var import_core = require("@graphql-codegen/core");
|
|
34
|
-
var import_helpers = require("yargs/helpers");
|
|
35
|
-
var import_graphql = require("graphql");
|
|
36
|
-
var import_ts_node = require("ts-node");
|
|
37
|
-
var import_tsconfig_paths = require("tsconfig-paths");
|
|
38
|
-
var import_npmlog = __toESM(require("npmlog"));
|
|
39
|
-
var import_yargs = __toESM(require("yargs"));
|
|
40
|
-
var logPrefix = "graphql-api";
|
|
41
|
-
var tsConfig = require(path.resolve(process.cwd(), "tsconfig.json"));
|
|
42
|
-
var cleanup = () => {};
|
|
43
|
-
try {
|
|
44
|
-
const baseUrl = tsConfig?.compilerOptions?.baseUrl;
|
|
45
|
-
const paths = tsConfig?.compilerOptions?.paths;
|
|
46
|
-
if (baseUrl && !paths || !baseUrl && paths) {
|
|
47
|
-
throw new Error("tsconfig.json must have 'baseUrl' and 'paths' properties.");
|
|
48
|
-
}
|
|
49
|
-
if (baseUrl && paths) {
|
|
50
|
-
cleanup = (0, import_tsconfig_paths.register)({
|
|
51
|
-
baseUrl: tsConfig.compilerOptions.baseUrl,
|
|
52
|
-
paths: tsConfig.compilerOptions.paths
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
error instanceof Error && import_npmlog.default.error(logPrefix, error.message);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
(0, import_ts_node.register)({
|
|
60
|
-
transpileOnly: true,
|
|
61
|
-
compilerOptions: {
|
|
62
|
-
module: "NodeNext",
|
|
63
|
-
moduleResolution: "NodeNext"
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
var buildSchema = async ({
|
|
67
|
-
directory
|
|
68
|
-
}) => {
|
|
69
|
-
import_npmlog.default.info(logPrefix, "Building schema...");
|
|
70
|
-
await fs.promises.mkdir("schema", {
|
|
71
|
-
recursive: true
|
|
72
|
-
});
|
|
73
|
-
try {
|
|
74
|
-
await fs.promises.access("schema/types.ts");
|
|
75
|
-
} catch {
|
|
76
|
-
await fs.promises.writeFile("schema/types.ts", "");
|
|
77
|
-
}
|
|
78
|
-
const {
|
|
79
|
-
schemaComposer
|
|
80
|
-
} = require(path.resolve(process.cwd(), directory, "schemaComposer.ts"));
|
|
81
|
-
const sdl = schemaComposer.toSDL();
|
|
82
|
-
const codegenConfig = {
|
|
83
|
-
documents: [],
|
|
84
|
-
config: {
|
|
85
|
-
declarationKind: {
|
|
86
|
-
type: "interface",
|
|
87
|
-
interface: "interface"
|
|
88
|
-
},
|
|
89
|
-
namingConvention: "keep"
|
|
90
|
-
},
|
|
91
|
-
filename: "schema/types.ts",
|
|
92
|
-
schema: (0, import_graphql.parse)(sdl),
|
|
93
|
-
plugins: [{
|
|
94
|
-
typescript: {}
|
|
95
|
-
}],
|
|
96
|
-
pluginMap: {
|
|
97
|
-
typescript: typescriptPlugin
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
await fs.promises.writeFile("schema/schema.graphql", sdl);
|
|
101
|
-
import_npmlog.default.info(logPrefix, "Generating types...");
|
|
102
|
-
const typesOutput = await (0, import_core.codegen)(codegenConfig);
|
|
103
|
-
const typesOutputIgnore = ["/* eslint-disable */"].join("\n");
|
|
104
|
-
await fs.promises.writeFile("schema/types.ts", `${typesOutputIgnore}
|
|
105
|
-
${typesOutput}`);
|
|
106
|
-
cleanup();
|
|
107
|
-
import_npmlog.default.info(logPrefix, "Schema and types generated!");
|
|
108
|
-
};
|
|
109
|
-
(0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).command("build-schema", "fetch the contents of the URL", yargs2 => {
|
|
110
|
-
return yargs2.options({
|
|
111
|
-
directory: {
|
|
112
|
-
alias: ["d"],
|
|
113
|
-
type: "string",
|
|
114
|
-
describe: "Schema composer directory relative to the project root",
|
|
115
|
-
default: "src"
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}, argv => {
|
|
119
|
-
return buildSchema(argv);
|
|
120
|
-
}).demandCommand(1).strictOptions().parse();
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
var __require = /* @__PURE__ */(x => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function (x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
export { __require };
|
package/dist/esm/cli.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { __require } from "./chunk-NT3ZWSM6.js";
|
|
3
|
-
|
|
4
|
-
// src/cli.ts
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
8
|
-
import { codegen } from "@graphql-codegen/core";
|
|
9
|
-
import { hideBin } from "yargs/helpers";
|
|
10
|
-
import { parse } from "graphql";
|
|
11
|
-
import { register } from "ts-node";
|
|
12
|
-
import { register as registerTsPaths } from "tsconfig-paths";
|
|
13
|
-
import log from "npmlog";
|
|
14
|
-
import yargs from "yargs";
|
|
15
|
-
var logPrefix = "graphql-api";
|
|
16
|
-
var tsConfig = __require(path.resolve(process.cwd(), "tsconfig.json"));
|
|
17
|
-
var cleanup = () => {};
|
|
18
|
-
try {
|
|
19
|
-
const baseUrl = tsConfig?.compilerOptions?.baseUrl;
|
|
20
|
-
const paths = tsConfig?.compilerOptions?.paths;
|
|
21
|
-
if (baseUrl && !paths || !baseUrl && paths) {
|
|
22
|
-
throw new Error("tsconfig.json must have 'baseUrl' and 'paths' properties.");
|
|
23
|
-
}
|
|
24
|
-
if (baseUrl && paths) {
|
|
25
|
-
cleanup = registerTsPaths({
|
|
26
|
-
baseUrl: tsConfig.compilerOptions.baseUrl,
|
|
27
|
-
paths: tsConfig.compilerOptions.paths
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
error instanceof Error && log.error(logPrefix, error.message);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
register({
|
|
35
|
-
transpileOnly: true,
|
|
36
|
-
compilerOptions: {
|
|
37
|
-
module: "NodeNext",
|
|
38
|
-
moduleResolution: "NodeNext"
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
var buildSchema = async ({
|
|
42
|
-
directory
|
|
43
|
-
}) => {
|
|
44
|
-
log.info(logPrefix, "Building schema...");
|
|
45
|
-
await fs.promises.mkdir("schema", {
|
|
46
|
-
recursive: true
|
|
47
|
-
});
|
|
48
|
-
try {
|
|
49
|
-
await fs.promises.access("schema/types.ts");
|
|
50
|
-
} catch {
|
|
51
|
-
await fs.promises.writeFile("schema/types.ts", "");
|
|
52
|
-
}
|
|
53
|
-
const {
|
|
54
|
-
schemaComposer
|
|
55
|
-
} = __require(path.resolve(process.cwd(), directory, "schemaComposer.ts"));
|
|
56
|
-
const sdl = schemaComposer.toSDL();
|
|
57
|
-
const codegenConfig = {
|
|
58
|
-
documents: [],
|
|
59
|
-
config: {
|
|
60
|
-
declarationKind: {
|
|
61
|
-
type: "interface",
|
|
62
|
-
interface: "interface"
|
|
63
|
-
},
|
|
64
|
-
namingConvention: "keep"
|
|
65
|
-
},
|
|
66
|
-
filename: "schema/types.ts",
|
|
67
|
-
schema: parse(sdl),
|
|
68
|
-
plugins: [{
|
|
69
|
-
typescript: {}
|
|
70
|
-
}],
|
|
71
|
-
pluginMap: {
|
|
72
|
-
typescript: typescriptPlugin
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
await fs.promises.writeFile("schema/schema.graphql", sdl);
|
|
76
|
-
log.info(logPrefix, "Generating types...");
|
|
77
|
-
const typesOutput = await codegen(codegenConfig);
|
|
78
|
-
const typesOutputIgnore = ["/* eslint-disable */"].join("\n");
|
|
79
|
-
await fs.promises.writeFile("schema/types.ts", `${typesOutputIgnore}
|
|
80
|
-
${typesOutput}`);
|
|
81
|
-
cleanup();
|
|
82
|
-
log.info(logPrefix, "Schema and types generated!");
|
|
83
|
-
};
|
|
84
|
-
yargs(hideBin(process.argv)).command("build-schema", "fetch the contents of the URL", yargs2 => {
|
|
85
|
-
return yargs2.options({
|
|
86
|
-
directory: {
|
|
87
|
-
alias: ["d"],
|
|
88
|
-
type: "string",
|
|
89
|
-
describe: "Schema composer directory relative to the project root",
|
|
90
|
-
default: "src"
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}, argv => {
|
|
94
|
-
return buildSchema(argv);
|
|
95
|
-
}).demandCommand(1).strictOptions().parse();
|
|
File without changes
|