nitro-graphql 1.4.4 → 1.5.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.
@@ -43,8 +43,7 @@ var nuxt_default = defineNuxtModule({
43
43
  nitroConfig.graphql.layerDirectories = layerDirectories;
44
44
  nitroConfig.graphql.layerServerDirs = layerServerDirs;
45
45
  nitroConfig.graphql.layerAppDirs = layerAppDirs;
46
- const appGraphqlDir = resolve(nuxt.options.rootDir, "app/graphql");
47
- if (!existsSync(appGraphqlDir)) {
46
+ if (!existsSync(resolve(nuxt.options.rootDir, "app/graphql"))) {
48
47
  const defaultDir = join(clientDir, "default");
49
48
  if (!existsSync(defaultDir)) mkdirSync(defaultDir, { recursive: true });
50
49
  const sampleQueryFile = join(defaultDir, "queries.graphql");
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";
2
+ import { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "./types/index.js";
3
3
  import * as nitropack0 from "nitropack";
4
4
 
5
5
  //#region src/index.d.ts
6
6
  declare const _default: nitropack0.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";
@@ -96,8 +98,7 @@ var src_default = defineNitroModule({
96
98
  nitro.hooks.hook("close", () => {
97
99
  watcher.close();
98
100
  });
99
- const tsConfigPath = resolve(nitro.options.buildDir, nitro.options.typescript.tsconfigPath);
100
- const tsconfigDir = dirname(tsConfigPath);
101
+ const tsconfigDir = dirname(resolve(nitro.options.buildDir, nitro.options.typescript.tsconfigPath));
101
102
  const typesDir = resolve(nitro.options.buildDir, "types");
102
103
  nitro.scanSchemas = await scanSchemas(nitro);
103
104
  nitro.scanDocuments = await scanDocs(nitro);
@@ -106,12 +107,53 @@ var src_default = defineNitroModule({
106
107
  nitro.scanDirectives = directives;
107
108
  await generateDirectiveSchemas(nitro, directives);
108
109
  nitro.hooks.hook("dev:start", async () => {
109
- nitro.scanSchemas = await scanSchemas(nitro);
110
- nitro.scanResolvers = await scanResolvers(nitro);
110
+ const schemas = await scanSchemas(nitro);
111
+ nitro.scanSchemas = schemas;
112
+ const resolvers = await scanResolvers(nitro);
113
+ nitro.scanResolvers = resolvers;
111
114
  const directives$1 = await scanDirectives(nitro);
112
115
  nitro.scanDirectives = directives$1;
113
116
  await generateDirectiveSchemas(nitro, directives$1);
114
- nitro.scanDocuments = await scanDocs(nitro);
117
+ const docs = await scanDocs(nitro);
118
+ nitro.scanDocuments = docs;
119
+ if (nitro.options.dev) {
120
+ consola.box({
121
+ title: "Nitro GraphQL",
122
+ message: [
123
+ `Framework: ${nitro.options.graphql?.framework || "Not configured"}`,
124
+ `Schemas: ${schemas.length}`,
125
+ `Resolvers: ${resolvers.length}`,
126
+ `Directives: ${directives$1.length}`,
127
+ `Documents: ${docs.length}`,
128
+ "",
129
+ "Debug Dashboard: /_nitro/graphql/debug"
130
+ ].join("\n"),
131
+ style: {
132
+ borderColor: "cyan",
133
+ borderStyle: "rounded"
134
+ }
135
+ });
136
+ if (resolvers.length > 0) {
137
+ const totalExports = resolvers.reduce((sum, r) => sum + r.imports.length, 0);
138
+ const typeCount = {
139
+ query: 0,
140
+ mutation: 0,
141
+ resolver: 0,
142
+ type: 0,
143
+ subscription: 0,
144
+ directive: 0
145
+ };
146
+ for (const resolver of resolvers) for (const imp of resolver.imports) if (imp.type in typeCount) typeCount[imp.type]++;
147
+ const breakdown = [];
148
+ if (typeCount.query > 0) breakdown.push(`${typeCount.query} query`);
149
+ if (typeCount.mutation > 0) breakdown.push(`${typeCount.mutation} mutation`);
150
+ if (typeCount.resolver > 0) breakdown.push(`${typeCount.resolver} resolver`);
151
+ if (typeCount.type > 0) breakdown.push(`${typeCount.type} type`);
152
+ if (typeCount.subscription > 0) breakdown.push(`${typeCount.subscription} subscription`);
153
+ if (typeCount.directive > 0) breakdown.push(`${typeCount.directive} directive`);
154
+ if (breakdown.length > 0) consola.success(`[nitro-graphql] ${totalExports} resolver export(s): ${breakdown.join(", ")}`);
155
+ } else consola.warn("[nitro-graphql] No resolvers found. Check /_nitro/graphql/debug for details.");
156
+ }
115
157
  });
116
158
  await rollupConfig(nitro);
117
159
  await serverTypeGeneration(nitro);
@@ -141,6 +183,14 @@ var src_default = defineNitroModule({
141
183
  handler: join(runtime, "health"),
142
184
  method: "get"
143
185
  });
186
+ if (nitro.options.dev) {
187
+ nitro.options.handlers.push({
188
+ route: "/_nitro/graphql/debug",
189
+ handler: join(runtime, "debug"),
190
+ method: "get"
191
+ });
192
+ consola.info("[nitro-graphql] Debug dashboard available at: /_nitro/graphql/debug");
193
+ }
144
194
  if (nitro.options.imports) {
145
195
  nitro.options.imports.presets ??= [];
146
196
  nitro.options.imports.presets.push({
@@ -188,31 +238,36 @@ var src_default = defineNitroModule({
188
238
  const nuxtOptions = nitro._nuxt?.options;
189
239
  if (nuxtOptions) nuxtOptions.nitroGraphqlExternalServices = nitro.options.graphql?.externalServices || [];
190
240
  });
191
- if (!existsSync(join(nitro.options.rootDir, "graphql.config.ts"))) {
192
- const schemaPath = relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.buildDir, "schema.graphql"));
193
- const documentsPath = relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.clientDir, "**/*.{graphql,js,ts,jsx,tsx}"));
194
- writeFileSync(join(nitro.options.rootDir, "graphql.config.ts"), `
241
+ if (shouldGenerateScaffold(nitro)) {
242
+ const placeholders = getDefaultPaths(nitro);
243
+ const scaffoldConfig = getScaffoldConfig(nitro);
244
+ const graphqlConfigPath = resolveFilePath(scaffoldConfig.graphqlConfig, scaffoldConfig.enabled, true, "graphql.config.ts", placeholders);
245
+ if (graphqlConfigPath) writeFileIfNotExists(graphqlConfigPath, `
195
246
  import type { IGraphQLConfig } from 'graphql-config'
196
247
 
197
248
  export default <IGraphQLConfig> {
198
249
  projects: {
199
250
  default: {
200
251
  schema: [
201
- '${schemaPath}',
252
+ '${relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.buildDir, "schema.graphql"))}',
202
253
  ],
203
254
  documents: [
204
- '${documentsPath}',
255
+ '${relativeWithDot(nitro.options.rootDir, resolve(nitro.graphql.clientDir, "**/*.{graphql,js,ts,jsx,tsx}"))}',
205
256
  ],
206
257
  },
207
258
  },
208
- }`, "utf-8");
209
- }
210
- if (!existsSync(nitro.graphql.serverDir)) mkdirSync(nitro.graphql.serverDir, { recursive: true });
211
- if (!existsSync(join(nitro.graphql.serverDir, "schema.ts"))) writeFileSync(join(nitro.graphql.serverDir, "schema.ts"), `export default defineSchema({
259
+ }`, "graphql.config.ts");
260
+ const serverSchemaPath = resolveFilePath(scaffoldConfig.serverSchema, scaffoldConfig.enabled, true, "{serverGraphql}/schema.ts", placeholders);
261
+ const serverConfigPath = resolveFilePath(scaffoldConfig.serverConfig, scaffoldConfig.enabled, true, "{serverGraphql}/config.ts", placeholders);
262
+ const serverContextPath = resolveFilePath(scaffoldConfig.serverContext, scaffoldConfig.enabled, true, "{serverGraphql}/context.ts", placeholders);
263
+ if (serverSchemaPath || serverConfigPath || serverContextPath) {
264
+ if (!existsSync(nitro.graphql.serverDir)) mkdirSync(nitro.graphql.serverDir, { recursive: true });
265
+ }
266
+ if (serverSchemaPath) writeFileIfNotExists(serverSchemaPath, `export default defineSchema({
212
267
 
213
268
  })
214
- `, "utf-8");
215
- 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
269
+ `, "server schema.ts");
270
+ if (serverConfigPath) writeFileIfNotExists(serverConfigPath, `// Example GraphQL config file please change it to your needs
216
271
  // import * as tables from '../drizzle/schema/index'
217
272
  // import { useDatabase } from '../utils/useDb'
218
273
 
@@ -227,8 +282,8 @@ export default defineGraphQLConfig({
227
282
  // }
228
283
  // },
229
284
  })
230
- `, "utf-8");
231
- if (!existsSync(join(nitro.graphql.serverDir, "context.ts"))) writeFileSync(join(nitro.graphql.serverDir, "context.ts"), `// Example context definition - please change it to your needs
285
+ `, "server config.ts");
286
+ if (serverContextPath) writeFileIfNotExists(serverContextPath, `// Example context definition - please change it to your needs
232
287
  // import type { Database } from '../utils/useDb'
233
288
 
234
289
  declare module 'h3' {
@@ -243,11 +298,12 @@ declare module 'h3' {
243
298
  // }
244
299
  // }
245
300
  }
246
- }`, "utf-8");
247
- if (existsSync(join(nitro.graphql.serverDir, "context.d.ts"))) {
248
- consola.warn("nitro-graphql: Found context.d.ts file. Please rename it to context.ts for the new structure.");
249
- consola.info("The context file should now be context.ts instead of context.d.ts");
250
- }
301
+ }`, "server context.ts");
302
+ if (existsSync(join(nitro.graphql.serverDir, "context.d.ts"))) {
303
+ consola.warn("nitro-graphql: Found context.d.ts file. Please rename it to context.ts for the new structure.");
304
+ consola.info("The context file should now be context.ts instead of context.d.ts");
305
+ }
306
+ } else consola.info("[nitro-graphql] Scaffold file generation is disabled (library mode)");
251
307
  }
252
308
  });
253
309
 
package/dist/rollup.js CHANGED
@@ -12,6 +12,7 @@ async function rollupConfig(app) {
12
12
  virtualDirectives(app);
13
13
  getGraphQLConfig(app);
14
14
  virtualModuleConfig(app);
15
+ virtualDebugInfo(app);
15
16
  app.hooks.hook("rollup:before", (nitro, rollupConfig$1) => {
16
17
  rollupConfig$1.plugins = rollupConfig$1.plugins || [];
17
18
  const { include = /\.(graphql|gql)$/i, exclude, validate = false } = app.options.graphql?.loader || {};
@@ -53,14 +54,27 @@ function virtualSchemas(app) {
53
54
  };
54
55
  app.options.virtual ??= {};
55
56
  app.options.virtual["#nitro-internal-virtual/server-schemas"] = () => {
56
- const imports = getSchemas();
57
- return `
58
- ${imports.map((handler) => `import ${getImportId(handler)} from '${handler}';`).join("\n")}
57
+ try {
58
+ const imports = getSchemas();
59
+ if (imports.length === 0) {
60
+ if (app.options.dev) app.logger.warn("[nitro-graphql] No schemas found. Virtual module will export empty array.");
61
+ return "export const schemas = []";
62
+ }
63
+ const importStatements = imports.map((handler) => `import ${getImportId(handler)} from '${handler}';`);
64
+ const schemaArray = imports.map((h) => `{ def: ${getImportId(h)} }`);
65
+ const code = `
66
+ ${importStatements.join("\n")}
59
67
 
60
68
  export const schemas = [
61
- ${imports.map((h) => `{ def: ${getImportId(h)} }`).join(",\n")}
69
+ ${schemaArray.join(",\n")}
62
70
  ];
63
71
  `;
72
+ if (app.options.dev) app.logger.success(`[nitro-graphql] Generated virtual schema module: ${imports.length} schema(s)`);
73
+ return code;
74
+ } catch (error) {
75
+ app.logger.error("[nitro-graphql] Failed to generate virtual schema module:", error);
76
+ return "export const schemas = []";
77
+ }
64
78
  };
65
79
  }
66
80
  function virtualResolvers(app) {
@@ -69,18 +83,48 @@ function virtualResolvers(app) {
69
83
  };
70
84
  app.options.virtual ??= {};
71
85
  app.options.virtual["#nitro-internal-virtual/server-resolvers"] = () => {
72
- const imports = getResolvers();
73
- const importsContent = [...imports.map(({ specifier, imports: imports$1, options }) => {
74
- return genImport(specifier, imports$1, options);
75
- })];
76
- const content = [
77
- "export const resolvers = [",
78
- imports.map(({ imports: imports$1 }) => imports$1.map((i) => `{ resolver: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n"),
79
- "]",
80
- ""
81
- ];
82
- content.unshift(...importsContent);
83
- return content.join("\n");
86
+ try {
87
+ const imports = getResolvers();
88
+ if (imports.length === 0) {
89
+ if (app.options.dev) app.logger.warn("[nitro-graphql] No resolvers found. Virtual module will export empty array.");
90
+ return "export const resolvers = []";
91
+ }
92
+ const importsContent = [];
93
+ const invalidImports = [];
94
+ for (const { specifier, imports: importList, options } of imports) try {
95
+ if (!importList || importList.length === 0) {
96
+ invalidImports.push(`${specifier}: No exports found`);
97
+ continue;
98
+ }
99
+ const importCode = genImport(specifier, importList, options);
100
+ importsContent.push(importCode);
101
+ } catch (error) {
102
+ const message = error instanceof Error ? error.message : String(error);
103
+ invalidImports.push(`${specifier}: ${message}`);
104
+ if (app.options.dev) app.logger.error(`[nitro-graphql] Failed to generate import for ${specifier}:`, error);
105
+ }
106
+ if (invalidImports.length > 0 && app.options.dev) {
107
+ app.logger.warn("[nitro-graphql] Some resolver imports could not be generated:");
108
+ for (const msg of invalidImports) app.logger.warn(` - ${msg}`);
109
+ }
110
+ const data = imports.map(({ imports: importList }) => importList.map((i) => `{ resolver: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
111
+ const code = [
112
+ ...importsContent,
113
+ "",
114
+ "export const resolvers = [",
115
+ data,
116
+ "]",
117
+ ""
118
+ ].join("\n");
119
+ if (app.options.dev) {
120
+ const totalExports = imports.reduce((sum, r) => sum + r.imports.length, 0);
121
+ app.logger.success(`[nitro-graphql] Generated virtual resolver module: ${totalExports} export(s) from ${imports.length} file(s)`);
122
+ }
123
+ return code;
124
+ } catch (error) {
125
+ app.logger.error("[nitro-graphql] Failed to generate virtual resolver module:", error);
126
+ return "export const resolvers = []";
127
+ }
84
128
  };
85
129
  }
86
130
  function virtualDirectives(app) {
@@ -89,18 +133,45 @@ function virtualDirectives(app) {
89
133
  };
90
134
  app.options.virtual ??= {};
91
135
  app.options.virtual["#nitro-internal-virtual/server-directives"] = () => {
92
- const imports = getDirectives();
93
- const importsContent = [...imports.map(({ specifier, imports: imports$1, options }) => {
94
- return genImport(specifier, imports$1, options);
95
- })];
96
- const content = [
97
- "export const directives = [",
98
- imports.map(({ imports: imports$1 }) => imports$1.map((i) => `{ directive: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n"),
99
- "]",
100
- ""
101
- ];
102
- content.unshift(...importsContent);
103
- return content.join("\n");
136
+ try {
137
+ const imports = getDirectives();
138
+ if (imports.length === 0) return "export const directives = []";
139
+ const importsContent = [];
140
+ const invalidImports = [];
141
+ for (const { specifier, imports: importList, options } of imports) try {
142
+ if (!importList || importList.length === 0) {
143
+ invalidImports.push(`${specifier}: No exports found`);
144
+ continue;
145
+ }
146
+ const importCode = genImport(specifier, importList, options);
147
+ importsContent.push(importCode);
148
+ } catch (error) {
149
+ const message = error instanceof Error ? error.message : String(error);
150
+ invalidImports.push(`${specifier}: ${message}`);
151
+ if (app.options.dev) app.logger.error(`[nitro-graphql] Failed to generate import for directive ${specifier}:`, error);
152
+ }
153
+ if (invalidImports.length > 0 && app.options.dev) {
154
+ app.logger.warn("[nitro-graphql] Some directive imports could not be generated:");
155
+ for (const msg of invalidImports) app.logger.warn(` - ${msg}`);
156
+ }
157
+ const data = imports.map(({ imports: importList }) => importList.map((i) => `{ directive: ${i.as} }`).join(",\n")).filter(Boolean).join(",\n");
158
+ const code = [
159
+ ...importsContent,
160
+ "",
161
+ "export const directives = [",
162
+ data,
163
+ "]",
164
+ ""
165
+ ].join("\n");
166
+ if (app.options.dev) {
167
+ const totalExports = imports.reduce((sum, d) => sum + d.imports.length, 0);
168
+ app.logger.success(`[nitro-graphql] Generated virtual directive module: ${totalExports} directive(s) from ${imports.length} file(s)`);
169
+ }
170
+ return code;
171
+ } catch (error) {
172
+ app.logger.error("[nitro-graphql] Failed to generate virtual directive module:", error);
173
+ return "export const directives = []";
174
+ }
104
175
  };
105
176
  }
106
177
  function getGraphQLConfig(app) {
@@ -120,6 +191,60 @@ function virtualModuleConfig(app) {
120
191
  return `export const moduleConfig = ${JSON.stringify(moduleConfig, null, 2)};`;
121
192
  };
122
193
  }
194
+ function virtualDebugInfo(app) {
195
+ app.options.virtual ??= {};
196
+ app.options.virtual["#nitro-internal-virtual/debug-info"] = () => {
197
+ const virtualModuleCodes = {};
198
+ try {
199
+ const schemasGenerator = app.options.virtual["#nitro-internal-virtual/server-schemas"];
200
+ if (schemasGenerator && typeof schemasGenerator === "function") virtualModuleCodes["server-schemas"] = schemasGenerator();
201
+ } catch (error) {
202
+ virtualModuleCodes["server-schemas"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
203
+ }
204
+ try {
205
+ const resolversGenerator = app.options.virtual["#nitro-internal-virtual/server-resolvers"];
206
+ if (resolversGenerator && typeof resolversGenerator === "function") virtualModuleCodes["server-resolvers"] = resolversGenerator();
207
+ } catch (error) {
208
+ virtualModuleCodes["server-resolvers"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
209
+ }
210
+ try {
211
+ const directivesGenerator = app.options.virtual["#nitro-internal-virtual/server-directives"];
212
+ if (directivesGenerator && typeof directivesGenerator === "function") virtualModuleCodes["server-directives"] = directivesGenerator();
213
+ } catch (error) {
214
+ virtualModuleCodes["server-directives"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
215
+ }
216
+ try {
217
+ const moduleConfigGenerator = app.options.virtual["#nitro-internal-virtual/module-config"];
218
+ if (moduleConfigGenerator && typeof moduleConfigGenerator === "function") virtualModuleCodes["module-config"] = moduleConfigGenerator();
219
+ } catch (error) {
220
+ virtualModuleCodes["module-config"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
221
+ }
222
+ try {
223
+ const graphqlConfigGenerator = app.options.virtual["#nitro-internal-virtual/graphql-config"];
224
+ if (graphqlConfigGenerator && typeof graphqlConfigGenerator === "function") virtualModuleCodes["graphql-config"] = graphqlConfigGenerator();
225
+ } catch (error) {
226
+ virtualModuleCodes["graphql-config"] = `// Error generating: ${error instanceof Error ? error.message : String(error)}`;
227
+ }
228
+ const debugInfo = {
229
+ isDev: app.options.dev,
230
+ framework: app.options.framework.name,
231
+ graphqlFramework: app.options.graphql?.framework,
232
+ federation: app.options.graphql?.federation,
233
+ scanned: {
234
+ schemas: app.scanSchemas?.length || 0,
235
+ schemaFiles: app.scanSchemas || [],
236
+ resolvers: app.scanResolvers?.length || 0,
237
+ resolverFiles: app.scanResolvers || [],
238
+ directives: app.scanDirectives?.length || 0,
239
+ directiveFiles: app.scanDirectives || [],
240
+ documents: app.scanDocuments?.length || 0,
241
+ documentFiles: app.scanDocuments || []
242
+ },
243
+ virtualModules: virtualModuleCodes
244
+ };
245
+ return `export const debugInfo = ${JSON.stringify(debugInfo, null, 2)};`;
246
+ };
247
+ }
123
248
 
124
249
  //#endregion
125
250
  export { rollupConfig };
@@ -1,6 +1,6 @@
1
- import * as h31 from "h3";
1
+ import * as h35 from "h3";
2
2
 
3
3
  //#region src/routes/apollo-server.d.ts
4
- declare const _default: h31.EventHandler<h31.EventHandlerRequest, Promise<any>>;
4
+ declare const _default: h35.EventHandler<h35.EventHandlerRequest, Promise<any>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -26,8 +26,7 @@ async function loadFederationSupport() {
26
26
  }
27
27
  async function createMergedSchema() {
28
28
  try {
29
- const mergedSchemas = schemas.map((schema$1) => schema$1.def).join("\n\n");
30
- const typeDefs = mergeTypeDefs([mergedSchemas], {
29
+ const typeDefs = mergeTypeDefs([schemas.map((schema$1) => schema$1.def).join("\n\n")], {
31
30
  throwOnConflict: true,
32
31
  commentDescriptions: true,
33
32
  sort: true
@@ -37,13 +36,11 @@ async function createMergedSchema() {
37
36
  let schema;
38
37
  if (federationEnabled) {
39
38
  const buildSubgraph = await loadFederationSupport();
40
- if (buildSubgraph) {
41
- const typeDefsDoc = typeof typeDefs === "string" ? parse(typeDefs) : typeDefs;
42
- schema = buildSubgraph({
43
- typeDefs: typeDefsDoc,
44
- resolvers: mergedResolvers
45
- });
46
- } else {
39
+ if (buildSubgraph) schema = buildSubgraph({
40
+ typeDefs: typeof typeDefs === "string" ? parse(typeDefs) : typeDefs,
41
+ resolvers: mergedResolvers
42
+ });
43
+ else {
47
44
  console.warn("Federation enabled but @apollo/subgraph not available, falling back to regular schema");
48
45
  schema = makeExecutableSchema({
49
46
  typeDefs,
@@ -67,9 +64,8 @@ let apolloServer = null;
67
64
  let serverStarted = false;
68
65
  async function createApolloServer() {
69
66
  if (!apolloServer) {
70
- const schema = await createMergedSchema();
71
67
  apolloServer = new ApolloServer(defu({
72
- schema,
68
+ schema: await createMergedSchema(),
73
69
  introspection: true,
74
70
  plugins: [ApolloServerPluginLandingPageLocalDefault({ embed: true })]
75
71
  }, importedConfig));
@@ -83,8 +79,7 @@ async function createApolloServer() {
83
79
  let serverPromise = null;
84
80
  var apollo_server_default = defineEventHandler(async (event) => {
85
81
  if (!serverPromise) serverPromise = createApolloServer();
86
- const server = await serverPromise;
87
- return startServerAndCreateH3Handler(server, {
82
+ return startServerAndCreateH3Handler(await serverPromise, {
88
83
  context: async () => ({ event }),
89
84
  serverAlreadyStarted: true
90
85
  })(event);
@@ -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.EventHandler<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: any;
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: any;
56
+ };
57
+ 'module-config': any;
58
+ };
59
+ }>>;
60
+ //#endregion
61
+ export { _default as default };