nitro-graphql 2.0.0-beta.72 → 2.0.0-beta.73

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 (187) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/adapter.d.mts +0 -3
  3. package/dist/cli/adapter.mjs +6 -29
  4. package/dist/cli/commands/generate.mjs +2 -2
  5. package/dist/cli/config.d.mts +4 -5
  6. package/dist/cli/config.mjs +3 -1
  7. package/dist/cli/index.d.mts +3 -6
  8. package/dist/cli/index.mjs +1 -1
  9. package/dist/cli/server/graphql-handler.mjs +2 -1
  10. package/dist/cli/server/watcher.mjs +1 -1
  11. package/dist/core/codegen/client.d.mts +4 -27
  12. package/dist/core/codegen/client.mjs +26 -445
  13. package/dist/core/codegen/file-header.d.mts +7 -0
  14. package/dist/core/codegen/file-header.mjs +12 -0
  15. package/dist/core/codegen/index.d.mts +7 -5
  16. package/dist/core/codegen/index.mjs +7 -5
  17. package/dist/core/codegen/{runtime.d.mts → runtime-generator.d.mts} +1 -1
  18. package/dist/core/codegen/{runtime.mjs → runtime-generator.mjs} +1 -1
  19. package/dist/core/codegen/schema-loader.d.mts +2 -7
  20. package/dist/core/codegen/schema-loader.mjs +65 -70
  21. package/dist/core/codegen/server-type-helpers.d.mts +14 -0
  22. package/dist/core/codegen/server-type-helpers.mjs +76 -0
  23. package/dist/core/codegen/server.d.mts +1 -15
  24. package/dist/core/codegen/server.mjs +15 -105
  25. package/dist/core/codegen/subscription-extractor.d.mts +20 -0
  26. package/dist/core/codegen/subscription-extractor.mjs +30 -0
  27. package/dist/core/codegen/vue-subscription-builder.d.mts +10 -0
  28. package/dist/core/codegen/vue-subscription-builder.mjs +351 -0
  29. package/dist/core/constants.d.mts +5 -53
  30. package/dist/core/constants.mjs +13 -54
  31. package/dist/core/create-config.d.mts +31 -0
  32. package/dist/core/create-config.mjs +42 -0
  33. package/dist/core/debug/index.d.mts +2 -2
  34. package/dist/core/debug/index.mjs +2 -2
  35. package/dist/core/debug/template.d.mts +1 -5
  36. package/dist/core/debug/template.mjs +1 -1
  37. package/dist/core/extend/loader.d.mts +0 -1
  38. package/dist/core/extend/loader.mjs +59 -89
  39. package/dist/core/index.d.mts +22 -17
  40. package/dist/core/index.mjs +19 -15
  41. package/dist/core/manifest.mjs +3 -1
  42. package/dist/core/pubsub/index.d.mts +2 -109
  43. package/dist/core/pubsub/index.mjs +1 -145
  44. package/dist/core/pubsub/memory-pubsub.d.mts +109 -0
  45. package/dist/core/pubsub/memory-pubsub.mjs +146 -0
  46. package/dist/core/scanning/ast-scanner.mjs +4 -2
  47. package/dist/core/scanning/directives.mjs +2 -3
  48. package/dist/core/scanning/documents.d.mts +4 -3
  49. package/dist/core/scanning/documents.mjs +1 -1
  50. package/dist/core/scanning/{common.d.mts → file-scanner.d.mts} +1 -1
  51. package/dist/core/scanning/{common.mjs → file-scanner.mjs} +2 -10
  52. package/dist/core/scanning/index.d.mts +3 -3
  53. package/dist/core/scanning/index.mjs +3 -3
  54. package/dist/core/scanning/resolvers.mjs +8 -9
  55. package/dist/core/scanning/schemas.d.mts +1 -5
  56. package/dist/core/scanning/schemas.mjs +2 -24
  57. package/dist/core/schema/builder.d.mts +4 -2
  58. package/dist/core/schema/builder.mjs +4 -2
  59. package/dist/core/schema/index.d.mts +2 -2
  60. package/dist/core/schema/index.mjs +2 -2
  61. package/dist/core/server/apollo.d.mts +20 -0
  62. package/dist/core/server/apollo.mjs +54 -0
  63. package/dist/core/server/index.d.mts +4 -2
  64. package/dist/core/server/index.mjs +3 -2
  65. package/dist/core/server/types.d.mts +7 -14
  66. package/dist/core/server/types.mjs +15 -1
  67. package/dist/core/server/yoga.d.mts +1 -7
  68. package/dist/core/server/yoga.mjs +4 -13
  69. package/dist/core/types/adapter.d.mts +4 -39
  70. package/dist/core/types/codegen.d.mts +22 -45
  71. package/dist/core/types/config.d.mts +33 -121
  72. package/dist/core/types/define.d.mts +8 -5
  73. package/dist/core/types/index.d.mts +5 -4
  74. package/dist/core/types/scanning.d.mts +4 -1
  75. package/dist/core/types/standard-schema.d.mts +64 -0
  76. package/dist/core/utils/directive-parser.d.mts +8 -63
  77. package/dist/core/utils/directive-parser.mjs +114 -166
  78. package/dist/core/utils/file-io.d.mts +1 -5
  79. package/dist/core/utils/file-io.mjs +1 -11
  80. package/dist/core/utils/index.d.mts +5 -4
  81. package/dist/core/utils/index.mjs +6 -5
  82. package/dist/core/utils/logger.d.mts +1 -10
  83. package/dist/core/utils/logger.mjs +1 -19
  84. package/dist/core/utils/ofetch-templates.mjs +3 -4
  85. package/dist/core/utils/runtime.d.mts +1 -30
  86. package/dist/core/utils/runtime.mjs +2 -44
  87. package/dist/core/utils/string.d.mts +10 -0
  88. package/dist/core/utils/string.mjs +12 -0
  89. package/dist/core/watcher/create-watcher.d.mts +103 -0
  90. package/dist/core/watcher/create-watcher.mjs +143 -0
  91. package/dist/core/watcher/index.d.mts +2 -107
  92. package/dist/core/watcher/index.mjs +1 -139
  93. package/dist/define.d.mts +4 -2
  94. package/dist/define.mjs +7 -6
  95. package/dist/index.d.mts +4 -3
  96. package/dist/index.mjs +1 -1
  97. package/dist/nitro/adapter.d.mts +6 -10
  98. package/dist/nitro/adapter.mjs +12 -42
  99. package/dist/nitro/codegen/client-types.d.mts +12 -0
  100. package/dist/nitro/codegen/client-types.mjs +73 -0
  101. package/dist/nitro/codegen/external-types.d.mts +8 -0
  102. package/dist/nitro/codegen/external-types.mjs +47 -0
  103. package/dist/nitro/codegen/index.d.mts +4 -0
  104. package/dist/nitro/codegen/index.mjs +4 -0
  105. package/dist/nitro/codegen/server-types.d.mts +12 -0
  106. package/dist/nitro/codegen/server-types.mjs +81 -0
  107. package/dist/nitro/defaults.d.mts +28 -0
  108. package/dist/nitro/defaults.mjs +34 -0
  109. package/dist/nitro/index.d.mts +11 -3
  110. package/dist/nitro/index.mjs +1 -1
  111. package/dist/nitro/paths.d.mts +3 -2
  112. package/dist/nitro/paths.mjs +13 -9
  113. package/dist/nitro/rollup.mjs +4 -3
  114. package/dist/nitro/routes/_ws-handler.d.mts +6 -0
  115. package/dist/nitro/routes/_ws-handler.mjs +49 -0
  116. package/dist/nitro/routes/apollo-server-ws.d.mts +1 -1
  117. package/dist/nitro/routes/apollo-server-ws.mjs +9 -44
  118. package/dist/nitro/routes/apollo-server.d.mts +1 -1
  119. package/dist/nitro/routes/apollo-server.mjs +16 -55
  120. package/dist/nitro/routes/debug.d.mts +1 -1
  121. package/dist/nitro/routes/debug.mjs +1 -0
  122. package/dist/nitro/routes/graphql-yoga-ws.d.mts +1 -1
  123. package/dist/nitro/routes/graphql-yoga-ws.mjs +6 -44
  124. package/dist/nitro/routes/graphql-yoga.mjs +7 -5
  125. package/dist/nitro/routes/health.mjs +22 -24
  126. package/dist/nitro/setup/extend-loader.d.mts +6 -5
  127. package/dist/nitro/setup/extend-loader.mjs +30 -58
  128. package/dist/nitro/setup/file-watcher.mjs +6 -4
  129. package/dist/nitro/setup/logging.d.mts +1 -8
  130. package/dist/nitro/setup/logging.mjs +7 -22
  131. package/dist/nitro/setup/rollup-integration.mjs +32 -1
  132. package/dist/nitro/setup/scanner.d.mts +8 -43
  133. package/dist/nitro/setup/scanner.mjs +56 -58
  134. package/dist/nitro/setup/security.d.mts +10 -0
  135. package/dist/nitro/setup/security.mjs +17 -0
  136. package/dist/nitro/setup/type-generation.d.mts +13 -0
  137. package/dist/nitro/setup/type-generation.mjs +16 -0
  138. package/dist/nitro/setup.d.mts +4 -3
  139. package/dist/nitro/setup.mjs +87 -74
  140. package/dist/nitro/state.d.mts +32 -0
  141. package/dist/nitro/state.mjs +58 -0
  142. package/dist/nitro/types/augmentation.d.mts +59 -0
  143. package/dist/nitro/types/augmentation.mjs +1 -0
  144. package/dist/nitro/types/config.d.mts +327 -0
  145. package/dist/nitro/types/config.mjs +1 -0
  146. package/dist/nitro/types/define.d.mts +13 -0
  147. package/dist/nitro/types/define.mjs +1 -0
  148. package/dist/nitro/types/index.d.mts +10 -0
  149. package/dist/nitro/types/index.mjs +1 -0
  150. package/dist/nitro/virtual/debug-info.d.mts +9 -0
  151. package/dist/nitro/virtual/debug-info.mjs +35 -0
  152. package/dist/nitro/virtual/graphql-config.d.mts +9 -0
  153. package/dist/nitro/virtual/graphql-config.mjs +33 -0
  154. package/dist/nitro/virtual/index.d.mts +25 -0
  155. package/dist/nitro/virtual/index.mjs +45 -0
  156. package/dist/nitro/virtual/module-config.d.mts +9 -0
  157. package/dist/nitro/virtual/module-config.mjs +10 -0
  158. package/dist/nitro/virtual/pubsub.d.mts +9 -0
  159. package/dist/nitro/virtual/pubsub.mjs +17 -0
  160. package/dist/nitro/virtual/server-directives.d.mts +9 -0
  161. package/dist/nitro/virtual/server-directives.mjs +12 -0
  162. package/dist/nitro/virtual/server-resolvers.d.mts +9 -0
  163. package/dist/nitro/virtual/server-resolvers.mjs +17 -0
  164. package/dist/nitro/virtual/server-schemas.d.mts +9 -0
  165. package/dist/nitro/virtual/server-schemas.mjs +31 -0
  166. package/dist/nitro/virtual/stubs.d.mts +42 -10
  167. package/dist/nitro/virtual/stubs.mjs +0 -5
  168. package/dist/nitro/virtual/utils.d.mts +15 -0
  169. package/dist/nitro/virtual/utils.mjs +26 -0
  170. package/dist/nitro/virtual/validation-schemas.d.mts +9 -0
  171. package/dist/nitro/virtual/validation-schemas.mjs +33 -0
  172. package/native/index.js +52 -52
  173. package/package.json +15 -15
  174. package/dist/cli/commands/index.d.mts +0 -5
  175. package/dist/cli/commands/index.mjs +0 -5
  176. package/dist/core/codegen/plugin.d.mts +0 -19
  177. package/dist/core/codegen/plugin.mjs +0 -29
  178. package/dist/core/config.d.mts +0 -45
  179. package/dist/core/config.mjs +0 -76
  180. package/dist/nitro/codegen.d.mts +0 -18
  181. package/dist/nitro/codegen.mjs +0 -171
  182. package/dist/nitro/config.d.mts +0 -50
  183. package/dist/nitro/config.mjs +0 -55
  184. package/dist/nitro/types.d.mts +0 -549
  185. package/dist/nitro/virtual/generators.d.mts +0 -38
  186. package/dist/nitro/virtual/generators.mjs +0 -190
  187. /package/dist/{nitro/types.mjs → core/types/standard-schema.mjs} +0 -0
@@ -0,0 +1,20 @@
1
+ import { CoreServerOptions } from "./types.mjs";
2
+ import { ApolloServer, BaseContext } from "@apollo/server";
3
+
4
+ //#region src/core/server/apollo.d.ts
5
+ /**
6
+ * Error codes that represent user-facing errors and should not be masked
7
+ * in production. All other error codes are treated as internal and masked.
8
+ */
9
+ declare const APOLLO_USER_FACING_ERROR_CODES: readonly ["BAD_USER_INPUT", "GRAPHQL_VALIDATION_FAILED", "UNAUTHENTICATED", "FORBIDDEN", "BAD_REQUEST"];
10
+ /**
11
+ * Create an Apollo Server instance
12
+ *
13
+ * Follows the same factory pattern as createYogaServer:
14
+ * - Takes CoreServerOptions
15
+ * - Applies security defaults
16
+ * - Merges user config via defu
17
+ */
18
+ declare function createApolloServerInstance(options: CoreServerOptions): Promise<ApolloServer<BaseContext>>;
19
+ //#endregion
20
+ export { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance };
@@ -0,0 +1,54 @@
1
+ import { createMergedSchema } from "../schema/builder.mjs";
2
+ import { resolveSecurityDefaults } from "./types.mjs";
3
+ import defu from "defu";
4
+ import { ApolloServer } from "@apollo/server";
5
+ import { ApolloServerPluginLandingPageDisabled } from "@apollo/server/plugin/disabled";
6
+ import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
7
+ //#region src/core/server/apollo.ts
8
+ /**
9
+ * Error codes that represent user-facing errors and should not be masked
10
+ * in production. All other error codes are treated as internal and masked.
11
+ */
12
+ const APOLLO_USER_FACING_ERROR_CODES = [
13
+ "BAD_USER_INPUT",
14
+ "GRAPHQL_VALIDATION_FAILED",
15
+ "UNAUTHENTICATED",
16
+ "FORBIDDEN",
17
+ "BAD_REQUEST"
18
+ ];
19
+ /**
20
+ * Create an Apollo Server instance
21
+ *
22
+ * Follows the same factory pattern as createYogaServer:
23
+ * - Takes CoreServerOptions
24
+ * - Applies security defaults
25
+ * - Merges user config via defu
26
+ */
27
+ async function createApolloServerInstance(options) {
28
+ const { schemas, resolvers, directives, moduleConfig, security, importedConfig } = options;
29
+ const schema = await createMergedSchema({
30
+ schemas,
31
+ resolvers,
32
+ directives: directives || [],
33
+ moduleConfig
34
+ });
35
+ const securityConfig = resolveSecurityDefaults(security);
36
+ const plugins = securityConfig.playground ? [ApolloServerPluginLandingPageLocalDefault({ embed: true })] : [ApolloServerPluginLandingPageDisabled()];
37
+ const server = new ApolloServer(defu({
38
+ schema,
39
+ introspection: securityConfig.introspection,
40
+ plugins,
41
+ formatError: securityConfig.maskErrors ? (formattedError) => {
42
+ const code = formattedError?.extensions?.code;
43
+ if (code && APOLLO_USER_FACING_ERROR_CODES.includes(code)) return formattedError;
44
+ return {
45
+ message: "Internal server error",
46
+ extensions: { code: "INTERNAL_SERVER_ERROR" }
47
+ };
48
+ } : void 0
49
+ }, importedConfig));
50
+ await server.start();
51
+ return server;
52
+ }
53
+ //#endregion
54
+ export { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance };
@@ -1,4 +1,6 @@
1
+ import { CoreSecurityConfig } from "../types/config.mjs";
1
2
  import { CoreServerInstance, CoreServerOptions, ServerFactory } from "./types.mjs";
3
+ import { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance } from "./apollo.mjs";
2
4
  import { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript } from "./sandbox.mjs";
3
- import { BASE_SCHEMA, apolloSandboxHtml, createYogaServer } from "./yoga.mjs";
4
- export { APOLLO_SANDBOX_CDN, type CoreServerInstance, type CoreServerOptions, type ServerFactory, BASE_SCHEMA as YOGA_BASE_SCHEMA, apolloSandboxHtml, createSandboxResponse, createYogaServer, fetchSandboxScript };
5
+ import { apolloSandboxHtml, createYogaServer } from "./yoga.mjs";
6
+ export { APOLLO_SANDBOX_CDN, APOLLO_USER_FACING_ERROR_CODES, type CoreSecurityConfig, type CoreServerInstance, type CoreServerOptions, type ServerFactory, apolloSandboxHtml, createApolloServerInstance, createSandboxResponse, createYogaServer, fetchSandboxScript };
@@ -1,3 +1,4 @@
1
+ import { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance } from "./apollo.mjs";
1
2
  import { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript } from "./sandbox.mjs";
2
- import { BASE_SCHEMA, apolloSandboxHtml, createYogaServer } from "./yoga.mjs";
3
- export { APOLLO_SANDBOX_CDN, BASE_SCHEMA as YOGA_BASE_SCHEMA, apolloSandboxHtml, createSandboxResponse, createYogaServer, fetchSandboxScript };
3
+ import { apolloSandboxHtml, createYogaServer } from "./yoga.mjs";
4
+ export { APOLLO_SANDBOX_CDN, APOLLO_USER_FACING_ERROR_CODES, apolloSandboxHtml, createApolloServerInstance, createSandboxResponse, createYogaServer, fetchSandboxScript };
@@ -1,20 +1,8 @@
1
+ import { CoreSecurityConfig } from "../types/config.mjs";
1
2
  import { DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition } from "../schema/builder.mjs";
2
3
  import { GraphQLSchema } from "graphql";
3
4
 
4
5
  //#region src/core/server/types.d.ts
5
- /**
6
- * Security configuration for GraphQL server
7
- */
8
- interface CoreSecurityConfig {
9
- /** Enable GraphQL introspection (default: true in dev, false in prod) */
10
- introspection?: boolean;
11
- /** Enable GraphQL playground/sandbox (default: true in dev, false in prod) */
12
- playground?: boolean;
13
- /** Mask error messages in responses (default: false in dev, true in prod) */
14
- maskErrors?: boolean;
15
- /** Disable field suggestions in error messages */
16
- disableSuggestions?: boolean;
17
- }
18
6
  /**
19
7
  * Options for creating a GraphQL server instance
20
8
  */
@@ -50,5 +38,10 @@ interface CoreServerInstance {
50
38
  * Factory function type for creating GraphQL servers
51
39
  */
52
40
  type ServerFactory = (options: CoreServerOptions) => Promise<CoreServerInstance>;
41
+ /**
42
+ * Resolve security config with safe defaults
43
+ * Used by both Yoga and Apollo server factories
44
+ */
45
+ declare function resolveSecurityDefaults(security?: CoreSecurityConfig): Required<CoreSecurityConfig>;
53
46
  //#endregion
54
- export { CoreSecurityConfig, CoreServerInstance, CoreServerOptions, ServerFactory };
47
+ export { CoreServerInstance, CoreServerOptions, ServerFactory, resolveSecurityDefaults };
@@ -1 +1,15 @@
1
- export {};
1
+ //#region src/core/server/types.ts
2
+ /**
3
+ * Resolve security config with safe defaults
4
+ * Used by both Yoga and Apollo server factories
5
+ */
6
+ function resolveSecurityDefaults(security) {
7
+ return {
8
+ introspection: security?.introspection ?? true,
9
+ playground: security?.playground ?? true,
10
+ maskErrors: security?.maskErrors ?? false,
11
+ disableSuggestions: security?.disableSuggestions ?? false
12
+ };
13
+ }
14
+ //#endregion
15
+ export { resolveSecurityDefaults };
@@ -1,12 +1,6 @@
1
- import { SchemaDefinition } from "../schema/builder.mjs";
2
1
  import { CoreServerInstance, CoreServerOptions } from "./types.mjs";
3
2
 
4
3
  //#region src/core/server/yoga.d.ts
5
- /**
6
- * Base schema definition for Yoga server
7
- * Uses shared BASE_SCHEMA string from builder
8
- */
9
- declare const BASE_SCHEMA: SchemaDefinition;
10
4
  /**
11
5
  * Apollo Sandbox HTML template
12
6
  * Shared between CLI and Nitro for consistent playground experience
@@ -39,4 +33,4 @@ declare const apolloSandboxHtml = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n
39
33
  */
40
34
  declare function createYogaServer(options: CoreServerOptions): Promise<CoreServerInstance>;
41
35
  //#endregion
42
- export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
36
+ export { apolloSandboxHtml, createYogaServer };
@@ -1,13 +1,9 @@
1
- import { BASE_SCHEMA as BASE_SCHEMA$1, createMergedSchema } from "../schema/builder.mjs";
1
+ import { createMergedSchema } from "../schema/builder.mjs";
2
+ import { resolveSecurityDefaults } from "./types.mjs";
2
3
  import defu from "defu";
3
4
  import { createYoga } from "graphql-yoga";
4
5
  //#region src/core/server/yoga.ts
5
6
  /**
6
- * Base schema definition for Yoga server
7
- * Uses shared BASE_SCHEMA string from builder
8
- */
9
- const BASE_SCHEMA = { def: BASE_SCHEMA$1 };
10
- /**
11
7
  * Apollo Sandbox HTML template
12
8
  * Shared between CLI and Nitro for consistent playground experience
13
9
  */
@@ -64,12 +60,7 @@ async function createYogaServer(options) {
64
60
  directives: directives || [],
65
61
  moduleConfig
66
62
  });
67
- const securityConfig = security || {
68
- introspection: true,
69
- playground: true,
70
- maskErrors: false,
71
- disableSuggestions: false
72
- };
63
+ const securityConfig = resolveSecurityDefaults(security);
73
64
  const yoga = createYoga(defu({
74
65
  schema,
75
66
  graphqlEndpoint: endpoint,
@@ -84,4 +75,4 @@ async function createYogaServer(options) {
84
75
  };
85
76
  }
86
77
  //#endregion
87
- export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
78
+ export { apolloSandboxHtml, createYogaServer };
@@ -1,5 +1,6 @@
1
- import { CoreConfig, CoreContext, CoreLogger } from "./config.mjs";
2
- import { ScanContext, ScanResult, ScannedResolver } from "./scanning.mjs";
1
+ import { CoreConfig, CoreLogger } from "./config.mjs";
2
+ import { ScanContext } from "./scanning.mjs";
3
+
3
4
  //#region src/core/types/adapter.d.ts
4
5
  /**
5
6
  * Framework adapter interface
@@ -10,46 +11,10 @@ interface FrameworkAdapter<TFramework = unknown> {
10
11
  readonly name: string;
11
12
  /** Create core config from framework instance */
12
13
  createCoreConfig: (framework: TFramework) => CoreConfig;
13
- /** Create core context from framework instance */
14
- createCoreContext: (framework: TFramework) => CoreContext;
15
14
  /** Create scan context from framework instance */
16
15
  createScanContext: (framework: TFramework) => ScanContext;
17
16
  /** Get framework logger adapted to CoreLogger interface */
18
17
  getLogger: (framework: TFramework) => CoreLogger;
19
18
  }
20
- /**
21
- * Scan adapter interface
22
- * Provides high-level scanning operations using the framework adapter
23
- */
24
- interface ScanAdapter<TFramework = unknown> {
25
- /** Scan for GraphQL schema files */
26
- scanSchemas: (framework: TFramework) => Promise<ScanResult<string>>;
27
- /** Scan for GraphQL files (schemas + operations) */
28
- scanGraphql: (framework: TFramework) => Promise<ScanResult<string>>;
29
- /** Scan for resolver files */
30
- scanResolvers: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
31
- /** Scan for directive files */
32
- scanDirectives: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
33
- /** Scan for client documents */
34
- scanDocuments: (framework: TFramework) => Promise<ScanResult<string>>;
35
- }
36
- /**
37
- * Codegen adapter interface
38
- * Provides high-level codegen operations using the framework adapter
39
- */
40
- interface CodegenAdapter<TFramework = unknown> {
41
- /** Generate server types */
42
- generateServerTypes: (framework: TFramework, options?: {
43
- silent?: boolean;
44
- }) => Promise<void>;
45
- /** Generate client types */
46
- generateClientTypes: (framework: TFramework, options?: {
47
- silent?: boolean;
48
- }) => Promise<void>;
49
- }
50
- /**
51
- * Combined full adapter interface
52
- */
53
- interface FullFrameworkAdapter<TFramework = unknown> extends FrameworkAdapter<TFramework>, ScanAdapter<TFramework>, CodegenAdapter<TFramework> {}
54
19
  //#endregion
55
- export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
20
+ export { FrameworkAdapter };
@@ -1,53 +1,37 @@
1
+ import { TypeScriptPluginConfig } from "@graphql-codegen/typescript";
2
+ import { plugin as plugin$1 } from "@graphql-codegen/typescript-generic-sdk";
3
+ import { TypeScriptDocumentsPluginConfig } from "@graphql-codegen/typescript-operations";
1
4
  import { Source } from "@graphql-tools/utils";
2
5
  import { GraphQLSchema } from "graphql";
6
+ import { TypeScriptResolversPluginConfig } from "@graphql-codegen/typescript-resolvers";
3
7
 
4
8
  //#region src/core/types/codegen.d.ts
5
- /**
6
- * Scalar type mapping (can be string or input/output object)
7
- */
8
- type ScalarType = string | {
9
- input: string;
10
- output: string;
11
- };
12
9
  /**
13
10
  * Server codegen configuration
11
+ * Extends @graphql-codegen/typescript + @graphql-codegen/typescript-resolvers
14
12
  */
15
- interface ServerCodegenConfig {
16
- scalars?: Record<string, ScalarType>;
17
- defaultScalarType?: string;
18
- defaultMapper?: string;
19
- contextType?: string;
20
- maybeValue?: string;
21
- inputMaybeValue?: string;
22
- declarationKind?: string;
23
- enumsAsTypes?: boolean;
24
- federation?: boolean;
25
- [key: string]: unknown;
26
- }
13
+ type ServerCodegenConfig = TypeScriptPluginConfig & TypeScriptResolversPluginConfig;
27
14
  /**
28
15
  * Client codegen configuration
16
+ * Extends @graphql-codegen/typescript + @graphql-codegen/typescript-operations
29
17
  */
30
- interface ClientCodegenConfig {
31
- emitLegacyCommonJSImports?: boolean;
32
- useTypeImports?: boolean;
33
- enumsAsTypes?: boolean;
34
- strictScalars?: boolean;
35
- maybeValue?: string;
36
- inputMaybeValue?: string;
37
- documentMode?: string;
38
- pureMagicComment?: boolean;
39
- dedupeOperationSuffix?: boolean;
40
- rawRequest?: boolean;
41
- scalars?: Record<string, ScalarType>;
18
+ type ClientCodegenConfig = TypeScriptPluginConfig & TypeScriptDocumentsPluginConfig & {
19
+ /**
20
+ * Generate TypedDocumentNode exports for urql/Apollo Client compatibility.
21
+ * @default false
22
+ */
42
23
  typedDocumentNode?: boolean;
43
- [key: string]: unknown;
44
- }
24
+ };
45
25
  /**
46
26
  * SDK codegen configuration
27
+ * Derives from the generic-sdk plugin's config parameter type with string documentMode
47
28
  */
48
- interface SdkCodegenConfig extends ClientCodegenConfig {
49
- [key: string]: unknown;
50
- }
29
+ type DocumentModeConfig = Pick<Parameters<typeof plugin$1>[2], 'documentMode'>;
30
+ type DocumentModeEnum = NonNullable<DocumentModeConfig['documentMode']>;
31
+ type DocumentModeType = `${DocumentModeEnum}`;
32
+ type SdkCodegenConfig = Omit<Parameters<typeof plugin$1>[2], 'documentMode'> & {
33
+ documentMode?: DocumentModeType;
34
+ };
51
35
  /**
52
36
  * Input for server type generation
53
37
  */
@@ -114,7 +98,7 @@ interface ClientCodegenResult {
114
98
  */
115
99
  interface ExternalServiceCodegenConfig {
116
100
  name: string;
117
- schema: string | string[];
101
+ schema?: string | string[];
118
102
  endpoint: string;
119
103
  headers?: Record<string, string> | (() => Record<string, string>);
120
104
  documents?: string[];
@@ -125,12 +109,5 @@ interface ExternalServiceCodegenConfig {
125
109
  clientSDK?: SdkCodegenConfig;
126
110
  };
127
111
  }
128
- /**
129
- * Schema loading options
130
- */
131
- interface SchemaLoadOptions {
132
- headers?: Record<string, string>;
133
- loaders?: unknown[];
134
- }
135
112
  //#endregion
136
- export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
113
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
@@ -1,4 +1,5 @@
1
1
  import { GraphQLFramework } from "../constants.mjs";
2
+ import { ClientCodegenConfig, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig } from "./codegen.mjs";
2
3
 
3
4
  //#region src/core/types/config.d.ts
4
5
  /**
@@ -12,19 +13,9 @@ interface CoreLogger {
12
13
  success: (message: string, ...args: unknown[]) => void;
13
14
  debug: (message: string, ...args: unknown[]) => void;
14
15
  }
15
- /**
16
- * GraphQL codegen configuration
17
- */
18
- interface CoreCodegenConfig {
19
- /** Server-side codegen options */
20
- server?: Record<string, unknown>;
21
- /** Client-side codegen options */
22
- client?: Record<string, unknown>;
23
- /** Client SDK codegen options */
24
- clientSDK?: Record<string, unknown>;
25
- }
26
16
  /**
27
17
  * Security configuration options
18
+ * Single source of truth — re-exported as `SecurityConfig` in Nitro types
28
19
  */
29
20
  interface CoreSecurityConfig {
30
21
  /** Enable/disable GraphQL introspection */
@@ -37,28 +28,8 @@ interface CoreSecurityConfig {
37
28
  disableSuggestions?: boolean;
38
29
  }
39
30
  /**
40
- * External GraphQL service configuration
41
- */
42
- interface CoreExternalService {
43
- /** Unique service name */
44
- name: string;
45
- /** GraphQL schema URL or file path */
46
- schema: string;
47
- /** GraphQL endpoint URL */
48
- endpoint: string;
49
- /** Headers for schema introspection */
50
- headers?: Record<string, string> | (() => Record<string, string>);
51
- /** Document patterns for this service */
52
- documents?: string[];
53
- /** Service-specific path overrides */
54
- paths?: {
55
- sdk?: string;
56
- types?: string;
57
- ofetch?: string;
58
- };
59
- }
60
- /**
61
- * Apollo Federation configuration
31
+ * Federation configuration
32
+ * Base type — Nitro's FederationConfig extends this
62
33
  */
63
34
  interface CoreFederationConfig {
64
35
  /** Enable federation support */
@@ -67,80 +38,33 @@ interface CoreFederationConfig {
67
38
  serviceName?: string;
68
39
  }
69
40
  /**
70
- * Path configuration with placeholders
41
+ * Codegen configuration
42
+ * Uses the authoritative types from codegen.ts
71
43
  */
72
- interface CorePathsConfig {
73
- /** Server GraphQL directory (default: 'server/graphql') */
74
- serverDir?: string;
75
- /** Client GraphQL directory (default: 'app/graphql' or 'graphql') */
76
- clientDir?: string;
77
- /** Types output directory (default: '{buildDir}/types') */
78
- typesDir?: string;
79
- }
80
- /**
81
- * Type generation configuration
82
- */
83
- interface CoreTypesConfig {
84
- /** Master switch for type generation */
85
- enabled?: boolean;
86
- /** Server types output path */
87
- server?: boolean | string;
88
- /** Client types output path */
89
- client?: boolean | string;
90
- /** External service types output path */
91
- external?: boolean | string;
92
- }
93
- /**
94
- * SDK generation configuration
95
- */
96
- interface CoreSdkConfig {
97
- /** Master switch for SDK generation */
98
- enabled?: boolean;
99
- /** Main SDK output path */
100
- main?: boolean | string;
101
- /** External service SDK output path */
102
- external?: boolean | string;
103
- }
104
- /**
105
- * Client utilities configuration
106
- */
107
- interface CoreClientUtilsConfig {
108
- /** Master switch for client utilities */
109
- enabled?: boolean;
110
- /** Index file output path */
111
- index?: boolean | string;
112
- /** Ofetch client output path */
113
- ofetch?: boolean | string;
44
+ interface CoreCodegenConfig {
45
+ /** Server-side codegen options */
46
+ server?: ServerCodegenConfig;
47
+ /** Client-side codegen options */
48
+ client?: ClientCodegenConfig;
49
+ /** Client SDK codegen options */
50
+ clientSDK?: SdkCodegenConfig;
114
51
  }
115
52
  /**
116
- * Core GraphQL options
117
- * Framework-agnostic GraphQL configuration
53
+ * External service with path overrides
54
+ * Extends the codegen base type with UI-facing path config
118
55
  */
119
- interface CoreGraphQLOptions {
120
- /** GraphQL framework to use */
121
- framework?: GraphQLFramework;
122
- /** GraphQL endpoint path */
123
- endpoint?: string;
124
- /** Codegen configuration */
125
- codegen?: CoreCodegenConfig;
126
- /** Security configuration */
127
- security?: CoreSecurityConfig;
128
- /** External GraphQL services */
129
- externalServices?: CoreExternalService[];
130
- /** Apollo Federation configuration */
131
- federation?: CoreFederationConfig;
132
- /** Path configuration */
133
- paths?: CorePathsConfig;
134
- /** Type generation configuration */
135
- types?: false | CoreTypesConfig;
136
- /** SDK generation configuration */
137
- sdk?: false | CoreSdkConfig;
138
- /** Client utilities configuration */
139
- clientUtils?: false | CoreClientUtilsConfig;
56
+ interface CoreExternalService extends ExternalServiceCodegenConfig {
57
+ /** Service-specific path overrides */
58
+ paths?: {
59
+ sdk?: string | boolean;
60
+ types?: string | boolean;
61
+ ofetch?: string | boolean;
62
+ };
140
63
  }
141
64
  /**
142
65
  * Core configuration
143
- * Main configuration interface that replaces Nitro-specific options
66
+ * The resolved, fully-populated config used by core functions.
67
+ * Created by adapters from framework-specific types.
144
68
  */
145
69
  interface CoreConfig {
146
70
  /** Root directory of the project */
@@ -159,30 +83,18 @@ interface CoreConfig {
159
83
  isNuxt: boolean;
160
84
  /** Whether running in development mode */
161
85
  isDev: boolean;
162
- /** GraphQL options */
163
- graphqlOptions: CoreGraphQLOptions;
164
86
  /** Logger instance */
165
87
  logger: CoreLogger;
166
88
  /** Patterns to ignore during scanning */
167
89
  ignorePatterns: string[];
168
- }
169
- /**
170
- * Core context for runtime operations
171
- * Holds resolved configuration and state
172
- */
173
- interface CoreContext {
174
- /** Resolved configuration */
175
- config: CoreConfig;
176
- /** GraphQL build directory */
177
- graphqlBuildDir: string;
178
- /** Watch directories for file watching */
179
- watchDirs: string[];
180
- /** Relative directory paths */
181
- dir: {
182
- build: string;
183
- client: string;
184
- server: string;
185
- };
90
+ /** Security configuration */
91
+ security?: CoreSecurityConfig;
92
+ /** Federation configuration */
93
+ federation?: CoreFederationConfig;
94
+ /** Codegen configuration */
95
+ codegen?: CoreCodegenConfig;
96
+ /** External services */
97
+ externalServices?: CoreExternalService[];
186
98
  }
187
99
  //#endregion
188
- export { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig };
100
+ export { CoreCodegenConfig, CoreConfig, CoreExternalService, CoreFederationConfig, CoreLogger, CoreSecurityConfig };
@@ -5,19 +5,22 @@ type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
5
5
  type DirectiveLocationName = 'QUERY' | 'MUTATION' | 'SUBSCRIPTION' | 'FIELD' | 'FRAGMENT_DEFINITION' | 'FRAGMENT_SPREAD' | 'INLINE_FRAGMENT' | 'VARIABLE_DEFINITION' | 'SCHEMA' | 'SCALAR' | 'OBJECT' | 'FIELD_DEFINITION' | 'ARGUMENT_DEFINITION' | 'INTERFACE' | 'UNION' | 'ENUM' | 'ENUM_VALUE' | 'INPUT_OBJECT' | 'INPUT_FIELD_DEFINITION';
6
6
  type GraphQLScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'ID' | 'JSON' | 'DateTime';
7
7
  type GraphQLBaseType = GraphQLScalarType | (string & {});
8
- type GraphQLArgumentType = 'String' | 'Int' | 'Float' | 'Boolean' | 'ID' | 'JSON' | 'DateTime' | 'String!' | 'Int!' | 'Float!' | 'Boolean!' | 'ID!' | 'JSON!' | 'DateTime!' | '[String]' | '[String!]' | '[String]!' | '[String!]!' | '[Int]' | '[Int!]' | '[Int]!' | '[Int!]!' | '[Float]' | '[Float!]' | '[Float]!' | '[Float!]!' | '[Boolean]' | '[Boolean!]' | '[Boolean]!' | '[Boolean!]!' | '[ID]' | '[ID!]' | '[ID]!' | '[ID!]!' | '[JSON]' | '[JSON!]' | '[JSON]!' | '[JSON!]!' | '[DateTime]' | '[DateTime!]' | '[DateTime]!' | '[DateTime!]!' | (string & {});
8
+ type GraphQLModifier = '' | '!' | '[]' | '[!]' | '[!]!';
9
+ type GraphQLArgumentType = `${GraphQLScalarType}${GraphQLModifier}` | `${GraphQLBaseType}${GraphQLModifier}` | (string & {});
10
+ /** Allowed default values for directive arguments */
11
+ type DirectiveDefaultValue = string | number | boolean | null;
9
12
  interface DirectiveArgument<T extends GraphQLArgumentType = GraphQLArgumentType> {
10
13
  /**
11
14
  * GraphQL type for the argument
12
15
  * @example 'String', 'Int!', '[String!]!', 'DateTime', 'JSON'
13
16
  */
14
17
  type: T;
15
- defaultValue?: any;
18
+ defaultValue?: DirectiveDefaultValue;
16
19
  description?: string;
17
20
  }
18
21
  interface DirectiveArg {
19
22
  type: GraphQLArgumentType;
20
- defaultValue?: any;
23
+ defaultValue?: DirectiveDefaultValue;
21
24
  description?: string;
22
25
  }
23
26
  interface DirectiveDefinition {
@@ -33,7 +36,7 @@ interface DefineDirectiveConfig {
33
36
  locations: ReadonlyArray<DirectiveLocationName>;
34
37
  args?: Record<string, {
35
38
  type: GraphQLArgumentType;
36
- defaultValue?: any;
39
+ defaultValue?: DirectiveDefaultValue;
37
40
  description?: string;
38
41
  }>;
39
42
  description?: string;
@@ -41,4 +44,4 @@ interface DefineDirectiveConfig {
41
44
  transformer?: (schema: GraphQLSchema) => GraphQLSchema;
42
45
  }
43
46
  //#endregion
44
- export { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
47
+ export { DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
@@ -1,5 +1,6 @@
1
- import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./codegen.mjs";
2
- import { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig } from "./config.mjs";
3
- import { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./define.mjs";
1
+ import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./codegen.mjs";
2
+ import { CoreCodegenConfig, CoreConfig, CoreExternalService, CoreFederationConfig, CoreLogger, CoreSecurityConfig } from "./config.mjs";
4
3
  import { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver } from "./scanning.mjs";
5
- export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig, DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, ExternalServiceCodegenConfig, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverImport, ScalarType, ScanContext, ScanResult, ScannedFile, ScannedResolver, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
4
+ import { DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./define.mjs";
5
+ import { StandardSchemaV1 } from "./standard-schema.mjs";
6
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreCodegenConfig, CoreConfig, CoreExternalService, CoreFederationConfig, CoreLogger, CoreSecurityConfig, DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, ExternalServiceCodegenConfig, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult, StandardSchemaV1 };
@@ -1,4 +1,5 @@
1
1
  import { CoreLogger } from "./config.mjs";
2
+ import * as knitwork from "knitwork";
2
3
 
3
4
  //#region src/core/types/scanning.d.ts
4
5
  /**
@@ -49,7 +50,7 @@ interface ResolverImport {
49
50
  /** Resolver type (query, mutation, resolver, type, subscription, directive) */
50
51
  type: 'query' | 'mutation' | 'resolver' | 'type' | 'subscription' | 'directive';
51
52
  /** Aliased import name */
52
- as: string;
53
+ as?: string;
53
54
  }
54
55
  /**
55
56
  * Scanned resolver information
@@ -59,6 +60,8 @@ interface ScannedResolver {
59
60
  specifier: string;
60
61
  /** Exports from this file */
61
62
  imports: ResolverImport[];
63
+ /** ESM code generation options (used by knitwork's genImport) */
64
+ options?: knitwork.ESMCodeGenOptions;
62
65
  }
63
66
  //#endregion
64
67
  export { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver };