nitro-graphql 2.0.0-beta.2 → 2.0.0-beta.20

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.
Files changed (64) hide show
  1. package/README.md +855 -5
  2. package/dist/ecosystem/nuxt.mjs +109 -0
  3. package/dist/index.d.mts +12 -0
  4. package/dist/index.mjs +16 -0
  5. package/dist/rollup.d.mts +12 -0
  6. package/dist/rollup.mjs +282 -0
  7. package/dist/routes/apollo-server.d.mts +6 -0
  8. package/dist/routes/{apollo-server.js → apollo-server.mjs} +5 -5
  9. package/dist/routes/debug.d.mts +61 -0
  10. package/dist/routes/debug.mjs +445 -0
  11. package/dist/routes/graphql-yoga.d.mts +6 -0
  12. package/dist/routes/{graphql-yoga.js → graphql-yoga.mjs} +5 -5
  13. package/dist/routes/health.d.mts +10 -0
  14. package/dist/routes/{health.js → health.mjs} +1 -0
  15. package/dist/setup.d.mts +11 -0
  16. package/dist/setup.mjs +390 -0
  17. package/dist/types/index.d.mts +246 -0
  18. package/dist/utils/{apollo.js → apollo.mjs} +2 -2
  19. package/dist/utils/{client-codegen.d.ts → client-codegen.d.mts} +3 -3
  20. package/dist/utils/{client-codegen.js → client-codegen.mjs} +4 -4
  21. package/dist/utils/file-generator.d.mts +37 -0
  22. package/dist/utils/file-generator.mjs +72 -0
  23. package/dist/utils/{index.d.ts → index.d.mts} +2 -2
  24. package/dist/utils/{index.js → index.mjs} +63 -35
  25. package/dist/utils/path-resolver.d.mts +70 -0
  26. package/dist/utils/path-resolver.mjs +127 -0
  27. package/dist/utils/{server-codegen.d.ts → server-codegen.d.mts} +1 -1
  28. package/dist/utils/{server-codegen.js → server-codegen.mjs} +1 -1
  29. package/dist/utils/{type-generation.js → type-generation.mjs} +153 -42
  30. package/dist/virtual/debug-info.d.mts +9 -0
  31. package/dist/virtual/debug-info.mjs +26 -0
  32. package/dist/virtual/graphql-config.d.mts +9 -0
  33. package/dist/virtual/graphql-config.mjs +10 -0
  34. package/dist/virtual/module-config.d.mts +9 -0
  35. package/dist/virtual/module-config.mjs +10 -0
  36. package/dist/virtual/server-directives.d.mts +11 -0
  37. package/dist/virtual/server-directives.mjs +10 -0
  38. package/dist/virtual/server-resolvers.d.mts +11 -0
  39. package/dist/virtual/server-resolvers.mjs +10 -0
  40. package/dist/virtual/server-schemas.d.mts +11 -0
  41. package/dist/virtual/server-schemas.mjs +10 -0
  42. package/dist/vite.d.mts +27 -0
  43. package/dist/vite.mjs +49 -0
  44. package/package.json +72 -58
  45. package/dist/ecosystem/nuxt.js +0 -67
  46. package/dist/index.d.ts +0 -8
  47. package/dist/index.js +0 -264
  48. package/dist/rollup.js +0 -114
  49. package/dist/routes/apollo-server.d.ts +0 -6
  50. package/dist/routes/graphql-yoga.d.ts +0 -6
  51. package/dist/routes/health.d.ts +0 -6
  52. package/dist/types/index.d.ts +0 -128
  53. /package/dist/ecosystem/{nuxt.d.ts → nuxt.d.mts} +0 -0
  54. /package/dist/graphql/{index.d.ts → index.d.mts} +0 -0
  55. /package/dist/graphql/{index.js → index.mjs} +0 -0
  56. /package/dist/graphql/{server.d.ts → server.d.mts} +0 -0
  57. /package/dist/graphql/{server.js → server.mjs} +0 -0
  58. /package/dist/types/{standard-schema.d.ts → standard-schema.d.mts} +0 -0
  59. /package/dist/utils/{apollo.d.ts → apollo.d.mts} +0 -0
  60. /package/dist/utils/{define.d.ts → define.d.mts} +0 -0
  61. /package/dist/utils/{define.js → define.mjs} +0 -0
  62. /package/dist/utils/{directive-parser.d.ts → directive-parser.d.mts} +0 -0
  63. /package/dist/utils/{directive-parser.js → directive-parser.mjs} +0 -0
  64. /package/dist/utils/{type-generation.d.ts → type-generation.d.mts} +0 -0
@@ -165,7 +165,7 @@ async function loadGraphQLDocuments(patterns) {
165
165
  else throw e;
166
166
  }
167
167
  }
168
- async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, outputPath, serviceName) {
168
+ async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, outputPath, serviceName, virtualTypesPath) {
169
169
  if (docs.length === 0 && !serviceName) {
170
170
  consola$1.info("No client GraphQL files found. Skipping client type generation.");
171
171
  return false;
@@ -252,7 +252,7 @@ export function getSdk(requester: Requester): Sdk {
252
252
  typescriptOperations: { plugin: plugin$2 }
253
253
  }
254
254
  });
255
- const typesPath = serviceName ? `#graphql/client/${serviceName}` : "#graphql/client";
255
+ const typesPath = virtualTypesPath || (serviceName ? `#graphql/client/${serviceName}` : "#graphql/client");
256
256
  const sdkOutput = await preset.buildGeneratesSection({
257
257
  baseOutputDir: outputPath || "client-types.generated.ts",
258
258
  schema: parse(printSchemaWithDirectives(schema)),
@@ -282,8 +282,8 @@ export function getSdk(requester: Requester): Sdk {
282
282
  /**
283
283
  * Generate client types for external GraphQL service
284
284
  */
285
- async function generateExternalClientTypes(service, schema, docs) {
286
- return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name);
285
+ async function generateExternalClientTypes(service, schema, docs, virtualTypesPath) {
286
+ return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name, virtualTypesPath);
287
287
  }
288
288
 
289
289
  //#endregion
@@ -0,0 +1,37 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/utils/file-generator.d.ts
4
+
5
+ /**
6
+ * Safely write a file to disk, creating parent directories if needed
7
+ */
8
+ declare function writeFile(filePath: string, content: string, description?: string): void;
9
+ /**
10
+ * Write a file only if it doesn't already exist
11
+ * Returns true if file was created, false if it already existed
12
+ */
13
+ declare function writeFileIfNotExists(filePath: string, content: string, description?: string): boolean;
14
+ /**
15
+ * Write a file and always overwrite (used for generated files like SDK)
16
+ * This is for files that are auto-generated and should be updated on every build
17
+ */
18
+ declare function writeGeneratedFile(filePath: string, content: string, description?: string): void;
19
+ /**
20
+ * Check if a path is configured and should be generated
21
+ * Returns the resolved path if should generate, null otherwise
22
+ */
23
+ declare function getGenerationPath(resolvedPath: string | null, description?: string): string | null;
24
+ /**
25
+ * Log skipped file generation (helpful for debugging library mode)
26
+ */
27
+ declare function logSkipped(fileName: string, reason?: string): void;
28
+ /**
29
+ * Log generated file path
30
+ */
31
+ declare function logGenerated(fileName: string, path: string): void;
32
+ /**
33
+ * Validate that a Nitro instance has the required GraphQL configuration
34
+ */
35
+ declare function validateGraphQLConfig(nitro: Nitro): boolean;
36
+ //#endregion
37
+ export { getGenerationPath, logGenerated, logSkipped, validateGraphQLConfig, writeFile, writeFileIfNotExists, writeGeneratedFile };
@@ -0,0 +1,72 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import consola from "consola";
3
+ import { dirname } from "pathe";
4
+
5
+ //#region src/utils/file-generator.ts
6
+ /**
7
+ * Safely write a file to disk, creating parent directories if needed
8
+ */
9
+ function writeFile(filePath, content, description) {
10
+ try {
11
+ const dir = dirname(filePath);
12
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
13
+ writeFileSync(filePath, content, "utf-8");
14
+ if (description) consola.success(`[nitro-graphql] Generated: ${description}`);
15
+ } catch (error) {
16
+ consola.error(`[nitro-graphql] Failed to write file: ${filePath}`, error);
17
+ throw error;
18
+ }
19
+ }
20
+ /**
21
+ * Write a file only if it doesn't already exist
22
+ * Returns true if file was created, false if it already existed
23
+ */
24
+ function writeFileIfNotExists(filePath, content, description) {
25
+ if (existsSync(filePath)) return false;
26
+ writeFile(filePath, content, description);
27
+ return true;
28
+ }
29
+ /**
30
+ * Write a file and always overwrite (used for generated files like SDK)
31
+ * This is for files that are auto-generated and should be updated on every build
32
+ */
33
+ function writeGeneratedFile(filePath, content, description) {
34
+ writeFile(filePath, content, description);
35
+ }
36
+ /**
37
+ * Check if a path is configured and should be generated
38
+ * Returns the resolved path if should generate, null otherwise
39
+ */
40
+ function getGenerationPath(resolvedPath, description) {
41
+ if (!resolvedPath) {
42
+ if (description) consola.debug(`[nitro-graphql] Skipping generation: ${description} (disabled in config)`);
43
+ return null;
44
+ }
45
+ return resolvedPath;
46
+ }
47
+ /**
48
+ * Log skipped file generation (helpful for debugging library mode)
49
+ */
50
+ function logSkipped(fileName, reason) {
51
+ const message = reason ? `Skipped ${fileName}: ${reason}` : `Skipped ${fileName}`;
52
+ consola.debug(`[nitro-graphql] ${message}`);
53
+ }
54
+ /**
55
+ * Log generated file path
56
+ */
57
+ function logGenerated(fileName, path) {
58
+ consola.info(`[nitro-graphql] Generated ${fileName} at: ${path}`);
59
+ }
60
+ /**
61
+ * Validate that a Nitro instance has the required GraphQL configuration
62
+ */
63
+ function validateGraphQLConfig(nitro) {
64
+ if (!nitro.options.graphql?.framework) {
65
+ consola.warn("[nitro-graphql] No GraphQL framework specified. Some features may not work correctly.");
66
+ return false;
67
+ }
68
+ return true;
69
+ }
70
+
71
+ //#endregion
72
+ export { getGenerationPath, logGenerated, logSkipped, validateGraphQLConfig, writeFile, writeFileIfNotExists, writeGeneratedFile };
@@ -1,5 +1,5 @@
1
- import { GenImport } from "../types/index.js";
2
- import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.js";
1
+ import { GenImport } from "../types/index.mjs";
2
+ import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
3
3
  import { Nitro } from "nitro/types";
4
4
 
5
5
  //#region src/utils/index.d.ts
@@ -1,4 +1,4 @@
1
- import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.js";
1
+ import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
2
2
  import { join, relative } from "pathe";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { hash } from "ohash";
@@ -65,50 +65,78 @@ async function scanResolvers(nitro) {
65
65
  return true;
66
66
  });
67
67
  const exportName = [];
68
- for (const file of files) {
68
+ const VALID_DEFINE_FUNCTIONS = [
69
+ "defineResolver",
70
+ "defineQuery",
71
+ "defineMutation",
72
+ "defineType",
73
+ "defineSubscription",
74
+ "defineDirective"
75
+ ];
76
+ for (const file of files) try {
69
77
  const fileContent = await readFile(file.fullPath, "utf-8");
70
78
  const parsed = await parseAsync(file.fullPath, fileContent);
71
79
  const exports = {
72
80
  imports: [],
73
81
  specifier: file.fullPath
74
82
  };
75
- for (const node of parsed.program.body) if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
76
- for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
77
- if (decl.init && decl.init.type === "CallExpression") {
78
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineResolver") exports.imports.push({
79
- name: decl.id.name,
80
- type: "resolver",
81
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
82
- });
83
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineQuery") exports.imports.push({
84
- name: decl.id.name,
85
- type: "query",
86
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
87
- });
88
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineMutation") exports.imports.push({
89
- name: decl.id.name,
90
- type: "mutation",
91
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
92
- });
93
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineType") exports.imports.push({
94
- name: decl.id.name,
95
- type: "type",
96
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
97
- });
98
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineSubscription") exports.imports.push({
99
- name: decl.id.name,
100
- type: "subscription",
101
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
102
- });
103
- if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineDirective") exports.imports.push({
104
- name: decl.id.name,
105
- type: "directive",
106
- as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
107
- });
83
+ let hasDefaultExport = false;
84
+ let hasNamedExport = false;
85
+ const namedExports = [];
86
+ for (const node of parsed.program.body) {
87
+ if (node.type === "ExportDefaultDeclaration") hasDefaultExport = true;
88
+ if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
89
+ for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
90
+ hasNamedExport = true;
91
+ namedExports.push(decl.id.name);
92
+ if (decl.init && decl.init.type === "CallExpression") {
93
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineResolver") exports.imports.push({
94
+ name: decl.id.name,
95
+ type: "resolver",
96
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
97
+ });
98
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineQuery") exports.imports.push({
99
+ name: decl.id.name,
100
+ type: "query",
101
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
102
+ });
103
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineMutation") exports.imports.push({
104
+ name: decl.id.name,
105
+ type: "mutation",
106
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
107
+ });
108
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineType") exports.imports.push({
109
+ name: decl.id.name,
110
+ type: "type",
111
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
112
+ });
113
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineSubscription") exports.imports.push({
114
+ name: decl.id.name,
115
+ type: "subscription",
116
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
117
+ });
118
+ if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineDirective") exports.imports.push({
119
+ name: decl.id.name,
120
+ type: "directive",
121
+ as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
122
+ });
123
+ }
108
124
  }
109
125
  }
110
126
  }
127
+ if (nitro.options.dev) {
128
+ const relPath = relative(nitro.options.rootDir, file.fullPath);
129
+ if (hasDefaultExport && !hasNamedExport) nitro.logger.warn(`[nitro-graphql] ${relPath}: Using default export instead of named export. Resolvers must use named exports like "export const myResolver = defineQuery(...)". Default exports are not detected.`);
130
+ if (exports.imports.length === 0 && hasNamedExport) {
131
+ const validFunctions = VALID_DEFINE_FUNCTIONS.join(", ");
132
+ nitro.logger.warn(`[nitro-graphql] ${relPath}: File has named exports [${namedExports.join(", ")}] but none use the required define functions (${validFunctions}). Exports will not be registered.`);
133
+ }
134
+ if (!hasDefaultExport && !hasNamedExport) nitro.logger.warn(`[nitro-graphql] ${relPath}: No exports found. Resolver files must export resolvers using defineResolver, defineQuery, defineMutation, etc.`);
135
+ }
111
136
  if (exports.imports.length > 0) exportName.push(exports);
137
+ } catch (error) {
138
+ const relPath = relative(nitro.options.rootDir, file.fullPath);
139
+ nitro.logger.error(`[nitro-graphql] Failed to parse resolver file ${relPath}:`, error);
112
140
  }
113
141
  return exportName;
114
142
  }
@@ -0,0 +1,70 @@
1
+ import { ClientUtilsConfig, FileGenerationConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "../types/index.mjs";
2
+ import { Nitro } from "nitro/types";
3
+
4
+ //#region src/utils/path-resolver.d.ts
5
+
6
+ /**
7
+ * Placeholder values for path resolution
8
+ */
9
+ interface PathPlaceholders {
10
+ serviceName?: string;
11
+ buildDir: string;
12
+ rootDir: string;
13
+ framework: 'nuxt' | 'nitro';
14
+ typesDir: string;
15
+ serverGraphql: string;
16
+ clientGraphql: string;
17
+ }
18
+ /**
19
+ * Replace placeholders in a path string
20
+ * Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {serverGraphql}, {clientGraphql}
21
+ */
22
+ declare function replacePlaceholders(path: string, placeholders: PathPlaceholders): string;
23
+ /**
24
+ * Get default paths based on framework and user configuration
25
+ */
26
+ declare function getDefaultPaths(nitro: Nitro): Required<PathPlaceholders>;
27
+ /**
28
+ * Check if a file should be generated based on config
29
+ * Returns: true if should generate, false if should skip
30
+ */
31
+ declare function shouldGenerateFile(config: FileGenerationConfig | undefined, categoryEnabled: boolean | undefined, topLevelEnabled: boolean): boolean;
32
+ /**
33
+ * Resolve the file path based on configuration
34
+ * Returns: resolved absolute path or null if file should not be generated
35
+ */
36
+ declare function resolveFilePath(config: FileGenerationConfig | undefined, categoryEnabled: boolean | undefined, topLevelEnabled: boolean, defaultPath: string, placeholders: PathPlaceholders): string | null;
37
+ /**
38
+ * Check if scaffold files should be generated (category-level check)
39
+ */
40
+ declare function shouldGenerateScaffold(nitro: Nitro): boolean;
41
+ /**
42
+ * Get scaffold configuration (handles false case)
43
+ */
44
+ declare function getScaffoldConfig(nitro: Nitro): ScaffoldConfig;
45
+ /**
46
+ * Check if client utilities should be generated (category-level check)
47
+ */
48
+ declare function shouldGenerateClientUtils(nitro: Nitro): boolean;
49
+ /**
50
+ * Get client utilities configuration (handles false case)
51
+ */
52
+ declare function getClientUtilsConfig(nitro: Nitro): ClientUtilsConfig;
53
+ /**
54
+ * Check if SDK files should be generated (category-level check)
55
+ */
56
+ declare function shouldGenerateSDK(nitro: Nitro): boolean;
57
+ /**
58
+ * Get SDK configuration (handles false case)
59
+ */
60
+ declare function getSdkConfig(nitro: Nitro): SdkConfig;
61
+ /**
62
+ * Check if type files should be generated (category-level check)
63
+ */
64
+ declare function shouldGenerateTypes(nitro: Nitro): boolean;
65
+ /**
66
+ * Get types configuration (handles false case)
67
+ */
68
+ declare function getTypesConfig(nitro: Nitro): TypesConfig;
69
+ //#endregion
70
+ export { PathPlaceholders, getClientUtilsConfig, getDefaultPaths, getScaffoldConfig, getSdkConfig, getTypesConfig, replacePlaceholders, resolveFilePath, shouldGenerateClientUtils, shouldGenerateFile, shouldGenerateSDK, shouldGenerateScaffold, shouldGenerateTypes };
@@ -0,0 +1,127 @@
1
+ import { isAbsolute, resolve } from "pathe";
2
+
3
+ //#region src/utils/path-resolver.ts
4
+ /**
5
+ * Replace placeholders in a path string
6
+ * Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {serverGraphql}, {clientGraphql}
7
+ */
8
+ function replacePlaceholders(path, placeholders) {
9
+ return path.replace(/\{serviceName\}/g, placeholders.serviceName || "default").replace(/\{buildDir\}/g, placeholders.buildDir).replace(/\{rootDir\}/g, placeholders.rootDir).replace(/\{framework\}/g, placeholders.framework).replace(/\{typesDir\}/g, placeholders.typesDir).replace(/\{serverGraphql\}/g, placeholders.serverGraphql).replace(/\{clientGraphql\}/g, placeholders.clientGraphql);
10
+ }
11
+ /**
12
+ * Get default paths based on framework and user configuration
13
+ */
14
+ function getDefaultPaths(nitro) {
15
+ const isNuxt = nitro.options.framework?.name === "nuxt";
16
+ const rootDir = nitro.options.rootDir;
17
+ const buildDir = nitro.options.buildDir;
18
+ const pathsConfig = nitro.options.graphql?.paths || {};
19
+ const defaultServerGraphql = pathsConfig.serverGraphql || resolve(rootDir, "server", "graphql");
20
+ const defaultClientGraphql = pathsConfig.clientGraphql || resolve(rootDir, isNuxt ? "app/graphql" : "graphql");
21
+ const defaultBuildDir = pathsConfig.buildDir || buildDir;
22
+ const defaultTypesDir = pathsConfig.typesDir || resolve(defaultBuildDir, "types");
23
+ return {
24
+ serviceName: "default",
25
+ buildDir: defaultBuildDir,
26
+ rootDir,
27
+ framework: isNuxt ? "nuxt" : "nitro",
28
+ typesDir: defaultTypesDir,
29
+ serverGraphql: defaultServerGraphql,
30
+ clientGraphql: defaultClientGraphql
31
+ };
32
+ }
33
+ /**
34
+ * Check if a file should be generated based on config
35
+ * Returns: true if should generate, false if should skip
36
+ */
37
+ function shouldGenerateFile(config, categoryEnabled, topLevelEnabled) {
38
+ if (config === false) return false;
39
+ if (config === true || typeof config === "string") return true;
40
+ if (categoryEnabled === false) return false;
41
+ if (categoryEnabled === true) return true;
42
+ return topLevelEnabled;
43
+ }
44
+ /**
45
+ * Resolve the file path based on configuration
46
+ * Returns: resolved absolute path or null if file should not be generated
47
+ */
48
+ function resolveFilePath(config, categoryEnabled, topLevelEnabled, defaultPath, placeholders) {
49
+ if (!shouldGenerateFile(config, categoryEnabled, topLevelEnabled)) return null;
50
+ if (typeof config === "string") {
51
+ const customPath = replacePlaceholders(config, placeholders);
52
+ return isAbsolute(customPath) ? customPath : resolve(placeholders.rootDir, customPath);
53
+ }
54
+ const resolvedDefault = replacePlaceholders(defaultPath, placeholders);
55
+ return resolve(placeholders.rootDir, resolvedDefault);
56
+ }
57
+ /**
58
+ * Check if scaffold files should be generated (category-level check)
59
+ */
60
+ function shouldGenerateScaffold(nitro) {
61
+ const scaffoldConfig = nitro.options.graphql?.scaffold;
62
+ if (scaffoldConfig === false) return false;
63
+ if (scaffoldConfig && scaffoldConfig.enabled === false) return false;
64
+ return true;
65
+ }
66
+ /**
67
+ * Get scaffold configuration (handles false case)
68
+ */
69
+ function getScaffoldConfig(nitro) {
70
+ const scaffoldConfig = nitro.options.graphql?.scaffold;
71
+ if (scaffoldConfig === false) return { enabled: false };
72
+ return scaffoldConfig || {};
73
+ }
74
+ /**
75
+ * Check if client utilities should be generated (category-level check)
76
+ */
77
+ function shouldGenerateClientUtils(nitro) {
78
+ const clientUtilsConfig = nitro.options.graphql?.clientUtils;
79
+ if (clientUtilsConfig === false) return false;
80
+ if (clientUtilsConfig && clientUtilsConfig.enabled === false) return false;
81
+ return true;
82
+ }
83
+ /**
84
+ * Get client utilities configuration (handles false case)
85
+ */
86
+ function getClientUtilsConfig(nitro) {
87
+ const clientUtilsConfig = nitro.options.graphql?.clientUtils;
88
+ if (clientUtilsConfig === false) return { enabled: false };
89
+ return clientUtilsConfig || {};
90
+ }
91
+ /**
92
+ * Check if SDK files should be generated (category-level check)
93
+ */
94
+ function shouldGenerateSDK(nitro) {
95
+ const sdkConfig = nitro.options.graphql?.sdk;
96
+ if (sdkConfig === false) return false;
97
+ if (sdkConfig && sdkConfig.enabled === false) return false;
98
+ return true;
99
+ }
100
+ /**
101
+ * Get SDK configuration (handles false case)
102
+ */
103
+ function getSdkConfig(nitro) {
104
+ const sdkConfig = nitro.options.graphql?.sdk;
105
+ if (sdkConfig === false) return { enabled: false };
106
+ return sdkConfig || {};
107
+ }
108
+ /**
109
+ * Check if type files should be generated (category-level check)
110
+ */
111
+ function shouldGenerateTypes(nitro) {
112
+ const typesConfig = nitro.options.graphql?.types;
113
+ if (typesConfig === false) return false;
114
+ if (typesConfig && typesConfig.enabled === false) return false;
115
+ return true;
116
+ }
117
+ /**
118
+ * Get types configuration (handles false case)
119
+ */
120
+ function getTypesConfig(nitro) {
121
+ const typesConfig = nitro.options.graphql?.types;
122
+ if (typesConfig === false) return { enabled: false };
123
+ return typesConfig || {};
124
+ }
125
+
126
+ //#endregion
127
+ export { getClientUtilsConfig, getDefaultPaths, getScaffoldConfig, getSdkConfig, getTypesConfig, replacePlaceholders, resolveFilePath, shouldGenerateClientUtils, shouldGenerateFile, shouldGenerateSDK, shouldGenerateScaffold, shouldGenerateTypes };
@@ -1,4 +1,4 @@
1
- import { NitroGraphQLOptions } from "../types/index.js";
1
+ import { NitroGraphQLOptions } from "../types/index.mjs";
2
2
  import { GraphQLSchema } from "graphql";
3
3
 
4
4
  //#region src/utils/server-codegen.d.ts
@@ -37,7 +37,7 @@ async function generateTypes(selectFremework, schema, config = {}, outputPath) {
37
37
  },
38
38
  defaultScalarType: "unknown",
39
39
  defaultMapper: `ResolverReturnType<{T}>`,
40
- contextType: "h3#H3Event",
40
+ contextType: "nitro/h3#H3Event",
41
41
  maybeValue: "T | null | undefined",
42
42
  inputMaybeValue: "T | undefined",
43
43
  declarationKind: "interface",