nitro-graphql 2.0.0-beta.4 → 2.0.0-beta.7

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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { StandardSchemaV1 } from "./types/standard-schema.js";
2
- import { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions } from "./types/index.js";
3
- import * as nitro_types0 from "nitro/types";
2
+ import { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "./types/index.js";
3
+ import * as nitropack_types0 from "nitropack/types";
4
4
 
5
5
  //#region src/index.d.ts
6
- declare const _default: nitro_types0.NitroModule;
6
+ declare const _default: nitropack_types0.NitroModule;
7
7
  //#endregion
8
- export { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, StandardSchemaV1, _default as default };
8
+ export { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, StandardSchemaV1, TypesConfig, _default as default };
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { generateDirectiveSchemas } from "./utils/directive-parser.js";
2
2
  import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerServerDirectories, relativeWithDot, scanDirectives, scanDocs, scanResolvers, scanSchemas, validateExternalServices } from "./utils/index.js";
3
+ import { writeFileIfNotExists } from "./utils/file-generator.js";
4
+ import { getDefaultPaths, getScaffoldConfig, resolveFilePath, shouldGenerateScaffold } from "./utils/path-resolver.js";
3
5
  import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.js";
4
6
  import { rollupConfig } from "./rollup.js";
5
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
7
+ import { existsSync, mkdirSync } from "node:fs";
6
8
  import { fileURLToPath } from "node:url";
7
9
  import { watch } from "chokidar";
8
10
  import consola from "consola";
@@ -111,12 +113,53 @@ var src_default = defineNitroModule({
111
113
  nitro.scanDirectives = directives;
112
114
  await generateDirectiveSchemas(nitro, directives);
113
115
  nitro.hooks.hook("dev:start", async () => {
114
- nitro.scanSchemas = await scanSchemas(nitro);
115
- nitro.scanResolvers = await scanResolvers(nitro);
116
+ const schemas = await scanSchemas(nitro);
117
+ nitro.scanSchemas = schemas;
118
+ const resolvers = await scanResolvers(nitro);
119
+ nitro.scanResolvers = resolvers;
116
120
  const directives$1 = await scanDirectives(nitro);
117
121
  nitro.scanDirectives = directives$1;
118
122
  await generateDirectiveSchemas(nitro, directives$1);
119
- nitro.scanDocuments = await scanDocs(nitro);
123
+ const docs = await scanDocs(nitro);
124
+ nitro.scanDocuments = docs;
125
+ if (nitro.options.dev) {
126
+ consola.box({
127
+ title: "Nitro GraphQL",
128
+ message: [
129
+ `Framework: ${nitro.options.graphql?.framework || "Not configured"}`,
130
+ `Schemas: ${schemas.length}`,
131
+ `Resolvers: ${resolvers.length}`,
132
+ `Directives: ${directives$1.length}`,
133
+ `Documents: ${docs.length}`,
134
+ "",
135
+ "Debug Dashboard: /_nitro/graphql/debug"
136
+ ].join("\n"),
137
+ style: {
138
+ borderColor: "cyan",
139
+ borderStyle: "rounded"
140
+ }
141
+ });
142
+ if (resolvers.length > 0) {
143
+ const totalExports = resolvers.reduce((sum, r) => sum + r.imports.length, 0);
144
+ const typeCount = {
145
+ query: 0,
146
+ mutation: 0,
147
+ resolver: 0,
148
+ type: 0,
149
+ subscription: 0,
150
+ directive: 0
151
+ };
152
+ for (const resolver of resolvers) for (const imp of resolver.imports) if (imp.type in typeCount) typeCount[imp.type]++;
153
+ const breakdown = [];
154
+ if (typeCount.query > 0) breakdown.push(`${typeCount.query} query`);
155
+ if (typeCount.mutation > 0) breakdown.push(`${typeCount.mutation} mutation`);
156
+ if (typeCount.resolver > 0) breakdown.push(`${typeCount.resolver} resolver`);
157
+ if (typeCount.type > 0) breakdown.push(`${typeCount.type} type`);
158
+ if (typeCount.subscription > 0) breakdown.push(`${typeCount.subscription} subscription`);
159
+ if (typeCount.directive > 0) breakdown.push(`${typeCount.directive} directive`);
160
+ if (breakdown.length > 0) consola.success(`[nitro-graphql] ${totalExports} resolver export(s): ${breakdown.join(", ")}`);
161
+ } else consola.warn("[nitro-graphql] No resolvers found. Check /_nitro/graphql/debug for details.");
162
+ }
120
163
  });
121
164
  await rollupConfig(nitro);
122
165
  await serverTypeGeneration(nitro);
@@ -146,6 +189,14 @@ var src_default = defineNitroModule({
146
189
  handler: join(runtime, "health"),
147
190
  method: "GET"
148
191
  });
192
+ if (nitro.options.dev) {
193
+ nitro.options.handlers.push({
194
+ route: "/_nitro/graphql/debug",
195
+ handler: join(runtime, "debug"),
196
+ method: "get"
197
+ });
198
+ consola.info("[nitro-graphql] Debug dashboard available at: /_nitro/graphql/debug");
199
+ }
149
200
  if (nitro.options.imports) {
150
201
  nitro.options.imports.presets ??= [];
151
202
  nitro.options.imports.presets.push({
@@ -193,34 +244,36 @@ var src_default = defineNitroModule({
193
244
  const nuxtOptions = nitro._nuxt?.options;
194
245
  if (nuxtOptions) nuxtOptions.nitroGraphqlExternalServices = nitro.options.graphql?.externalServices || [];
195
246
  });
196
- if (!existsSync(join(nitro.options.rootDir, "graphql.config.ts"))) {
197
- const schemaPath = relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.buildDir, "schema.graphql"));
198
- const documentsPath = relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.clientDir, "**/*.{graphql,js,ts,jsx,tsx}"));
199
- writeFileSync(join(nitro.options.rootDir, "graphql.config.ts"), `
247
+ if (shouldGenerateScaffold(nitro)) {
248
+ const placeholders = getDefaultPaths(nitro);
249
+ const scaffoldConfig = getScaffoldConfig(nitro);
250
+ const graphqlConfigPath = resolveFilePath(scaffoldConfig.graphqlConfig, scaffoldConfig.enabled, true, "graphql.config.ts", placeholders);
251
+ if (graphqlConfigPath) writeFileIfNotExists(graphqlConfigPath, `
200
252
  import type { IGraphQLConfig } from 'graphql-config'
201
253
 
202
254
  export default <IGraphQLConfig> {
203
255
  projects: {
204
256
  default: {
205
257
  schema: [
206
- '${schemaPath}',
258
+ '${relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.buildDir, "schema.graphql"))}',
207
259
  ],
208
260
  documents: [
209
- '${documentsPath}',
261
+ '${relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.clientDir, "**/*.{graphql,js,ts,jsx,tsx}"))}',
210
262
  ],
211
263
  },
212
264
  },
213
- }`, "utf-8");
214
- }
215
- if (!existsSync(nitro.graphql.serverDir)) mkdirSync(nitro.graphql.serverDir, { recursive: true });
216
- if (!existsSync(join(nitro.graphql.serverDir, "schema.ts"))) writeFileSync(join(nitro.graphql.serverDir, "schema.ts"), `
217
- import { defineSchema } from 'nitro-graphql/utils/define'
218
-
219
- export default defineSchema({
265
+ }`, "graphql.config.ts");
266
+ const serverSchemaPath = resolveFilePath(scaffoldConfig.serverSchema, scaffoldConfig.enabled, true, "{serverGraphql}/schema.ts", placeholders);
267
+ const serverConfigPath = resolveFilePath(scaffoldConfig.serverConfig, scaffoldConfig.enabled, true, "{serverGraphql}/config.ts", placeholders);
268
+ const serverContextPath = resolveFilePath(scaffoldConfig.serverContext, scaffoldConfig.enabled, true, "{serverGraphql}/context.ts", placeholders);
269
+ if (serverSchemaPath || serverConfigPath || serverContextPath) {
270
+ if (!existsSync(nitro.graphql.serverDir)) mkdirSync(nitro.graphql.serverDir, { recursive: true });
271
+ }
272
+ if (serverSchemaPath) writeFileIfNotExists(serverSchemaPath, `export default defineSchema({
220
273
 
221
274
  })
222
- `, "utf-8");
223
- if (!existsSync(join(nitro.graphql.serverDir, "config.ts"))) writeFileSync(join(nitro.graphql.serverDir, "config.ts"), `// Example GraphQL config file please change it to your needs
275
+ `, "server schema.ts");
276
+ if (serverConfigPath) writeFileIfNotExists(serverConfigPath, `// Example GraphQL config file please change it to your needs
224
277
  // import * as tables from '../drizzle/schema/index'
225
278
  // import { useDatabase } from '../utils/useDb'
226
279
  import { defineGraphQLConfig } from 'nitro-graphql/utils/define'
@@ -236,8 +289,8 @@ export default defineGraphQLConfig({
236
289
  // }
237
290
  // },
238
291
  })
239
- `, "utf-8");
240
- if (!existsSync(join(nitro.graphql.serverDir, "context.ts"))) writeFileSync(join(nitro.graphql.serverDir, "context.ts"), `// Example context definition - please change it to your needs
292
+ `, "server config.ts");
293
+ if (serverContextPath) writeFileIfNotExists(serverContextPath, `// Example context definition - please change it to your needs
241
294
  // import type { Database } from '../utils/useDb'
242
295
 
243
296
  declare module 'h3' {
@@ -252,11 +305,12 @@ declare module 'h3' {
252
305
  // }
253
306
  // }
254
307
  }
255
- }`, "utf-8");
256
- if (existsSync(join(nitro.graphql.serverDir, "context.d.ts"))) {
257
- consola.warn("nitro-graphql: Found context.d.ts file. Please rename it to context.ts for the new structure.");
258
- consola.info("The context file should now be context.ts instead of context.d.ts");
259
- }
308
+ }`, "server context.ts");
309
+ if (existsSync(join(nitro.graphql.serverDir, "context.d.ts"))) {
310
+ consola.warn("nitro-graphql: Found context.d.ts file. Please rename it to context.ts for the new structure.");
311
+ consola.info("The context file should now be context.ts instead of context.d.ts");
312
+ }
313
+ } else consola.info("[nitro-graphql] Scaffold file generation is disabled (library mode)");
260
314
  }
261
315
  });
262
316
 
package/dist/rollup.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getImportId, scanGraphql } from "./utils/index.js";
2
2
  import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.js";
3
+ import { fileURLToPath } from "node:url";
3
4
  import { resolve } from "pathe";
4
5
  import { readFile } from "node:fs/promises";
5
6
  import { parse } from "graphql";
@@ -12,36 +13,77 @@ async function rollupConfig(app) {
12
13
  virtualDirectives(app);
13
14
  getGraphQLConfig(app);
14
15
  virtualModuleConfig(app);
16
+ virtualDebugInfo(app);
15
17
  app.hooks.hook("rollup:before", (nitro, rollupConfig$1) => {
16
18
  rollupConfig$1.plugins = rollupConfig$1.plugins || [];
17
- const { include = /\.(graphql|gql)$/i, exclude, validate = false } = app.options.graphql?.loader || {};
19
+ const { include = /\.(?:graphql|gql)$/i, exclude, validate = false } = app.options.graphql?.loader || {};
18
20
  if (Array.isArray(rollupConfig$1.plugins)) {
19
21
  rollupConfig$1.plugins.push({
20
- name: "nitro-graphql",
21
- enforce: "pre",
22
- resolveId(id) {
23
- if (/\.(graphql|gql)$/i.test(id)) return null;
22
+ name: "nitro-graphql:virtual",
23
+ resolveId: {
24
+ order: "pre",
25
+ async handler(id, parent, options) {
26
+ if (id.startsWith("#nitro-graphql/")) return `\0virtual:${id}`;
27
+ if (parent?.startsWith("\0virtual:#nitro-graphql")) {
28
+ const runtimeDir = fileURLToPath(new URL("routes", import.meta.url));
29
+ const internalRes = await this.resolve(id, runtimeDir, {
30
+ skipSelf: true,
31
+ ...options
32
+ });
33
+ if (internalRes) return internalRes;
34
+ }
35
+ }
24
36
  },
25
- async load(id) {
26
- if (exclude?.test?.(id)) return null;
27
- if (!include.test(id)) return null;
28
- try {
29
- const content = await readFile(id, "utf-8");
30
- if (validate) parse(content);
31
- return `export default ${JSON.stringify(content)}`;
32
- } catch (error) {
33
- if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
34
- const message = error instanceof Error ? error.message : String(error);
35
- this.error(`Failed to read GraphQL file ${id}: ${message}`);
37
+ load: {
38
+ order: "pre",
39
+ handler(id) {
40
+ if (id.startsWith("\0virtual:#nitro-graphql/")) {
41
+ const moduleName = id.slice(9);
42
+ const generator = app.options.virtual?.[moduleName];
43
+ if (typeof generator === "function") try {
44
+ return generator();
45
+ } catch (error) {
46
+ const message = error instanceof Error ? error.message : String(error);
47
+ this.error(`Failed to generate virtual module ${moduleName}: ${message}`);
48
+ }
49
+ else this.error(`No generator function found for virtual module ${moduleName}`);
50
+ }
36
51
  }
37
52
  }
38
53
  });
39
54
  rollupConfig$1.plugins.push({
55
+ name: "nitro-graphql",
56
+ resolveId: {
57
+ order: "pre",
58
+ handler(id) {
59
+ if (/\.(?:graphql|gql)$/i.test(id)) return null;
60
+ }
61
+ },
62
+ load: {
63
+ order: "pre",
64
+ async handler(id) {
65
+ if (exclude?.test?.(id)) return null;
66
+ if (!include.test(id)) return null;
67
+ try {
68
+ const content = await readFile(id, "utf-8");
69
+ if (validate) parse(content);
70
+ return `export default ${JSON.stringify(content)}`;
71
+ } catch (error) {
72
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
73
+ const message = error instanceof Error ? error.message : String(error);
74
+ this.error(`Failed to read GraphQL file ${id}: ${message}`);
75
+ }
76
+ }
77
+ }
78
+ });
79
+ if (app.options.dev) rollupConfig$1.plugins.push({
40
80
  name: "nitro-graphql-watcher",
41
- enforce: "pre",
42
- async buildStart() {
43
- const graphqlFiles = await scanGraphql(nitro);
44
- for (const file of graphqlFiles) this.addWatchFile(file);
81
+ buildStart: {
82
+ order: "pre",
83
+ async handler() {
84
+ const graphqlFiles = await scanGraphql(nitro);
85
+ for (const file of graphqlFiles) this.addWatchFile(file);
86
+ }
45
87
  }
46
88
  });
47
89
  }
@@ -54,53 +96,115 @@ async function rollupConfig(app) {
54
96
  function virtualSchemas(app) {
55
97
  const getSchemas = () => [...app.scanSchemas, ...app.options.graphql?.typedefs ?? []];
56
98
  app.options.virtual ??= {};
57
- app.options.virtual["#nitro-internal-virtual/server-schemas"] = () => {
58
- const imports = getSchemas();
59
- return `
60
- ${imports.map((handler) => `import ${getImportId(handler)} from '${handler}';`).join("\n")}
99
+ app.options.virtual["#nitro-graphql/server-schemas"] = () => {
100
+ try {
101
+ const imports = getSchemas();
102
+ if (imports.length === 0) {
103
+ if (app.options.dev) app.logger.warn("[nitro-graphql] No schemas found. Virtual module will export empty array.");
104
+ return "export const schemas = []";
105
+ }
106
+ const importStatements = imports.map((handler) => `import ${getImportId(handler)} from '${handler}';`);
107
+ const schemaArray = imports.map((h) => `{ def: ${getImportId(h)} }`);
108
+ return `
109
+ ${importStatements.join("\n")}
61
110
 
62
111
  export const schemas = [
63
- ${imports.map((h) => `{ def: ${getImportId(h)} }`).join(",\n")}
112
+ ${schemaArray.join(",\n")}
64
113
  ];
65
114
  `;
115
+ } catch (error) {
116
+ app.logger.error("[nitro-graphql] Failed to generate virtual schema module:", error);
117
+ return "export const schemas = []";
118
+ }
66
119
  };
67
120
  }
68
121
  function virtualResolvers(app) {
69
122
  const getResolvers = () => [...app.scanResolvers];
70
123
  app.options.virtual ??= {};
71
- app.options.virtual["#nitro-internal-virtual/server-resolvers"] = () => {
72
- const imports = getResolvers();
73
- const importsContent = imports.map(({ specifier, imports: imports$1, options }) => genImport(specifier, imports$1, options));
74
- const data = imports.map(({ imports: imports$1 }) => imports$1.map((i) => `{ resolver: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
75
- return [
76
- ...importsContent,
77
- "export const resolvers = [",
78
- data,
79
- "]",
80
- ""
81
- ].join("\n");
124
+ app.options.virtual["#nitro-graphql/server-resolvers"] = () => {
125
+ try {
126
+ const imports = getResolvers();
127
+ if (imports.length === 0) {
128
+ if (app.options.dev) app.logger.warn("[nitro-graphql] No resolvers found. Virtual module will export empty array.");
129
+ return "export const resolvers = []";
130
+ }
131
+ const importsContent = [];
132
+ const invalidImports = [];
133
+ for (const { specifier, imports: importList, options } of imports) try {
134
+ if (!importList || importList.length === 0) {
135
+ invalidImports.push(`${specifier}: No exports found`);
136
+ continue;
137
+ }
138
+ const importCode = genImport(specifier, importList, options);
139
+ importsContent.push(importCode);
140
+ } catch (error) {
141
+ const message = error instanceof Error ? error.message : String(error);
142
+ invalidImports.push(`${specifier}: ${message}`);
143
+ if (app.options.dev) app.logger.error(`[nitro-graphql] Failed to generate import for ${specifier}:`, error);
144
+ }
145
+ if (invalidImports.length > 0 && app.options.dev) {
146
+ app.logger.warn("[nitro-graphql] Some resolver imports could not be generated:");
147
+ for (const msg of invalidImports) app.logger.warn(` - ${msg}`);
148
+ }
149
+ const data = imports.map(({ imports: importList }) => importList.map((i) => `{ resolver: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
150
+ return [
151
+ ...importsContent,
152
+ "",
153
+ "export const resolvers = [",
154
+ data,
155
+ "]",
156
+ ""
157
+ ].join("\n");
158
+ } catch (error) {
159
+ app.logger.error("[nitro-graphql] Failed to generate virtual resolver module:", error);
160
+ return "export const resolvers = []";
161
+ }
82
162
  };
83
163
  }
84
164
  function virtualDirectives(app) {
85
165
  const getDirectives = () => app.scanDirectives || [];
86
166
  app.options.virtual ??= {};
87
- app.options.virtual["#nitro-internal-virtual/server-directives"] = () => {
88
- const imports = getDirectives();
89
- const importsContent = imports.map(({ specifier, imports: imports$1, options }) => genImport(specifier, imports$1, options));
90
- const data = imports.map(({ imports: imports$1 }) => imports$1.map((i) => `{ directive: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
91
- return [
92
- ...importsContent,
93
- "export const directives = [",
94
- data,
95
- "]",
96
- ""
97
- ].join("\n");
167
+ app.options.virtual["#nitro-graphql/server-directives"] = () => {
168
+ try {
169
+ const imports = getDirectives();
170
+ if (imports.length === 0) return "export const directives = []";
171
+ const importsContent = [];
172
+ const invalidImports = [];
173
+ for (const { specifier, imports: importList, options } of imports) try {
174
+ if (!importList || importList.length === 0) {
175
+ invalidImports.push(`${specifier}: No exports found`);
176
+ continue;
177
+ }
178
+ const importCode = genImport(specifier, importList, options);
179
+ importsContent.push(importCode);
180
+ } catch (error) {
181
+ const message = error instanceof Error ? error.message : String(error);
182
+ invalidImports.push(`${specifier}: ${message}`);
183
+ if (app.options.dev) app.logger.error(`[nitro-graphql] Failed to generate import for directive ${specifier}:`, error);
184
+ }
185
+ if (invalidImports.length > 0 && app.options.dev) {
186
+ app.logger.warn("[nitro-graphql] Some directive imports could not be generated:");
187
+ for (const msg of invalidImports) app.logger.warn(` - ${msg}`);
188
+ }
189
+ const data = imports.map(({ imports: importList }) => importList.map((i) => `{ directive: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
190
+ return [
191
+ ...importsContent,
192
+ "",
193
+ "export const directives = [",
194
+ data,
195
+ "]",
196
+ ""
197
+ ].join("\n");
198
+ } catch (error) {
199
+ app.logger.error("[nitro-graphql] Failed to generate virtual directive module:", error);
200
+ return "export const directives = []";
201
+ }
98
202
  };
99
203
  }
100
204
  function getGraphQLConfig(app) {
101
205
  const configPath = resolve(app.graphql.serverDir, "config.ts");
102
206
  app.options.virtual ??= {};
103
- app.options.virtual["#nitro-internal-virtual/graphql-config"] = () => {
207
+ app.options.virtual["#nitro-graphql/graphql-config"] = () => {
104
208
  return `import config from '${configPath}'
105
209
  const importedConfig = config
106
210
  export { importedConfig }
@@ -109,11 +213,65 @@ export { importedConfig }
109
213
  }
110
214
  function virtualModuleConfig(app) {
111
215
  app.options.virtual ??= {};
112
- app.options.virtual["#nitro-internal-virtual/module-config"] = () => {
216
+ app.options.virtual["#nitro-graphql/module-config"] = () => {
113
217
  const moduleConfig = app.options.graphql || {};
114
218
  return `export const moduleConfig = ${JSON.stringify(moduleConfig, null, 2)};`;
115
219
  };
116
220
  }
221
+ function virtualDebugInfo(app) {
222
+ app.options.virtual ??= {};
223
+ app.options.virtual["#nitro-graphql/debug-info"] = () => {
224
+ const virtualModuleCodes = {};
225
+ try {
226
+ const schemasGenerator = app.options.virtual["#nitro-graphql/server-schemas"];
227
+ if (schemasGenerator && typeof schemasGenerator === "function") virtualModuleCodes["server-schemas"] = schemasGenerator();
228
+ } catch (error) {
229
+ virtualModuleCodes["server-schemas"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
230
+ }
231
+ try {
232
+ const resolversGenerator = app.options.virtual["#nitro-graphql/server-resolvers"];
233
+ if (resolversGenerator && typeof resolversGenerator === "function") virtualModuleCodes["server-resolvers"] = resolversGenerator();
234
+ } catch (error) {
235
+ virtualModuleCodes["server-resolvers"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
236
+ }
237
+ try {
238
+ const directivesGenerator = app.options.virtual["#nitro-graphql/server-directives"];
239
+ if (directivesGenerator && typeof directivesGenerator === "function") virtualModuleCodes["server-directives"] = directivesGenerator();
240
+ } catch (error) {
241
+ virtualModuleCodes["server-directives"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
242
+ }
243
+ try {
244
+ const moduleConfigGenerator = app.options.virtual["#nitro-graphql/module-config"];
245
+ if (moduleConfigGenerator && typeof moduleConfigGenerator === "function") virtualModuleCodes["module-config"] = moduleConfigGenerator();
246
+ } catch (error) {
247
+ virtualModuleCodes["module-config"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
248
+ }
249
+ try {
250
+ const graphqlConfigGenerator = app.options.virtual["#nitro-graphql/graphql-config"];
251
+ if (graphqlConfigGenerator && typeof graphqlConfigGenerator === "function") virtualModuleCodes["graphql-config"] = graphqlConfigGenerator();
252
+ } catch (error) {
253
+ virtualModuleCodes["graphql-config"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
254
+ }
255
+ const debugInfo = {
256
+ isDev: app.options.dev,
257
+ framework: app.options.framework.name,
258
+ graphqlFramework: app.options.graphql?.framework,
259
+ federation: app.options.graphql?.federation,
260
+ scanned: {
261
+ schemas: app.scanSchemas?.length || 0,
262
+ schemaFiles: app.scanSchemas || [],
263
+ resolvers: app.scanResolvers?.length || 0,
264
+ resolverFiles: app.scanResolvers || [],
265
+ directives: app.scanDirectives?.length || 0,
266
+ directiveFiles: app.scanDirectives || [],
267
+ documents: app.scanDocuments?.length || 0,
268
+ documentFiles: app.scanDocuments || []
269
+ },
270
+ virtualModules: virtualModuleCodes
271
+ };
272
+ return `export const debugInfo = ${JSON.stringify(debugInfo, null, 2)};`;
273
+ };
274
+ }
117
275
 
118
276
  //#endregion
119
277
  export { rollupConfig };
@@ -1,6 +1,6 @@
1
- import * as h33 from "h3";
1
+ import * as h30 from "h3";
2
2
 
3
3
  //#region src/routes/apollo-server.d.ts
4
- declare const _default: h33.EventHandler<h33.EventHandlerRequest, unknown>;
4
+ declare const _default: h30.EventHandlerWithFetch<h30.EventHandlerRequest, Promise<any>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -2,11 +2,11 @@ import { consola as consola$1 } from "consola";
2
2
  import defu from "defu";
3
3
  import { parse } from "graphql";
4
4
  import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
5
- import { importedConfig } from "#nitro-internal-virtual/graphql-config";
6
- import { moduleConfig } from "#nitro-internal-virtual/module-config";
7
- import { directives } from "#nitro-internal-virtual/server-directives";
8
- import { resolvers } from "#nitro-internal-virtual/server-resolvers";
9
- import { schemas } from "#nitro-internal-virtual/server-schemas";
5
+ import { importedConfig } from "#nitro-graphql/graphql-config";
6
+ import { moduleConfig } from "#nitro-graphql/module-config";
7
+ import { directives } from "#nitro-graphql/server-directives";
8
+ import { resolvers } from "#nitro-graphql/server-resolvers";
9
+ import { schemas } from "#nitro-graphql/server-schemas";
10
10
  import { ApolloServer } from "@apollo/server";
11
11
  import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
12
12
  import { makeExecutableSchema } from "@graphql-tools/schema";
@@ -0,0 +1,61 @@
1
+ import * as h31 from "h3";
2
+
3
+ //#region src/routes/debug.d.ts
4
+
5
+ /**
6
+ * Debug endpoint for inspecting virtual modules and GraphQL setup
7
+ * Only available in development mode
8
+ *
9
+ * Routes:
10
+ * - /_nitro/graphql/debug - HTML dashboard
11
+ * - /_nitro/graphql/debug?format=json - JSON API
12
+ */
13
+ declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<string | {
14
+ timestamp: string;
15
+ environment: {
16
+ dev: any;
17
+ framework: any;
18
+ };
19
+ graphql: {
20
+ framework: any;
21
+ federation: any;
22
+ };
23
+ scanned: {
24
+ schemas: any;
25
+ schemaFiles: any;
26
+ resolvers: any;
27
+ resolverFiles: any;
28
+ directives: any;
29
+ directiveFiles: any;
30
+ documents: any;
31
+ documentFiles: any;
32
+ };
33
+ runtime: {
34
+ loadedResolvers: number;
35
+ loadedSchemas: number;
36
+ loadedDirectives: number;
37
+ };
38
+ virtualModules: any;
39
+ virtualModuleSamples: {
40
+ 'server-resolvers': {
41
+ resolverCount: number;
42
+ sample: {
43
+ hasResolver: boolean;
44
+ resolverKeys: string[];
45
+ }[];
46
+ };
47
+ 'server-schemas': {
48
+ schemaCount: number;
49
+ sample: {
50
+ defLength: number;
51
+ defPreview: string;
52
+ }[];
53
+ };
54
+ 'server-directives': {
55
+ directiveCount: number;
56
+ };
57
+ 'module-config': Record<string, any>;
58
+ };
59
+ }>>;
60
+ //#endregion
61
+ export { _default as default };