nitro-graphql 1.5.4 → 1.5.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/dist/ecosystem/nuxt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getDefaultPaths, getTypesConfig, resolveFilePath } from "../utils/path-resolver.js";
|
|
1
2
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "pathe";
|
|
3
|
+
import { dirname, join, relative, resolve } from "pathe";
|
|
3
4
|
import { defineNuxtModule, getLayerDirectories } from "@nuxt/kit";
|
|
4
5
|
|
|
5
6
|
//#region src/ecosystem/nuxt.ts
|
|
@@ -11,24 +12,65 @@ var nuxt_default = defineNuxtModule({
|
|
|
11
12
|
},
|
|
12
13
|
setup: async (_options, nuxt) => {
|
|
13
14
|
nuxt.hooks.hook("prepare:types", (options) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const mockNitro$1 = { options: {
|
|
16
|
+
rootDir: nuxt.options.rootDir,
|
|
17
|
+
buildDir: nuxt.options.buildDir,
|
|
18
|
+
framework: { name: "nuxt" },
|
|
19
|
+
graphql: nuxt.options.nitro?.graphql
|
|
20
|
+
} };
|
|
21
|
+
const placeholders$1 = getDefaultPaths(mockNitro$1);
|
|
22
|
+
const typesConfig$1 = getTypesConfig(mockNitro$1);
|
|
23
|
+
const tsconfigDir = dirname(join(nuxt.options.buildDir, "tsconfig.json"));
|
|
24
|
+
const relativeWithDot = (from, to) => {
|
|
25
|
+
const rel = relative(from, to);
|
|
26
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
27
|
+
};
|
|
28
|
+
const clientTypesPath$1 = resolveFilePath(typesConfig$1.client, typesConfig$1.enabled, true, "{typesDir}/nitro-graphql-client.d.ts", placeholders$1);
|
|
29
|
+
if (clientTypesPath$1) {
|
|
30
|
+
const relativePath = relativeWithDot(tsconfigDir, clientTypesPath$1);
|
|
31
|
+
options.references.push({ path: relativePath });
|
|
32
|
+
options.tsConfig ??= {};
|
|
33
|
+
options.tsConfig.compilerOptions ??= {};
|
|
34
|
+
options.tsConfig.compilerOptions.paths ??= {};
|
|
35
|
+
options.tsConfig.compilerOptions.paths["#graphql/client"] = [relativePath];
|
|
36
|
+
options.tsConfig.include = options.tsConfig.include || [];
|
|
37
|
+
options.tsConfig.include.push(relativePath);
|
|
38
|
+
}
|
|
19
39
|
const externalServices$1 = nuxt.options.nitro?.graphql?.externalServices || [];
|
|
20
40
|
for (const service of externalServices$1) {
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
const servicePlaceholders = {
|
|
42
|
+
...placeholders$1,
|
|
43
|
+
serviceName: service.name
|
|
44
|
+
};
|
|
45
|
+
const externalTypesPath = resolveFilePath(service.paths?.types ?? typesConfig$1.external, typesConfig$1.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", servicePlaceholders);
|
|
46
|
+
if (externalTypesPath) {
|
|
47
|
+
const relativePath = relativeWithDot(tsconfigDir, externalTypesPath);
|
|
48
|
+
options.references.push({ path: relativePath });
|
|
49
|
+
options.tsConfig.compilerOptions.paths[`#graphql/client/${service.name}`] = [relativePath];
|
|
50
|
+
options.tsConfig.include.push(relativePath);
|
|
51
|
+
}
|
|
23
52
|
}
|
|
24
|
-
options.tsConfig.include = options.tsConfig.include || [];
|
|
25
|
-
options.tsConfig.include.push("./types/nitro-graphql-client.d.ts");
|
|
26
|
-
for (const service of externalServices$1) options.tsConfig.include.push(`./types/nitro-graphql-client-${service.name}.d.ts`);
|
|
27
53
|
});
|
|
28
54
|
nuxt.options.alias = nuxt.options.alias || {};
|
|
29
|
-
|
|
55
|
+
const mockNitro = { options: {
|
|
56
|
+
rootDir: nuxt.options.rootDir,
|
|
57
|
+
buildDir: nuxt.options.buildDir,
|
|
58
|
+
framework: { name: "nuxt" },
|
|
59
|
+
graphql: nuxt.options.nitro?.graphql
|
|
60
|
+
} };
|
|
61
|
+
const placeholders = getDefaultPaths(mockNitro);
|
|
62
|
+
const typesConfig = getTypesConfig(mockNitro);
|
|
63
|
+
const clientTypesPath = resolveFilePath(typesConfig.client, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client.d.ts", placeholders);
|
|
64
|
+
if (clientTypesPath) nuxt.options.alias["#graphql/client"] = clientTypesPath;
|
|
30
65
|
const externalServices = nuxt.options.nitro?.graphql?.externalServices || [];
|
|
31
|
-
for (const service of externalServices)
|
|
66
|
+
for (const service of externalServices) {
|
|
67
|
+
const servicePlaceholders = {
|
|
68
|
+
...placeholders,
|
|
69
|
+
serviceName: service.name
|
|
70
|
+
};
|
|
71
|
+
const externalTypesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", servicePlaceholders);
|
|
72
|
+
if (externalTypesPath) nuxt.options.alias[`#graphql/client/${service.name}`] = externalTypesPath;
|
|
73
|
+
}
|
|
32
74
|
nuxt.hook("imports:dirs", (dirs) => {
|
|
33
75
|
const graphqlServerPath = nuxt.options.nitro?.graphql?.serverDir || resolve(nuxt.options.srcDir, "graphql");
|
|
34
76
|
dirs.push(graphqlServerPath);
|
package/dist/index.js
CHANGED
|
@@ -237,17 +237,8 @@ var src_default = defineNitroModule({
|
|
|
237
237
|
...placeholders,
|
|
238
238
|
serviceName: service.name
|
|
239
239
|
};
|
|
240
|
-
consola.info(`[DEBUG] External service: ${service.name}`);
|
|
241
|
-
consola.info("[DEBUG] service.paths:", service.paths);
|
|
242
|
-
consola.info("[DEBUG] service.paths?.types:", service.paths?.types);
|
|
243
|
-
consola.info("[DEBUG] typesConfig.external:", typesConfig.external);
|
|
244
240
|
const externalTypesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", servicePlaceholders);
|
|
245
|
-
|
|
246
|
-
if (externalTypesPath) {
|
|
247
|
-
const relativePath = relativeWithDot(tsconfigDir, externalTypesPath);
|
|
248
|
-
consola.info("[DEBUG] relativePath after relativeWithDot:", relativePath);
|
|
249
|
-
types.tsConfig.compilerOptions.paths[`#graphql/client/${service.name}`] = [relativePath];
|
|
250
|
-
}
|
|
241
|
+
if (externalTypesPath) types.tsConfig.compilerOptions.paths[`#graphql/client/${service.name}`] = [relativeWithDot(tsconfigDir, externalTypesPath)];
|
|
251
242
|
}
|
|
252
243
|
types.tsConfig.include = types.tsConfig.include || [];
|
|
253
244
|
if (serverTypesPath) types.tsConfig.include.push(relativeWithDot(tsconfigDir, serverTypesPath));
|
package/dist/routes/debug.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h35 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/debug.d.ts
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import * as h30 from "h3";
|
|
|
10
10
|
* - /_nitro/graphql/debug - HTML dashboard
|
|
11
11
|
* - /_nitro/graphql/debug?format=json - JSON API
|
|
12
12
|
*/
|
|
13
|
-
declare const _default:
|
|
13
|
+
declare const _default: h35.EventHandler<h35.EventHandlerRequest, Promise<string | {
|
|
14
14
|
timestamp: string;
|
|
15
15
|
environment: {
|
|
16
16
|
dev: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h30 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h30.EventHandler<h30.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h31.EventHandler<h31.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
|
@@ -336,12 +336,7 @@ async function generateExternalServicesTypes(nitro) {
|
|
|
336
336
|
};
|
|
337
337
|
const typesConfig = getTypesConfig(nitro);
|
|
338
338
|
const sdkConfig = getSdkConfig(nitro);
|
|
339
|
-
consola.info(`[TYPE-GEN DEBUG] External service: ${service.name}`);
|
|
340
|
-
consola.info("[TYPE-GEN DEBUG] service.paths:", service.paths);
|
|
341
|
-
consola.info("[TYPE-GEN DEBUG] service.paths?.types:", service.paths?.types);
|
|
342
|
-
consola.info("[TYPE-GEN DEBUG] typesConfig.external:", typesConfig.external);
|
|
343
339
|
const serviceTypesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", placeholders);
|
|
344
|
-
consola.info("[TYPE-GEN DEBUG] serviceTypesPath after resolveFilePath:", serviceTypesPath);
|
|
345
340
|
if (serviceTypesPath) {
|
|
346
341
|
mkdirSync(dirname(serviceTypesPath), { recursive: true });
|
|
347
342
|
writeFileSync(serviceTypesPath, types.types, "utf-8");
|