nitro-graphql 2.0.0-beta.70 → 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 (228) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/adapter.d.mts +0 -3
  3. package/dist/cli/adapter.mjs +7 -32
  4. package/dist/cli/commands/build.d.mts +2 -2
  5. package/dist/cli/commands/build.mjs +1 -3
  6. package/dist/cli/commands/dev.d.mts +2 -2
  7. package/dist/cli/commands/dev.mjs +1 -3
  8. package/dist/cli/commands/generate.mjs +10 -10
  9. package/dist/cli/commands/init.mjs +4 -4
  10. package/dist/cli/commands/validate.mjs +1 -3
  11. package/dist/cli/completions.mjs +1 -3
  12. package/dist/cli/config.d.mts +4 -5
  13. package/dist/cli/config.mjs +4 -3
  14. package/dist/cli/index.d.mts +3 -6
  15. package/dist/cli/index.mjs +2 -4
  16. package/dist/cli/server/debug-handler.mjs +2 -5
  17. package/dist/cli/server/dev-server.mjs +1 -3
  18. package/dist/cli/server/graphql-handler.mjs +3 -4
  19. package/dist/cli/server/health-handler.mjs +1 -2
  20. package/dist/cli/server/loader.mjs +1 -3
  21. package/dist/cli/server/sandbox-handler.mjs +1 -3
  22. package/dist/cli/server/watcher.mjs +2 -4
  23. package/dist/cli/server/ws-handler.mjs +1 -3
  24. package/dist/config.mjs +1 -2
  25. package/dist/core/codegen/client.d.mts +4 -27
  26. package/dist/core/codegen/client.mjs +26 -447
  27. package/dist/core/codegen/document-loader.mjs +1 -3
  28. package/dist/core/codegen/file-header.d.mts +7 -0
  29. package/dist/core/codegen/file-header.mjs +12 -0
  30. package/dist/core/codegen/index.d.mts +7 -5
  31. package/dist/core/codegen/index.mjs +7 -6
  32. package/dist/core/codegen/{runtime.d.mts → runtime-generator.d.mts} +1 -3
  33. package/dist/core/codegen/{runtime.mjs → runtime-generator.mjs} +7 -6
  34. package/dist/core/codegen/schema-loader.d.mts +2 -7
  35. package/dist/core/codegen/schema-loader.mjs +66 -73
  36. package/dist/core/codegen/server-type-helpers.d.mts +14 -0
  37. package/dist/core/codegen/server-type-helpers.mjs +76 -0
  38. package/dist/core/codegen/server.d.mts +1 -15
  39. package/dist/core/codegen/server.mjs +15 -107
  40. package/dist/core/codegen/subscription-extractor.d.mts +20 -0
  41. package/dist/core/codegen/subscription-extractor.mjs +30 -0
  42. package/dist/core/codegen/validation.mjs +1 -3
  43. package/dist/core/codegen/vue-subscription-builder.d.mts +10 -0
  44. package/dist/core/codegen/vue-subscription-builder.mjs +351 -0
  45. package/dist/core/constants.d.mts +5 -53
  46. package/dist/core/constants.mjs +13 -56
  47. package/dist/core/create-config.d.mts +31 -0
  48. package/dist/core/create-config.mjs +42 -0
  49. package/dist/core/debug/index.d.mts +2 -2
  50. package/dist/core/debug/index.mjs +2 -3
  51. package/dist/core/debug/template.d.mts +1 -5
  52. package/dist/core/debug/template.mjs +5 -4
  53. package/dist/core/extend/index.mjs +1 -2
  54. package/dist/core/extend/loader.d.mts +0 -1
  55. package/dist/core/extend/loader.mjs +60 -92
  56. package/dist/core/index.d.mts +22 -21
  57. package/dist/core/index.mjs +19 -16
  58. package/dist/core/manifest.mjs +4 -4
  59. package/dist/core/pubsub/index.d.mts +2 -109
  60. package/dist/core/pubsub/index.mjs +2 -148
  61. package/dist/core/pubsub/memory-pubsub.d.mts +109 -0
  62. package/dist/core/pubsub/memory-pubsub.mjs +146 -0
  63. package/dist/core/scanning/ast-scanner.mjs +5 -5
  64. package/dist/core/scanning/directives.mjs +3 -5
  65. package/dist/core/scanning/documents.d.mts +4 -3
  66. package/dist/core/scanning/documents.mjs +4 -5
  67. package/dist/core/scanning/{common.d.mts → file-scanner.d.mts} +1 -1
  68. package/dist/core/scanning/{common.mjs → file-scanner.mjs} +3 -13
  69. package/dist/core/scanning/index.d.mts +3 -3
  70. package/dist/core/scanning/index.mjs +3 -4
  71. package/dist/core/scanning/resolvers.mjs +9 -11
  72. package/dist/core/scanning/schemas.d.mts +1 -5
  73. package/dist/core/scanning/schemas.mjs +2 -26
  74. package/dist/core/schema/builder.d.mts +4 -2
  75. package/dist/core/schema/builder.mjs +4 -4
  76. package/dist/core/schema/federation.mjs +1 -3
  77. package/dist/core/schema/index.d.mts +2 -2
  78. package/dist/core/schema/index.mjs +2 -3
  79. package/dist/core/server/apollo.d.mts +20 -0
  80. package/dist/core/server/apollo.mjs +54 -0
  81. package/dist/core/server/index.d.mts +4 -2
  82. package/dist/core/server/index.mjs +3 -3
  83. package/dist/core/server/sandbox.mjs +1 -2
  84. package/dist/core/server/types.d.mts +7 -14
  85. package/dist/core/server/types.mjs +15 -1
  86. package/dist/core/server/yoga.d.mts +1 -7
  87. package/dist/core/server/yoga.mjs +4 -15
  88. package/dist/core/types/adapter.d.mts +3 -40
  89. package/dist/core/types/adapter.mjs +1 -1
  90. package/dist/core/types/codegen.d.mts +22 -45
  91. package/dist/core/types/codegen.mjs +1 -1
  92. package/dist/core/types/config.d.mts +33 -121
  93. package/dist/core/types/config.mjs +1 -1
  94. package/dist/core/types/define.d.mts +8 -5
  95. package/dist/core/types/define.mjs +1 -1
  96. package/dist/core/types/index.d.mts +5 -4
  97. package/dist/core/types/index.mjs +1 -1
  98. package/dist/core/types/scanning.d.mts +4 -1
  99. package/dist/core/types/scanning.mjs +1 -1
  100. package/dist/core/types/standard-schema.d.mts +64 -0
  101. package/dist/core/types/standard-schema.mjs +1 -0
  102. package/dist/core/utils/directive-parser.d.mts +8 -63
  103. package/dist/core/utils/directive-parser.mjs +114 -167
  104. package/dist/core/utils/errors.mjs +1 -3
  105. package/dist/core/utils/file-io.d.mts +1 -5
  106. package/dist/core/utils/file-io.mjs +1 -13
  107. package/dist/core/utils/imports.mjs +3 -4
  108. package/dist/core/utils/index.d.mts +5 -4
  109. package/dist/core/utils/index.mjs +6 -6
  110. package/dist/core/utils/logger.d.mts +1 -10
  111. package/dist/core/utils/logger.mjs +1 -21
  112. package/dist/core/utils/ofetch-templates.mjs +4 -6
  113. package/dist/core/utils/runtime.d.mts +1 -30
  114. package/dist/core/utils/runtime.mjs +2 -46
  115. package/dist/core/utils/string.d.mts +10 -0
  116. package/dist/core/utils/string.mjs +12 -0
  117. package/dist/core/utils/subscribe-templates.mjs +1 -2
  118. package/dist/core/validation/external-services.mjs +3 -3
  119. package/dist/core/validation/index.mjs +1 -2
  120. package/dist/core/watcher/create-watcher.d.mts +103 -0
  121. package/dist/core/watcher/create-watcher.mjs +143 -0
  122. package/dist/core/watcher/index.d.mts +2 -107
  123. package/dist/core/watcher/index.mjs +2 -141
  124. package/dist/define.d.mts +4 -2
  125. package/dist/define.mjs +8 -9
  126. package/dist/index.d.mts +4 -3
  127. package/dist/index.mjs +3 -4
  128. package/dist/nitro/adapter.d.mts +6 -11
  129. package/dist/nitro/adapter.mjs +12 -45
  130. package/dist/nitro/apollo.mjs +1 -3
  131. package/dist/nitro/codegen/client-types.d.mts +12 -0
  132. package/dist/nitro/codegen/client-types.mjs +73 -0
  133. package/dist/nitro/codegen/external-types.d.mts +8 -0
  134. package/dist/nitro/codegen/external-types.mjs +47 -0
  135. package/dist/nitro/codegen/index.d.mts +4 -0
  136. package/dist/nitro/codegen/index.mjs +4 -0
  137. package/dist/nitro/codegen/server-types.d.mts +12 -0
  138. package/dist/nitro/codegen/server-types.mjs +81 -0
  139. package/dist/nitro/defaults.d.mts +28 -0
  140. package/dist/nitro/defaults.mjs +34 -0
  141. package/dist/nitro/index.d.mts +11 -3
  142. package/dist/nitro/index.mjs +4 -6
  143. package/dist/nitro/paths.d.mts +3 -2
  144. package/dist/nitro/paths.mjs +14 -5
  145. package/dist/nitro/rollup.mjs +8 -8
  146. package/dist/nitro/routes/_ws-handler.d.mts +6 -0
  147. package/dist/nitro/routes/_ws-handler.mjs +49 -0
  148. package/dist/nitro/routes/apollo-sandbox-script.d.mts +2 -2
  149. package/dist/nitro/routes/apollo-sandbox-script.mjs +1 -3
  150. package/dist/nitro/routes/apollo-server-ws.d.mts +1 -1
  151. package/dist/nitro/routes/apollo-server-ws.mjs +10 -48
  152. package/dist/nitro/routes/apollo-server.d.mts +2 -2
  153. package/dist/nitro/routes/apollo-server.mjs +17 -58
  154. package/dist/nitro/routes/debug.d.mts +2 -2
  155. package/dist/nitro/routes/debug.mjs +4 -7
  156. package/dist/nitro/routes/graphql-yoga-ws.d.mts +3 -3
  157. package/dist/nitro/routes/graphql-yoga-ws.mjs +7 -48
  158. package/dist/nitro/routes/graphql-yoga.d.mts +2 -2
  159. package/dist/nitro/routes/graphql-yoga.mjs +8 -8
  160. package/dist/nitro/routes/health.d.mts +2 -2
  161. package/dist/nitro/routes/health.mjs +23 -27
  162. package/dist/nitro/setup/extend-loader.d.mts +6 -5
  163. package/dist/nitro/setup/extend-loader.mjs +31 -61
  164. package/dist/nitro/setup/file-watcher.mjs +9 -8
  165. package/dist/nitro/setup/logging.d.mts +1 -8
  166. package/dist/nitro/setup/logging.mjs +7 -24
  167. package/dist/nitro/setup/rollup-integration.mjs +36 -4
  168. package/dist/nitro/setup/routes.mjs +1 -3
  169. package/dist/nitro/setup/scanner.d.mts +8 -43
  170. package/dist/nitro/setup/scanner.mjs +56 -60
  171. package/dist/nitro/setup/security.d.mts +10 -0
  172. package/dist/nitro/setup/security.mjs +17 -0
  173. package/dist/nitro/setup/ts-config.mjs +1 -3
  174. package/dist/nitro/setup/type-generation.d.mts +13 -0
  175. package/dist/nitro/setup/type-generation.mjs +16 -0
  176. package/dist/nitro/setup.d.mts +4 -3
  177. package/dist/nitro/setup.mjs +88 -77
  178. package/dist/nitro/state.d.mts +32 -0
  179. package/dist/nitro/state.mjs +58 -0
  180. package/dist/nitro/types/augmentation.d.mts +59 -0
  181. package/dist/nitro/types/augmentation.mjs +1 -0
  182. package/dist/nitro/types/config.d.mts +327 -0
  183. package/dist/nitro/types/config.mjs +1 -0
  184. package/dist/nitro/types/define.d.mts +13 -0
  185. package/dist/nitro/types/define.mjs +1 -0
  186. package/dist/nitro/types/index.d.mts +10 -0
  187. package/dist/nitro/types/index.mjs +1 -0
  188. package/dist/nitro/virtual/debug-info.d.mts +9 -0
  189. package/dist/nitro/virtual/debug-info.mjs +35 -0
  190. package/dist/nitro/virtual/graphql-config.d.mts +9 -0
  191. package/dist/nitro/virtual/graphql-config.mjs +33 -0
  192. package/dist/nitro/virtual/index.d.mts +25 -0
  193. package/dist/nitro/virtual/index.mjs +45 -0
  194. package/dist/nitro/virtual/module-config.d.mts +9 -0
  195. package/dist/nitro/virtual/module-config.mjs +10 -0
  196. package/dist/nitro/virtual/pubsub.d.mts +9 -0
  197. package/dist/nitro/virtual/pubsub.mjs +17 -0
  198. package/dist/nitro/virtual/server-directives.d.mts +9 -0
  199. package/dist/nitro/virtual/server-directives.mjs +12 -0
  200. package/dist/nitro/virtual/server-resolvers.d.mts +9 -0
  201. package/dist/nitro/virtual/server-resolvers.mjs +17 -0
  202. package/dist/nitro/virtual/server-schemas.d.mts +9 -0
  203. package/dist/nitro/virtual/server-schemas.mjs +31 -0
  204. package/dist/nitro/virtual/stubs.d.mts +42 -10
  205. package/dist/nitro/virtual/stubs.mjs +1 -7
  206. package/dist/nitro/virtual/utils.d.mts +15 -0
  207. package/dist/nitro/virtual/utils.mjs +26 -0
  208. package/dist/nitro/virtual/validation-schemas.d.mts +9 -0
  209. package/dist/nitro/virtual/validation-schemas.mjs +33 -0
  210. package/dist/nuxt.mjs +4 -5
  211. package/dist/stubs/index.mjs +1 -1
  212. package/dist/subscribe/index.mjs +3 -4
  213. package/native/index.js +52 -52
  214. package/package.json +41 -41
  215. package/dist/cli/commands/index.d.mts +0 -5
  216. package/dist/cli/commands/index.mjs +0 -6
  217. package/dist/core/codegen/plugin.d.mts +0 -19
  218. package/dist/core/codegen/plugin.mjs +0 -30
  219. package/dist/core/config.d.mts +0 -45
  220. package/dist/core/config.mjs +0 -78
  221. package/dist/nitro/codegen.d.mts +0 -18
  222. package/dist/nitro/codegen.mjs +0 -173
  223. package/dist/nitro/config.d.mts +0 -50
  224. package/dist/nitro/config.mjs +0 -57
  225. package/dist/nitro/types.d.mts +0 -549
  226. package/dist/nitro/types.mjs +0 -1
  227. package/dist/nitro/virtual/generators.d.mts +0 -38
  228. package/dist/nitro/virtual/generators.mjs +0 -192
@@ -46,9 +46,11 @@ declare function createMergedSchema(options: CreateMergedSchemaOptions): Promise
46
46
  /**
47
47
  * Base schema with empty Query and Mutation types.
48
48
  * Required for 'extend type Query' syntax to work.
49
- * Shared between CLI and Nitro.
49
+ * Shared between CLI, Yoga, and Apollo routes.
50
50
  */
51
51
  declare const BASE_SCHEMA = "type Query { _empty: String }\ntype Mutation { _empty: String }";
52
+ /** BASE_SCHEMA wrapped as a SchemaDefinition for virtual module usage */
53
+ declare const BASE_SCHEMA_DEF: SchemaDefinition;
52
54
  /**
53
55
  * Build a GraphQL schema from file paths (CLI usage)
54
56
  * Reads schema files, merges them, and builds an executable schema
@@ -56,4 +58,4 @@ declare const BASE_SCHEMA = "type Query { _empty: String }\ntype Mutation { _emp
56
58
  */
57
59
  declare function buildGraphQLSchema(schemaPaths: string[]): Promise<GraphQLSchema | null>;
58
60
  //#endregion
59
- export { BASE_SCHEMA, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
61
+ export { BASE_SCHEMA, BASE_SCHEMA_DEF, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
@@ -4,7 +4,6 @@ import { buildSchema, parse, parse as parse$1, print, subscribe, validate } from
4
4
  import { readFileSync } from "node:fs";
5
5
  import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
6
6
  import { makeExecutableSchema } from "@graphql-tools/schema";
7
-
8
7
  //#region src/core/schema/builder.ts
9
8
  /**
10
9
  * Create a merged GraphQL schema from schemas, resolvers, and directives
@@ -50,10 +49,12 @@ async function createMergedSchema(options) {
50
49
  /**
51
50
  * Base schema with empty Query and Mutation types.
52
51
  * Required for 'extend type Query' syntax to work.
53
- * Shared between CLI and Nitro.
52
+ * Shared between CLI, Yoga, and Apollo routes.
54
53
  */
55
54
  const BASE_SCHEMA = `type Query { _empty: String }
56
55
  type Mutation { _empty: String }`;
56
+ /** BASE_SCHEMA wrapped as a SchemaDefinition for virtual module usage */
57
+ const BASE_SCHEMA_DEF = { def: BASE_SCHEMA };
57
58
  /**
58
59
  * Build a GraphQL schema from file paths (CLI usage)
59
60
  * Reads schema files, merges them, and builds an executable schema
@@ -73,6 +74,5 @@ async function buildGraphQLSchema(schemaPaths) {
73
74
  return null;
74
75
  }
75
76
  }
76
-
77
77
  //#endregion
78
- export { BASE_SCHEMA, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
78
+ export { BASE_SCHEMA, BASE_SCHEMA_DEF, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate };
@@ -1,6 +1,5 @@
1
1
  import { LOG_TAG } from "../constants.mjs";
2
2
  import { consola as consola$1 } from "consola";
3
-
4
3
  //#region src/core/schema/federation.ts
5
4
  const logger = consola$1.withTag(LOG_TAG);
6
5
  /**
@@ -35,6 +34,5 @@ function warnFederationUnavailable() {
35
34
  function resetFederationCache() {
36
35
  buildSubgraphSchemaCache = null;
37
36
  }
38
-
39
37
  //#endregion
40
- export { loadFederationSupport, resetFederationCache, warnFederationUnavailable };
38
+ export { loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -1,3 +1,3 @@
1
- import { BASE_SCHEMA, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
1
+ import { BASE_SCHEMA, BASE_SCHEMA_DEF, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
2
2
  import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
3
- export { BASE_SCHEMA, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
3
+ export { BASE_SCHEMA, BASE_SCHEMA_DEF, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
@@ -1,4 +1,3 @@
1
1
  import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
2
- import { BASE_SCHEMA, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
3
-
4
- export { BASE_SCHEMA, buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
2
+ import { BASE_SCHEMA, BASE_SCHEMA_DEF, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./builder.mjs";
3
+ export { BASE_SCHEMA, BASE_SCHEMA_DEF, buildGraphQLSchema, createMergedSchema, loadFederationSupport, parse, resetFederationCache, subscribe, validate, warnFederationUnavailable };
@@ -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,4 +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
-
4
- 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 };
@@ -34,6 +34,5 @@ async function createSandboxResponse() {
34
34
  });
35
35
  }
36
36
  }
37
-
38
37
  //#endregion
39
- export { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript };
38
+ export { APOLLO_SANDBOX_CDN, createSandboxResponse, 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,14 +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
5
  //#region src/core/server/yoga.ts
6
6
  /**
7
- * Base schema definition for Yoga server
8
- * Uses shared BASE_SCHEMA string from builder
9
- */
10
- const BASE_SCHEMA = { def: BASE_SCHEMA$1 };
11
- /**
12
7
  * Apollo Sandbox HTML template
13
8
  * Shared between CLI and Nitro for consistent playground experience
14
9
  */
@@ -65,12 +60,7 @@ async function createYogaServer(options) {
65
60
  directives: directives || [],
66
61
  moduleConfig
67
62
  });
68
- const securityConfig = security || {
69
- introspection: true,
70
- playground: true,
71
- maskErrors: false,
72
- disableSuggestions: false
73
- };
63
+ const securityConfig = resolveSecurityDefaults(security);
74
64
  const yoga = createYoga(defu({
75
65
  schema,
76
66
  graphqlEndpoint: endpoint,
@@ -84,6 +74,5 @@ async function createYogaServer(options) {
84
74
  schema
85
75
  };
86
76
  }
87
-
88
77
  //#endregion
89
- export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
78
+ export { apolloSandboxHtml, createYogaServer };
@@ -1,6 +1,5 @@
1
- import { CoreConfig, CoreContext, CoreLogger } from "./config.mjs";
2
- import { ScanContext, ScanResult, ScannedResolver } from "./scanning.mjs";
3
- import "./index.mjs";
1
+ import { CoreConfig, CoreLogger } from "./config.mjs";
2
+ import { ScanContext } from "./scanning.mjs";
4
3
 
5
4
  //#region src/core/types/adapter.d.ts
6
5
  /**
@@ -12,46 +11,10 @@ interface FrameworkAdapter<TFramework = unknown> {
12
11
  readonly name: string;
13
12
  /** Create core config from framework instance */
14
13
  createCoreConfig: (framework: TFramework) => CoreConfig;
15
- /** Create core context from framework instance */
16
- createCoreContext: (framework: TFramework) => CoreContext;
17
14
  /** Create scan context from framework instance */
18
15
  createScanContext: (framework: TFramework) => ScanContext;
19
16
  /** Get framework logger adapted to CoreLogger interface */
20
17
  getLogger: (framework: TFramework) => CoreLogger;
21
18
  }
22
- /**
23
- * Scan adapter interface
24
- * Provides high-level scanning operations using the framework adapter
25
- */
26
- interface ScanAdapter<TFramework = unknown> {
27
- /** Scan for GraphQL schema files */
28
- scanSchemas: (framework: TFramework) => Promise<ScanResult<string>>;
29
- /** Scan for GraphQL files (schemas + operations) */
30
- scanGraphql: (framework: TFramework) => Promise<ScanResult<string>>;
31
- /** Scan for resolver files */
32
- scanResolvers: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
33
- /** Scan for directive files */
34
- scanDirectives: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
35
- /** Scan for client documents */
36
- scanDocuments: (framework: TFramework) => Promise<ScanResult<string>>;
37
- }
38
- /**
39
- * Codegen adapter interface
40
- * Provides high-level codegen operations using the framework adapter
41
- */
42
- interface CodegenAdapter<TFramework = unknown> {
43
- /** Generate server types */
44
- generateServerTypes: (framework: TFramework, options?: {
45
- silent?: boolean;
46
- }) => Promise<void>;
47
- /** Generate client types */
48
- generateClientTypes: (framework: TFramework, options?: {
49
- silent?: boolean;
50
- }) => Promise<void>;
51
- }
52
- /**
53
- * Combined full adapter interface
54
- */
55
- interface FullFrameworkAdapter<TFramework = unknown> extends FrameworkAdapter<TFramework>, ScanAdapter<TFramework>, CodegenAdapter<TFramework> {}
56
19
  //#endregion
57
- export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
20
+ export { FrameworkAdapter };
@@ -1 +1 @@
1
- export { };
1
+ export {};
@@ -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 +1 @@
1
- export { };
1
+ export {};
@@ -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 };
@@ -1 +1 @@
1
- export { };
1
+ export {};