nitro-graphql 2.0.0-beta.31 → 2.0.0-beta.33
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/codegen/client-types.d.mts +13 -0
- package/dist/codegen/client-types.mjs +131 -0
- package/dist/codegen/external-types.d.mts +12 -0
- package/dist/codegen/external-types.mjs +88 -0
- package/dist/codegen/index.d.mts +18 -0
- package/dist/codegen/index.mjs +24 -0
- package/dist/codegen/server-types.d.mts +13 -0
- package/dist/codegen/server-types.mjs +64 -0
- package/dist/codegen/validation.d.mts +13 -0
- package/dist/codegen/validation.mjs +96 -0
- package/dist/config/defaults.mjs +36 -0
- package/dist/constants/scalars.mjs +27 -0
- package/dist/constants.mjs +106 -0
- package/dist/ecosystem/nuxt.mjs +3 -3
- package/dist/rollup.d.mts +2 -8
- package/dist/rollup.mjs +24 -199
- package/dist/routes/apollo-server.d.mts +2 -2
- package/dist/routes/apollo-server.mjs +7 -51
- package/dist/routes/debug-template.d.mts +15 -0
- package/dist/routes/debug-template.mjs +385 -0
- package/dist/routes/debug.d.mts +2 -2
- package/dist/routes/debug.mjs +1 -344
- package/dist/routes/graphql-yoga.d.mts +2 -2
- package/dist/routes/graphql-yoga.mjs +7 -51
- package/dist/routes/health.d.mts +2 -2
- package/dist/setup/file-watcher.mjs +84 -0
- package/dist/setup/graphql-scanner.mjs +25 -0
- package/dist/setup/rollup-integration.mjs +90 -0
- package/dist/setup/scaffold-generator.mjs +109 -0
- package/dist/setup/ts-config.mjs +69 -0
- package/dist/setup.d.mts +2 -2
- package/dist/setup.mjs +147 -303
- package/dist/types/index.d.mts +2 -2
- package/dist/utils/client-codegen.d.mts +1 -1
- package/dist/utils/client-codegen.mjs +5 -28
- package/dist/utils/codegen-plugin.d.mts +20 -0
- package/dist/utils/codegen-plugin.mjs +30 -0
- package/dist/utils/directive-parser.d.mts +2 -1
- package/dist/utils/directive-parser.mjs +4 -2
- package/dist/utils/federation.d.mts +29 -0
- package/dist/utils/federation.mjs +40 -0
- package/dist/utils/file-generator.mjs +1 -1
- package/dist/utils/file-writer.d.mts +35 -0
- package/dist/utils/file-writer.mjs +32 -0
- package/dist/utils/imports.d.mts +15 -0
- package/dist/utils/imports.mjs +25 -0
- package/dist/utils/index.d.mts +11 -38
- package/dist/utils/index.mjs +10 -287
- package/dist/utils/layers.d.mts +22 -0
- package/dist/utils/layers.mjs +28 -0
- package/dist/utils/ofetch-templates.d.mts +30 -0
- package/dist/utils/ofetch-templates.mjs +135 -0
- package/dist/utils/path-resolver.d.mts +2 -2
- package/dist/utils/path-resolver.mjs +2 -2
- package/dist/utils/scanning/common.d.mts +23 -0
- package/dist/utils/scanning/common.mjs +39 -0
- package/dist/utils/scanning/directives.d.mts +11 -0
- package/dist/utils/scanning/directives.mjs +43 -0
- package/dist/utils/scanning/documents.d.mts +15 -0
- package/dist/utils/scanning/documents.mjs +46 -0
- package/dist/utils/scanning/index.d.mts +6 -0
- package/dist/utils/scanning/index.mjs +7 -0
- package/dist/utils/scanning/resolvers.d.mts +11 -0
- package/dist/utils/scanning/resolvers.mjs +100 -0
- package/dist/utils/scanning/schemas.d.mts +15 -0
- package/dist/utils/scanning/schemas.mjs +29 -0
- package/dist/utils/schema-builder.d.mts +48 -0
- package/dist/utils/schema-builder.mjs +51 -0
- package/dist/utils/server-codegen.mjs +4 -27
- package/dist/utils/type-generation.d.mts +6 -12
- package/dist/utils/type-generation.mjs +6 -419
- package/dist/utils/validation.d.mts +11 -0
- package/dist/utils/validation.mjs +34 -0
- package/dist/virtual/generators/config.d.mts +22 -0
- package/dist/virtual/generators/config.mjs +36 -0
- package/dist/virtual/generators/debug.d.mts +14 -0
- package/dist/virtual/generators/debug.mjs +53 -0
- package/dist/virtual/generators/directives.d.mts +14 -0
- package/dist/virtual/generators/directives.mjs +52 -0
- package/dist/virtual/generators/index.d.mts +6 -0
- package/dist/virtual/generators/index.mjs +7 -0
- package/dist/virtual/generators/resolvers.d.mts +14 -0
- package/dist/virtual/generators/resolvers.mjs +55 -0
- package/dist/virtual/generators/schemas.d.mts +14 -0
- package/dist/virtual/generators/schemas.mjs +43 -0
- package/package.json +75 -57
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Nitro } from "nitro/types";
|
|
2
|
+
|
|
3
|
+
//#region src/codegen/client-types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate main client types (for the default service)
|
|
7
|
+
*/
|
|
8
|
+
declare function generateMainClientTypes(nitro: Nitro, options?: {
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
isInitial?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { generateMainClientTypes };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { FILE_INDEX_TS, LOG_TAG, SERVICE_DEFAULT } from "../constants.mjs";
|
|
2
|
+
import { generateClientTypes, loadGraphQLDocuments } from "../utils/client-codegen.mjs";
|
|
3
|
+
import { loadFederationSupport } from "../utils/federation.mjs";
|
|
4
|
+
import { writeFileIfNotExists } from "../utils/file-generator.mjs";
|
|
5
|
+
import { generateOfetchTemplate } from "../utils/ofetch-templates.mjs";
|
|
6
|
+
import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils } from "../utils/path-resolver.mjs";
|
|
7
|
+
import consola from "consola";
|
|
8
|
+
import { dirname, join, resolve } from "pathe";
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { buildSchema, parse } from "graphql";
|
|
11
|
+
|
|
12
|
+
//#region src/codegen/client-types.ts
|
|
13
|
+
const logger = consola.withTag(LOG_TAG);
|
|
14
|
+
/**
|
|
15
|
+
* Check for old structure files and warn user about manual migration
|
|
16
|
+
*/
|
|
17
|
+
function warnLegacyGraphQLStructure(clientDir) {
|
|
18
|
+
const oldOfetchPath = resolve(clientDir, "ofetch.ts");
|
|
19
|
+
const oldSdkPath = resolve(clientDir, "sdk.ts");
|
|
20
|
+
if (existsSync(oldOfetchPath) || existsSync(oldSdkPath)) {
|
|
21
|
+
const foundFiles = [];
|
|
22
|
+
if (existsSync(oldOfetchPath)) foundFiles.push("app/graphql/ofetch.ts");
|
|
23
|
+
if (existsSync(oldSdkPath)) foundFiles.push("app/graphql/sdk.ts");
|
|
24
|
+
consola.error(`⚠️ OLD GRAPHQL STRUCTURE DETECTED!
|
|
25
|
+
|
|
26
|
+
📁 Found old files in app/graphql/ directory that need to be moved:
|
|
27
|
+
• ${foundFiles.join("\n • ")}
|
|
28
|
+
|
|
29
|
+
🔄 Please manually move these files to the new structure:
|
|
30
|
+
• app/graphql/ofetch.ts → app/graphql/default/ofetch.ts
|
|
31
|
+
• app/graphql/sdk.ts → app/graphql/default/sdk.ts
|
|
32
|
+
|
|
33
|
+
📝 Also update your app/graphql/index.ts to include:
|
|
34
|
+
export * from './default/ofetch'
|
|
35
|
+
|
|
36
|
+
💡 After moving, update your imports to use:
|
|
37
|
+
import { $sdk } from "#graphql/client"
|
|
38
|
+
|
|
39
|
+
🚫 The old files will cause import conflicts until moved!`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate main client types (for the default service)
|
|
44
|
+
*/
|
|
45
|
+
async function generateMainClientTypes(nitro, options = {}) {
|
|
46
|
+
warnLegacyGraphQLStructure(nitro.graphql.clientDir);
|
|
47
|
+
const docs = nitro.scanDocuments;
|
|
48
|
+
const loadedDocs = await loadGraphQLDocuments(docs);
|
|
49
|
+
const schemaFilePath = join(nitro.graphql.buildDir, "schema.graphql");
|
|
50
|
+
if (!existsSync(schemaFilePath)) {
|
|
51
|
+
if (!options.silent) consola.info("Schema file not ready yet for client type generation. Server types need to be generated first.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const graphqlString = readFileSync(schemaFilePath, "utf-8");
|
|
55
|
+
const federationEnabled = nitro.options.graphql?.federation?.enabled === true;
|
|
56
|
+
let schema;
|
|
57
|
+
if (federationEnabled) {
|
|
58
|
+
const buildSubgraph = await loadFederationSupport();
|
|
59
|
+
if (!buildSubgraph) throw new Error("Federation is enabled but @apollo/subgraph is not installed. Run: pnpm add @apollo/subgraph");
|
|
60
|
+
schema = buildSubgraph([{ typeDefs: parse(graphqlString) }]);
|
|
61
|
+
} else schema = buildSchema(graphqlString);
|
|
62
|
+
const types = await generateClientTypes(schema, loadedDocs, nitro.options.graphql?.codegen?.client ?? {}, nitro.options.graphql?.codegen?.clientSDK ?? {}, void 0, void 0, void 0, options);
|
|
63
|
+
if (types === false) return;
|
|
64
|
+
const placeholders = getDefaultPaths(nitro);
|
|
65
|
+
const typesConfig = getTypesConfig(nitro);
|
|
66
|
+
const sdkConfig = getSdkConfig(nitro);
|
|
67
|
+
const clientTypesPath = resolveFilePath(typesConfig.client, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client.d.ts", placeholders);
|
|
68
|
+
if (clientTypesPath) {
|
|
69
|
+
mkdirSync(dirname(clientTypesPath), { recursive: true });
|
|
70
|
+
writeFileSync(clientTypesPath, types.types, "utf-8");
|
|
71
|
+
if (!options.silent) logger.success(`Generated client types at: ${clientTypesPath}`);
|
|
72
|
+
}
|
|
73
|
+
const sdkPath = resolveFilePath(sdkConfig.main, sdkConfig.enabled, true, "{clientGraphql}/default/sdk.ts", placeholders);
|
|
74
|
+
if (sdkPath) {
|
|
75
|
+
mkdirSync(dirname(sdkPath), { recursive: true });
|
|
76
|
+
writeFileSync(sdkPath, types.sdk, "utf-8");
|
|
77
|
+
if (!options.silent) logger.success(`Generated SDK at: ${sdkPath}`);
|
|
78
|
+
}
|
|
79
|
+
generateNuxtOfetchClient(nitro, nitro.graphql.clientDir, SERVICE_DEFAULT);
|
|
80
|
+
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
81
|
+
if (externalServices.length > 0) generateGraphQLIndexFile(nitro, nitro.graphql.clientDir, externalServices);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Generate GraphQL index file that exports all services
|
|
85
|
+
*/
|
|
86
|
+
function generateGraphQLIndexFile(nitro, clientDir, externalServices = []) {
|
|
87
|
+
if (!shouldGenerateClientUtils(nitro)) return;
|
|
88
|
+
const placeholders = getDefaultPaths(nitro);
|
|
89
|
+
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
90
|
+
const indexPath = resolveFilePath(clientUtilsConfig.index, clientUtilsConfig.enabled, true, `{clientGraphql}/${FILE_INDEX_TS}`, placeholders);
|
|
91
|
+
if (!indexPath) return;
|
|
92
|
+
if (!existsSync(indexPath)) {
|
|
93
|
+
let indexContent = `// This file is auto-generated once by nitro-graphql for quick start
|
|
94
|
+
// You can modify this file according to your needs
|
|
95
|
+
//
|
|
96
|
+
// Export your main GraphQL service (auto-generated)
|
|
97
|
+
export * from './default/ofetch'
|
|
98
|
+
|
|
99
|
+
// Export external GraphQL services (auto-generated for existing services)
|
|
100
|
+
// When you add new external services, don't forget to add their exports here:
|
|
101
|
+
// export * from './yourServiceName/ofetch'
|
|
102
|
+
`;
|
|
103
|
+
for (const service of externalServices) indexContent += `export * from './${service.name}/ofetch'\n`;
|
|
104
|
+
writeFileIfNotExists(indexPath, indexContent, `client ${FILE_INDEX_TS}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Generate ofetch client wrapper for Nuxt/Nitro
|
|
109
|
+
*/
|
|
110
|
+
function generateNuxtOfetchClient(nitro, clientDir, serviceName = SERVICE_DEFAULT) {
|
|
111
|
+
if (!shouldGenerateClientUtils(nitro)) return;
|
|
112
|
+
const placeholders = {
|
|
113
|
+
...getDefaultPaths(nitro),
|
|
114
|
+
serviceName
|
|
115
|
+
};
|
|
116
|
+
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
117
|
+
const ofetchPath = resolveFilePath(clientUtilsConfig.ofetch, clientUtilsConfig.enabled, true, "{clientGraphql}/{serviceName}/ofetch.ts", placeholders);
|
|
118
|
+
if (!ofetchPath) return;
|
|
119
|
+
const serviceDir = dirname(ofetchPath);
|
|
120
|
+
if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
|
|
121
|
+
if (existsSync(ofetchPath)) return;
|
|
122
|
+
writeFileIfNotExists(ofetchPath, generateOfetchTemplate({
|
|
123
|
+
serviceName,
|
|
124
|
+
isNuxt: nitro.options.framework?.name === "nuxt",
|
|
125
|
+
endpoint: "/api/graphql",
|
|
126
|
+
isExternal: false
|
|
127
|
+
}), `${serviceName} ofetch.ts`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { generateMainClientTypes };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Nitro } from "nitro/types";
|
|
2
|
+
|
|
3
|
+
//#region src/codegen/external-types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate types for all external GraphQL services
|
|
7
|
+
*/
|
|
8
|
+
declare function generateExternalServicesTypes(nitro: Nitro, options?: {
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { generateExternalServicesTypes };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { downloadAndSaveSchema, generateExternalClientTypes, loadExternalSchema, loadGraphQLDocuments } from "../utils/client-codegen.mjs";
|
|
2
|
+
import { writeFileIfNotExists } from "../utils/file-generator.mjs";
|
|
3
|
+
import { generateOfetchTemplate } from "../utils/ofetch-templates.mjs";
|
|
4
|
+
import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils } from "../utils/path-resolver.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { dirname } from "pathe";
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
|
|
9
|
+
//#region src/codegen/external-types.ts
|
|
10
|
+
/**
|
|
11
|
+
* Generate types for all external GraphQL services
|
|
12
|
+
*/
|
|
13
|
+
async function generateExternalServicesTypes(nitro, options = {}) {
|
|
14
|
+
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
15
|
+
for (const service of externalServices) try {
|
|
16
|
+
if (!options.silent) consola.info(`[graphql:${service.name}] Processing external service`);
|
|
17
|
+
await downloadAndSaveSchema(service, nitro.options.buildDir);
|
|
18
|
+
const schema = await loadExternalSchema(service, nitro.options.buildDir);
|
|
19
|
+
if (!schema) {
|
|
20
|
+
consola.warn(`[graphql:${service.name}] Failed to load schema, skipping`);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const documentPatterns = service.documents || [];
|
|
24
|
+
let loadedDocs = [];
|
|
25
|
+
if (documentPatterns.length > 0) try {
|
|
26
|
+
loadedDocs = await loadGraphQLDocuments(documentPatterns);
|
|
27
|
+
if (!loadedDocs || loadedDocs.length === 0) {
|
|
28
|
+
consola.warn(`[graphql:${service.name}] No GraphQL documents found, skipping service generation`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
consola.warn(`[graphql:${service.name}] No documents found, skipping service generation:`, error);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const types = await generateExternalClientTypes(service, schema, loadedDocs);
|
|
36
|
+
if (types === false) {
|
|
37
|
+
consola.warn(`[graphql:${service.name}] Type generation failed`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const placeholders = {
|
|
41
|
+
...getDefaultPaths(nitro),
|
|
42
|
+
serviceName: service.name
|
|
43
|
+
};
|
|
44
|
+
const typesConfig = getTypesConfig(nitro);
|
|
45
|
+
const sdkConfig = getSdkConfig(nitro);
|
|
46
|
+
const serviceTypesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", placeholders);
|
|
47
|
+
if (serviceTypesPath) {
|
|
48
|
+
mkdirSync(dirname(serviceTypesPath), { recursive: true });
|
|
49
|
+
writeFileSync(serviceTypesPath, types.types, "utf-8");
|
|
50
|
+
if (!options.silent) consola.success(`[graphql:${service.name}] Generated types at: ${serviceTypesPath}`);
|
|
51
|
+
}
|
|
52
|
+
const serviceSdkPath = resolveFilePath(service.paths?.sdk ?? sdkConfig.external, sdkConfig.enabled, true, "{clientGraphql}/{serviceName}/sdk.ts", placeholders);
|
|
53
|
+
if (serviceSdkPath) {
|
|
54
|
+
mkdirSync(dirname(serviceSdkPath), { recursive: true });
|
|
55
|
+
writeFileSync(serviceSdkPath, types.sdk, "utf-8");
|
|
56
|
+
if (!options.silent) consola.success(`[graphql:${service.name}] Generated SDK at: ${serviceSdkPath}`);
|
|
57
|
+
}
|
|
58
|
+
generateExternalOfetchClient(nitro, service, service.endpoint);
|
|
59
|
+
if (!options.silent) consola.success(`[graphql:${service.name}] External service types generated successfully`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
consola.error(`[graphql:${service.name}] External service generation failed:`, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate ofetch client for external service
|
|
66
|
+
*/
|
|
67
|
+
function generateExternalOfetchClient(nitro, service, endpoint) {
|
|
68
|
+
if (!shouldGenerateClientUtils(nitro)) return;
|
|
69
|
+
const serviceName = service.name;
|
|
70
|
+
const placeholders = {
|
|
71
|
+
...getDefaultPaths(nitro),
|
|
72
|
+
serviceName
|
|
73
|
+
};
|
|
74
|
+
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
75
|
+
const ofetchPath = resolveFilePath(service.paths?.ofetch ?? clientUtilsConfig.ofetch, clientUtilsConfig.enabled, true, "{clientGraphql}/{serviceName}/ofetch.ts", placeholders);
|
|
76
|
+
if (!ofetchPath) return;
|
|
77
|
+
const serviceDir = dirname(ofetchPath);
|
|
78
|
+
if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
|
|
79
|
+
if (!existsSync(ofetchPath)) writeFileIfNotExists(ofetchPath, generateOfetchTemplate({
|
|
80
|
+
serviceName,
|
|
81
|
+
isNuxt: nitro.options.framework?.name === "nuxt",
|
|
82
|
+
endpoint,
|
|
83
|
+
isExternal: true
|
|
84
|
+
}), `${serviceName} external ofetch.ts`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { generateExternalServicesTypes };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { generateMainClientTypes } from "./client-types.mjs";
|
|
2
|
+
import { generateExternalServicesTypes } from "./external-types.mjs";
|
|
3
|
+
import { generateServerTypes } from "./server-types.mjs";
|
|
4
|
+
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
5
|
+
import { Nitro } from "nitro/types";
|
|
6
|
+
|
|
7
|
+
//#region src/codegen/index.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generate client-side GraphQL types
|
|
11
|
+
* Generates types for both main service and external services
|
|
12
|
+
*/
|
|
13
|
+
declare function generateClientTypes(nitro: Nitro, options?: {
|
|
14
|
+
silent?: boolean;
|
|
15
|
+
isInitial?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { generateClientTypes };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LOG_TAG } from "../constants.mjs";
|
|
2
|
+
import { generateMainClientTypes } from "./client-types.mjs";
|
|
3
|
+
import { generateExternalServicesTypes } from "./external-types.mjs";
|
|
4
|
+
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
5
|
+
import { generateServerTypes } from "./server-types.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
|
|
8
|
+
//#region src/codegen/index.ts
|
|
9
|
+
const logger = consola.withTag(LOG_TAG);
|
|
10
|
+
/**
|
|
11
|
+
* Generate client-side GraphQL types
|
|
12
|
+
* Generates types for both main service and external services
|
|
13
|
+
*/
|
|
14
|
+
async function generateClientTypes(nitro, options = {}) {
|
|
15
|
+
try {
|
|
16
|
+
if (nitro.scanSchemas && nitro.scanSchemas.length > 0) await generateMainClientTypes(nitro, options);
|
|
17
|
+
if (nitro.options.graphql?.externalServices?.length) await generateExternalServicesTypes(nitro, options);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
logger.error("Client schema generation error:", error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { generateClientTypes };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Nitro } from "nitro/types";
|
|
2
|
+
|
|
3
|
+
//#region src/codegen/server-types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate server-side GraphQL types
|
|
7
|
+
* Creates resolver types from GraphQL schemas
|
|
8
|
+
*/
|
|
9
|
+
declare function generateServerTypes(nitro: Nitro, options?: {
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { generateServerTypes };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LOG_TAG } from "../constants.mjs";
|
|
2
|
+
import { loadFederationSupport } from "../utils/federation.mjs";
|
|
3
|
+
import { getDefaultPaths, getTypesConfig, resolveFilePath, shouldGenerateTypes } from "../utils/path-resolver.mjs";
|
|
4
|
+
import { generateTypes } from "../utils/server-codegen.mjs";
|
|
5
|
+
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import { dirname, resolve } from "pathe";
|
|
8
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { buildSchema, parse } from "graphql";
|
|
10
|
+
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
11
|
+
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
12
|
+
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
13
|
+
|
|
14
|
+
//#region src/codegen/server-types.ts
|
|
15
|
+
const logger = consola.withTag(LOG_TAG);
|
|
16
|
+
/**
|
|
17
|
+
* Generate server-side GraphQL types
|
|
18
|
+
* Creates resolver types from GraphQL schemas
|
|
19
|
+
*/
|
|
20
|
+
async function generateServerTypes(nitro, options = {}) {
|
|
21
|
+
try {
|
|
22
|
+
if (!shouldGenerateTypes(nitro)) {
|
|
23
|
+
logger.debug("Server type generation is disabled");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const schemas = nitro.scanSchemas || [];
|
|
27
|
+
if (!schemas.length) {
|
|
28
|
+
if (!options.silent) consola.info("No GraphQL definitions found for server type generation.");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const schemaStrings = loadFilesSync(schemas).map((schema$1) => typeof schema$1 === "string" ? schema$1 : schema$1.loc?.source?.body || "").filter(Boolean);
|
|
32
|
+
if (!validateNoDuplicateTypes(schemas, schemaStrings)) return;
|
|
33
|
+
const federationEnabled = nitro.options.graphql?.federation?.enabled === true;
|
|
34
|
+
const mergedSchemas = mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
35
|
+
throwOnConflict: true,
|
|
36
|
+
commentDescriptions: true,
|
|
37
|
+
sort: true
|
|
38
|
+
});
|
|
39
|
+
let schema;
|
|
40
|
+
if (federationEnabled) {
|
|
41
|
+
const buildSubgraph = await loadFederationSupport();
|
|
42
|
+
if (!buildSubgraph) throw new Error("Federation is enabled but @apollo/subgraph is not installed. Run: pnpm add @apollo/subgraph");
|
|
43
|
+
schema = buildSubgraph([{ typeDefs: parse(mergedSchemas) }]);
|
|
44
|
+
} else schema = buildSchema(mergedSchemas);
|
|
45
|
+
const data = await generateTypes(nitro.options.graphql?.framework || "graphql-yoga", schema, nitro.options.graphql ?? {});
|
|
46
|
+
const printSchema = printSchemaWithDirectives(schema);
|
|
47
|
+
const schemaPath = resolve(nitro.graphql.buildDir, "schema.graphql");
|
|
48
|
+
mkdirSync(dirname(schemaPath), { recursive: true });
|
|
49
|
+
writeFileSync(schemaPath, printSchema, "utf-8");
|
|
50
|
+
const placeholders = getDefaultPaths(nitro);
|
|
51
|
+
const typesConfig = getTypesConfig(nitro);
|
|
52
|
+
const serverTypesPath = resolveFilePath(typesConfig.server, typesConfig.enabled, true, "{typesDir}/nitro-graphql-server.d.ts", placeholders);
|
|
53
|
+
if (serverTypesPath) {
|
|
54
|
+
mkdirSync(dirname(serverTypesPath), { recursive: true });
|
|
55
|
+
writeFileSync(serverTypesPath, data, "utf-8");
|
|
56
|
+
if (!options.silent) logger.success(`Generated server types at: ${serverTypesPath}`);
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error("Server schema generation error:", error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { generateServerTypes };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/codegen/validation.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* GraphQL schema validation utilities
|
|
4
|
+
* Validates schemas for duplicate type definitions and conflicts
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check for duplicate type definitions using a simpler approach
|
|
8
|
+
* Try to build each schema individually - if that succeeds but merging fails, we have duplicates
|
|
9
|
+
* @returns true if validation passes, false if duplicates found
|
|
10
|
+
*/
|
|
11
|
+
declare function validateNoDuplicateTypes(schemas: string[], schemaStrings: string[]): boolean;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { validateNoDuplicateTypes };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BUILTIN_SCALARS } from "../constants.mjs";
|
|
2
|
+
import consola from "consola";
|
|
3
|
+
import { basename } from "pathe";
|
|
4
|
+
import { parse } from "graphql";
|
|
5
|
+
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
6
|
+
|
|
7
|
+
//#region src/codegen/validation.ts
|
|
8
|
+
/**
|
|
9
|
+
* GraphQL schema validation utilities
|
|
10
|
+
* Validates schemas for duplicate type definitions and conflicts
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Check for duplicate type definitions using a simpler approach
|
|
14
|
+
* Try to build each schema individually - if that succeeds but merging fails, we have duplicates
|
|
15
|
+
* @returns true if validation passes, false if duplicates found
|
|
16
|
+
*/
|
|
17
|
+
function validateNoDuplicateTypes(schemas, schemaStrings) {
|
|
18
|
+
const individualSchemasByFile = /* @__PURE__ */ new Map();
|
|
19
|
+
schemaStrings.forEach((schemaContent, index) => {
|
|
20
|
+
const schemaPath = schemas[index];
|
|
21
|
+
const fileName = basename(schemaPath);
|
|
22
|
+
try {
|
|
23
|
+
parse(schemaContent);
|
|
24
|
+
individualSchemasByFile.set(fileName, schemaContent);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
consola.warn(`Invalid GraphQL syntax in ${fileName}:`, error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
32
|
+
throwOnConflict: false,
|
|
33
|
+
commentDescriptions: true,
|
|
34
|
+
sort: true
|
|
35
|
+
});
|
|
36
|
+
mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
37
|
+
throwOnConflict: true,
|
|
38
|
+
commentDescriptions: true,
|
|
39
|
+
sort: true
|
|
40
|
+
});
|
|
41
|
+
} catch (conflictError) {
|
|
42
|
+
if (conflictError?.message?.includes("already defined with a different type")) throw conflictError;
|
|
43
|
+
}
|
|
44
|
+
const typeNames = /* @__PURE__ */ new Set();
|
|
45
|
+
const duplicateTypes = [];
|
|
46
|
+
schemaStrings.forEach((schemaContent, index) => {
|
|
47
|
+
const fileName = basename(schemas[index]);
|
|
48
|
+
try {
|
|
49
|
+
parse(schemaContent).definitions.forEach((def) => {
|
|
50
|
+
if (def.kind === "ObjectTypeDefinition" || def.kind === "InterfaceTypeDefinition" || def.kind === "UnionTypeDefinition" || def.kind === "EnumTypeDefinition" || def.kind === "InputObjectTypeDefinition" || def.kind === "ScalarTypeDefinition") {
|
|
51
|
+
const typeName = def.name.value;
|
|
52
|
+
if (BUILTIN_SCALARS.includes(typeName)) return;
|
|
53
|
+
if (typeNames.has(typeName)) {
|
|
54
|
+
const existing = duplicateTypes.find((d) => d.type === typeName);
|
|
55
|
+
if (existing) existing.files.push(fileName);
|
|
56
|
+
else {
|
|
57
|
+
const firstFile = schemas.find((_, i) => {
|
|
58
|
+
const content = schemaStrings[i];
|
|
59
|
+
if (!content) return false;
|
|
60
|
+
try {
|
|
61
|
+
return parse(content).definitions.some((d) => (d.kind === "ObjectTypeDefinition" || d.kind === "InterfaceTypeDefinition" || d.kind === "UnionTypeDefinition" || d.kind === "EnumTypeDefinition" || d.kind === "InputObjectTypeDefinition" || d.kind === "ScalarTypeDefinition") && d.name.value === typeName);
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
duplicateTypes.push({
|
|
67
|
+
type: typeName,
|
|
68
|
+
files: [basename(firstFile || ""), fileName]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} else typeNames.add(typeName);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
} catch {}
|
|
75
|
+
});
|
|
76
|
+
if (duplicateTypes.length > 0) {
|
|
77
|
+
let errorMessage = "⚠️ DUPLICATE TYPE DEFINITIONS DETECTED!\n\n";
|
|
78
|
+
duplicateTypes.forEach(({ type, files }) => {
|
|
79
|
+
errorMessage += `❌ Type "${type}" is defined in multiple files:\n`;
|
|
80
|
+
files.forEach((fileName) => {
|
|
81
|
+
const fullPath = schemas.find((path) => basename(path) === fileName) || fileName;
|
|
82
|
+
errorMessage += ` • ${fullPath}\n`;
|
|
83
|
+
});
|
|
84
|
+
errorMessage += "\n";
|
|
85
|
+
});
|
|
86
|
+
errorMessage += "💡 Each GraphQL type should only be defined once.\n";
|
|
87
|
+
errorMessage += " Consider using \"extend type\" syntax instead of duplicate definitions.\n";
|
|
88
|
+
errorMessage += `\n🔍 Found ${duplicateTypes.length} duplicate type(s): ${duplicateTypes.map((d) => d.type).join(", ")}`;
|
|
89
|
+
consola.error(errorMessage);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { validateNoDuplicateTypes };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DEFAULT_CLIENT_TYPES_PATH, DEFAULT_SERVER_TYPES_PATH, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH } from "../constants.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/config/defaults.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default type generation configuration
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_TYPES_CONFIG = {
|
|
8
|
+
server: DEFAULT_SERVER_TYPES_PATH,
|
|
9
|
+
client: DEFAULT_CLIENT_TYPES_PATH,
|
|
10
|
+
enabled: true
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Default runtime GraphQL configuration
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_RUNTIME_CONFIG = {
|
|
16
|
+
endpoint: {
|
|
17
|
+
graphql: ENDPOINT_GRAPHQL,
|
|
18
|
+
healthCheck: ENDPOINT_HEALTH
|
|
19
|
+
},
|
|
20
|
+
playground: true
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Default TypeScript strict mode setting
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_TYPESCRIPT_STRICT = true;
|
|
26
|
+
/**
|
|
27
|
+
* Default watcher persistence setting
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_WATCHER_PERSISTENT = true;
|
|
30
|
+
/**
|
|
31
|
+
* Default watcher ignore initial setting
|
|
32
|
+
*/
|
|
33
|
+
const DEFAULT_WATCHER_IGNORE_INITIAL = true;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DEFAULT_RUNTIME_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG, DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CurrencyResolver, DateTimeISOResolver, DateTimeResolver, JSONObjectResolver, JSONResolver, NonEmptyStringResolver, UUIDResolver } from "graphql-scalars";
|
|
2
|
+
|
|
3
|
+
//#region src/constants/scalars.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default GraphQL scalar type definitions
|
|
6
|
+
* Used by both server and client codegen
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default scalar type mappings for GraphQL codegen
|
|
10
|
+
* These scalars are commonly used and have proper TypeScript type mappings
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_GRAPHQL_SCALARS = {
|
|
13
|
+
DateTime: DateTimeResolver.extensions.codegenScalarType,
|
|
14
|
+
DateTimeISO: DateTimeISOResolver.extensions.codegenScalarType,
|
|
15
|
+
UUID: UUIDResolver.extensions.codegenScalarType,
|
|
16
|
+
JSON: JSONResolver.extensions.codegenScalarType,
|
|
17
|
+
JSONObject: JSONObjectResolver.extensions.codegenScalarType,
|
|
18
|
+
NonEmptyString: NonEmptyStringResolver.extensions.codegenScalarType,
|
|
19
|
+
Currency: CurrencyResolver.extensions.codegenScalarType,
|
|
20
|
+
File: {
|
|
21
|
+
input: "File",
|
|
22
|
+
output: "File"
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DEFAULT_GRAPHQL_SCALARS };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Constants and magic strings used throughout nitro-graphql
|
|
4
|
+
* Centralizing these values prevents typos and makes refactoring easier
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* GraphQL schema file extensions
|
|
8
|
+
*/
|
|
9
|
+
const GRAPHQL_EXTENSIONS = [".graphql", ".gql"];
|
|
10
|
+
/**
|
|
11
|
+
* Resolver file extensions
|
|
12
|
+
*/
|
|
13
|
+
const RESOLVER_EXTENSIONS = [".resolver.ts", ".resolver.js"];
|
|
14
|
+
/**
|
|
15
|
+
* Directive file extensions
|
|
16
|
+
*/
|
|
17
|
+
const DIRECTIVE_EXTENSIONS = [".directive.ts", ".directive.js"];
|
|
18
|
+
/**
|
|
19
|
+
* Combined pattern for glob scanning
|
|
20
|
+
*/
|
|
21
|
+
const GLOB_SCAN_PATTERN = "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
22
|
+
/**
|
|
23
|
+
* Framework names
|
|
24
|
+
*/
|
|
25
|
+
const FRAMEWORK_NUXT = "nuxt";
|
|
26
|
+
const FRAMEWORK_NITRO = "nitro";
|
|
27
|
+
/**
|
|
28
|
+
* Default directory names for GraphQL files
|
|
29
|
+
*/
|
|
30
|
+
const DIR_SERVER_GRAPHQL = "server/graphql";
|
|
31
|
+
/**
|
|
32
|
+
* Windows-compatible server GraphQL directory
|
|
33
|
+
*/
|
|
34
|
+
const DIR_SERVER_GRAPHQL_WIN = "server\\graphql";
|
|
35
|
+
/**
|
|
36
|
+
* Default GraphQL endpoint paths
|
|
37
|
+
*/
|
|
38
|
+
const ENDPOINT_GRAPHQL = "/api/graphql";
|
|
39
|
+
const ENDPOINT_HEALTH = "/api/graphql/health";
|
|
40
|
+
const ENDPOINT_DEBUG = "/_nitro/graphql/debug";
|
|
41
|
+
/**
|
|
42
|
+
* Configuration and scaffold file names
|
|
43
|
+
*/
|
|
44
|
+
const FILE_GRAPHQL_CONFIG = "graphql.config.ts";
|
|
45
|
+
const FILE_SCHEMA_TS = "schema.ts";
|
|
46
|
+
const FILE_CONFIG_TS = "config.ts";
|
|
47
|
+
const FILE_CONTEXT_DTS = "context.d.ts";
|
|
48
|
+
const FILE_CONTEXT_TS = "context.ts";
|
|
49
|
+
const FILE_INDEX_TS = "index.ts";
|
|
50
|
+
/**
|
|
51
|
+
* Rollup/Rolldown chunk output paths
|
|
52
|
+
*/
|
|
53
|
+
const CHUNK_PATH_GRAPHQL = "chunks/graphql/[name].mjs";
|
|
54
|
+
const CHUNK_PATH_UNKNOWN = "chunks/_/[name].mjs";
|
|
55
|
+
/**
|
|
56
|
+
* Default chunk names
|
|
57
|
+
*/
|
|
58
|
+
const CHUNK_NAME_SCHEMAS = "schemas";
|
|
59
|
+
const CHUNK_NAME_RESOLVERS = "resolvers";
|
|
60
|
+
/**
|
|
61
|
+
* Valid define function names for resolver exports
|
|
62
|
+
*/
|
|
63
|
+
const DEFINE_FUNCTIONS = [
|
|
64
|
+
"defineResolver",
|
|
65
|
+
"defineQuery",
|
|
66
|
+
"defineMutation",
|
|
67
|
+
"defineField",
|
|
68
|
+
"defineSubscription",
|
|
69
|
+
"defineDirective"
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Built-in GraphQL scalar types (should not be flagged as duplicates)
|
|
73
|
+
*/
|
|
74
|
+
const BUILTIN_SCALARS = [
|
|
75
|
+
"String",
|
|
76
|
+
"Int",
|
|
77
|
+
"Float",
|
|
78
|
+
"Boolean",
|
|
79
|
+
"ID",
|
|
80
|
+
"DateTime",
|
|
81
|
+
"JSON"
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Supported HTTP methods for GraphQL endpoints
|
|
85
|
+
*/
|
|
86
|
+
const GRAPHQL_HTTP_METHODS = [
|
|
87
|
+
"GET",
|
|
88
|
+
"POST",
|
|
89
|
+
"OPTIONS"
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Default paths for type generation (relative to buildDir)
|
|
93
|
+
*/
|
|
94
|
+
const DEFAULT_SERVER_TYPES_PATH = ".graphql/nitro-graphql-server.d.ts";
|
|
95
|
+
const DEFAULT_CLIENT_TYPES_PATH = ".graphql/nitro-graphql-client.d.ts";
|
|
96
|
+
/**
|
|
97
|
+
* Logger tag for nitro-graphql module
|
|
98
|
+
*/
|
|
99
|
+
const LOG_TAG = "nitro-graphql";
|
|
100
|
+
/**
|
|
101
|
+
* Default service directory name for main service
|
|
102
|
+
*/
|
|
103
|
+
const SERVICE_DEFAULT = "default";
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_SERVER_TYPES_PATH, DEFINE_FUNCTIONS, DIRECTIVE_EXTENSIONS, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_GRAPHQL_CONFIG, FILE_INDEX_TS, FILE_SCHEMA_TS, FRAMEWORK_NITRO, FRAMEWORK_NUXT, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_HTTP_METHODS, LOG_TAG, RESOLVER_EXTENSIONS, SERVICE_DEFAULT };
|
package/dist/ecosystem/nuxt.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDefaultPaths, getTypesConfig, resolveFilePath } from "../utils/path-resolver.mjs";
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
2
|
import { dirname, join, relative, resolve } from "pathe";
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { defineNuxtModule, getLayerDirectories } from "@nuxt/kit";
|
|
5
5
|
|
|
6
6
|
//#region src/ecosystem/nuxt.ts
|
|
@@ -46,8 +46,8 @@ var nuxt_default = defineNuxtModule({
|
|
|
46
46
|
if (externalTypesPath) {
|
|
47
47
|
const relativePath = relativeWithDot(tsconfigDir, externalTypesPath);
|
|
48
48
|
options.references.push({ path: relativePath });
|
|
49
|
-
options.tsConfig.compilerOptions.paths[`#graphql/client/${service.name}`] = [relativePath];
|
|
50
|
-
options.tsConfig.include.push(relativePath);
|
|
49
|
+
if (options.tsConfig.compilerOptions) options.tsConfig.compilerOptions.paths[`#graphql/client/${service.name}`] = [relativePath];
|
|
50
|
+
if (options.tsConfig.include) options.tsConfig.include.push(relativePath);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
});
|