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,59 @@
1
+ import { ScannedResolver } from "../../core/types/scanning.mjs";
2
+ import { NitroGraphQLOptions } from "./config.mjs";
3
+
4
+ //#region src/nitro/types/augmentation.d.ts
5
+ /**
6
+ * Immutable scan state snapshot
7
+ * Built atomically from local scan + extend results.
8
+ * All consumers (virtual modules, codegen, logging) read from this single snapshot.
9
+ * Never mutate — replace the entire object for updates.
10
+ */
11
+ interface GraphQLScanState {
12
+ readonly schemas: readonly string[];
13
+ readonly resolvers: readonly ScannedResolver[];
14
+ readonly directives: readonly ScannedResolver[];
15
+ readonly documents: readonly string[];
16
+ readonly directiveSchemas: string | null;
17
+ readonly extendConfigs: readonly string[];
18
+ readonly extendSchemas: readonly string[];
19
+ }
20
+ declare module 'nitro/types' {
21
+ interface Nitro {
22
+ /** @deprecated Use nitro.graphql.state.schemas — kept for backward compatibility */
23
+ scanSchemas: string[];
24
+ /** @deprecated Use nitro.graphql.state.documents */
25
+ scanDocuments: string[];
26
+ /** @deprecated Use nitro.graphql.state.resolvers */
27
+ scanResolvers: ScannedResolver[];
28
+ /** @deprecated Use nitro.graphql.state.directives */
29
+ scanDirectives: ScannedResolver[];
30
+ graphql: {
31
+ /** Immutable scan state — the single source of truth for all scanned files */state: GraphQLScanState; /** Absolute path to GraphQL build directory (e.g. /project/.graphql) */
32
+ buildDir: string; /** Directories watched for file changes in dev mode */
33
+ watchDirs: string[]; /** Absolute path to client GraphQL directory (e.g. /project/graphql) */
34
+ clientDir: string; /** Absolute path to server GraphQL directory (e.g. /project/server/graphql) */
35
+ serverDir: string; /** Relative paths (from rootDir) — used for display and config resolution */
36
+ dir: {
37
+ build: string;
38
+ client: string;
39
+ server: string;
40
+ }; /** @deprecated Use nitro.graphql.state.directiveSchemas */
41
+ directiveSchemas: string | null; /** @deprecated Use nitro.graphql.state.extendConfigs */
42
+ extendConfigs: string[]; /** @deprecated Use nitro.graphql.state.extendSchemas */
43
+ extendSchemas: string[];
44
+ };
45
+ }
46
+ }
47
+ declare module 'nitro/types' {
48
+ interface NitroOptions {
49
+ graphql?: NitroGraphQLOptions;
50
+ }
51
+ interface NitroRuntimeConfig {
52
+ graphql?: NitroGraphQLOptions;
53
+ }
54
+ interface NitroConfig {
55
+ graphql?: NitroGraphQLOptions;
56
+ }
57
+ }
58
+ //#endregion
59
+ export { GraphQLScanState };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,327 @@
1
+ import { ClientCodegenConfig, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig } from "../../core/types/codegen.mjs";
2
+ import { CoreFederationConfig, CoreSecurityConfig } from "../../core/types/config.mjs";
3
+ import { LocalDirExtendSource as LocalDirExtendSource$1 } from "../../core/extend/loader.mjs";
4
+ import { IResolvers } from "@graphql-tools/utils";
5
+
6
+ //#region src/nitro/types/config.d.ts
7
+ /**
8
+ * File generation control:
9
+ * - false: Do not generate this file
10
+ * - true: Generate at default location
11
+ * - string: Generate at custom path (supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework})
12
+ */
13
+ type FileGenerationConfig = boolean | string;
14
+ /**
15
+ * Service-specific path overrides for external GraphQL services
16
+ * These paths override global config for this specific service
17
+ */
18
+ interface ExternalServicePaths {
19
+ /** SDK file path (overrides global sdk.external config) */
20
+ sdk?: FileGenerationConfig;
21
+ /** Type definitions file path (overrides global types.external config) */
22
+ types?: FileGenerationConfig;
23
+ /** Ofetch client file path (overrides global clientUtils.ofetch config) */
24
+ ofetch?: FileGenerationConfig;
25
+ }
26
+ /**
27
+ * External GraphQL service configuration
28
+ * Extends the core codegen type with Nitro-specific path overrides
29
+ */
30
+ interface ExternalGraphQLService extends ExternalServiceCodegenConfig {
31
+ /**
32
+ * Optional: Service-specific path overrides
33
+ * These paths take precedence over global config (sdk, types, clientUtils)
34
+ * Supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {clientDir}
35
+ */
36
+ paths?: ExternalServicePaths;
37
+ }
38
+ /**
39
+ * Federation configuration
40
+ * Extends core federation with Nitro-specific fields
41
+ */
42
+ interface FederationConfig extends CoreFederationConfig {
43
+ /** Enable Apollo Federation subgraph support */
44
+ enabled: boolean;
45
+ /** Service version for federation */
46
+ serviceVersion?: string;
47
+ /** Service URL for federation gateway */
48
+ serviceUrl?: string;
49
+ }
50
+ /**
51
+ * SDK files configuration
52
+ * Control auto-generation of GraphQL SDK files
53
+ */
54
+ interface SdkConfig {
55
+ /** Enable/disable all SDK files */
56
+ enabled?: boolean;
57
+ /** app/graphql/default/sdk.ts - Main service SDK */
58
+ main?: FileGenerationConfig;
59
+ /** app/graphql/{serviceName}/sdk.ts - External service SDKs */
60
+ external?: FileGenerationConfig;
61
+ }
62
+ /**
63
+ * Type files configuration
64
+ * Control auto-generation of TypeScript type definition files
65
+ */
66
+ interface TypesConfig {
67
+ /** Enable/disable all type files */
68
+ enabled?: boolean;
69
+ /** .nitro/types/nitro-graphql-server.d.ts - Server-side types */
70
+ server?: FileGenerationConfig;
71
+ /** .nitro/types/nitro-graphql-client.d.ts - Client-side types */
72
+ client?: FileGenerationConfig;
73
+ /** .nitro/types/nitro-graphql-client-{serviceName}.d.ts - External service types */
74
+ external?: FileGenerationConfig;
75
+ }
76
+ /**
77
+ * WebSocket transport configuration for subscriptions
78
+ */
79
+ interface WebSocketTransportConfig {
80
+ /**
81
+ * Enable WebSocket transport
82
+ * @default true when subscriptions.enabled is true
83
+ */
84
+ enabled?: boolean;
85
+ /**
86
+ * WebSocket endpoint path
87
+ * @default Same as GraphQL HTTP endpoint
88
+ */
89
+ path?: string;
90
+ /**
91
+ * Connection initialization timeout in milliseconds
92
+ * @default 10000
93
+ */
94
+ connectionTimeout?: number;
95
+ /**
96
+ * Keep-alive ping interval in milliseconds
97
+ * @default 30000
98
+ */
99
+ pingInterval?: number;
100
+ }
101
+ /**
102
+ * SSE (Server-Sent Events) transport configuration for subscriptions
103
+ * Only available with GraphQL Yoga framework
104
+ */
105
+ interface SSETransportConfig {
106
+ /**
107
+ * Enable SSE transport
108
+ * @default true for GraphQL Yoga
109
+ */
110
+ enabled?: boolean;
111
+ }
112
+ /**
113
+ * PubSub configuration for subscription event distribution
114
+ */
115
+ interface PubSubConfig {
116
+ /**
117
+ * Use built-in in-memory PubSub
118
+ * Suitable for single-instance deployments
119
+ * @default true
120
+ */
121
+ useBuiltin?: boolean;
122
+ /**
123
+ * Path to custom PubSub module
124
+ * The module should export a PubSub-compatible instance
125
+ * When provided, built-in PubSub is disabled
126
+ */
127
+ customPath?: string;
128
+ }
129
+ /**
130
+ * GraphQL Subscriptions configuration
131
+ */
132
+ interface SubscriptionsConfig {
133
+ /**
134
+ * Enable subscriptions support
135
+ * @default false
136
+ */
137
+ enabled?: boolean;
138
+ /**
139
+ * WebSocket transport configuration
140
+ */
141
+ websocket?: WebSocketTransportConfig;
142
+ /**
143
+ * SSE transport configuration (GraphQL Yoga only)
144
+ */
145
+ sse?: SSETransportConfig;
146
+ /**
147
+ * PubSub configuration for event distribution
148
+ */
149
+ pubsub?: PubSubConfig;
150
+ }
151
+ /**
152
+ * Client utilities configuration
153
+ * Controls auto-generation of client utility files
154
+ */
155
+ interface ClientUtilsConfig {
156
+ /** Master switch for client utilities */
157
+ enabled?: boolean;
158
+ /** Index file output path */
159
+ index?: FileGenerationConfig;
160
+ /** Ofetch client output path */
161
+ ofetch?: FileGenerationConfig;
162
+ }
163
+ /**
164
+ * Path configuration with placeholders
165
+ * Supports: {buildDir}, {rootDir}, {typesDir}, {serverDir}, {clientDir}, {serviceName}
166
+ */
167
+ interface PathsConfig {
168
+ /** Server GraphQL directory (default: 'server/graphql') */
169
+ serverDir?: string;
170
+ /** Client GraphQL directory (default: 'app/graphql' or 'graphql') */
171
+ clientDir?: string;
172
+ /** Types output directory (default: '{buildDir}/types') */
173
+ typesDir?: string;
174
+ }
175
+ /**
176
+ * Watch mode configuration
177
+ */
178
+ interface WatchConfig {
179
+ /** Debounce time in ms for file change detection */
180
+ debounce?: number;
181
+ }
182
+ /**
183
+ * Runtime file generation configuration
184
+ * Generates resolvers.ts, schema.ts for standalone server usage
185
+ */
186
+ interface RuntimeConfig {
187
+ /** Output directory for runtime files (defaults to '{buildDir}/runtime') */
188
+ outDir?: string;
189
+ /** What to include in generation */
190
+ include?: {
191
+ resolvers?: boolean;
192
+ schema?: boolean;
193
+ index?: boolean;
194
+ };
195
+ }
196
+ /**
197
+ * Explicit paths extend source (legacy)
198
+ */
199
+ interface ExplicitPathsExtendSource {
200
+ /** Explicit manifest path */
201
+ manifest?: string;
202
+ /** Explicit resolver paths (legacy, prefer manifest) */
203
+ resolvers?: string | string[];
204
+ /** Explicit schema paths (legacy, prefer manifest) */
205
+ schemas?: string | string[];
206
+ }
207
+ /**
208
+ * Extend source - package path or detailed config
209
+ * - string: package name or local path, requires nitro-graphql.config.ts in package root
210
+ * - LocalDirExtendSource: local directories with serverDir/clientDir
211
+ * - ExplicitPathsExtendSource: explicit paths (legacy)
212
+ */
213
+ type ExtendSource = string | LocalDirExtendSource | ExplicitPathsExtendSource;
214
+ interface NitroGraphQLOptions {
215
+ framework?: 'graphql-yoga' | 'apollo-server';
216
+ /**
217
+ * Enable/disable GraphQL server functionality
218
+ * When set to false, only external services client types will be generated
219
+ * Server routes, resolvers, schemas, and directives will not be processed
220
+ * @default true
221
+ */
222
+ server?: boolean;
223
+ endpoint?: {
224
+ graphql?: string;
225
+ healthCheck?: string;
226
+ };
227
+ playground?: boolean;
228
+ typedefs?: string[];
229
+ resolvers?: Array<IResolvers<any, any>>;
230
+ loader?: {
231
+ include?: RegExp;
232
+ exclude?: RegExp;
233
+ validate?: boolean;
234
+ };
235
+ codegen?: {
236
+ server?: ServerCodegenConfig;
237
+ client?: ClientCodegenConfig;
238
+ clientSDK?: SdkCodegenConfig;
239
+ };
240
+ /** External GraphQL services to generate types and SDKs for */
241
+ externalServices?: ExternalGraphQLService[];
242
+ /** Apollo Federation configuration */
243
+ federation?: FederationConfig;
244
+ /** Server GraphQL directory path (default: 'server/graphql') */
245
+ serverDir?: string;
246
+ /** Client GraphQL directory path (default: 'app/graphql' for Nuxt, 'graphql' for Nitro) */
247
+ clientDir?: string;
248
+ /** Types directory path (default: '{buildDir}/types') */
249
+ typesDir?: string;
250
+ /**
251
+ * SDK files configuration
252
+ * Set to false to disable all SDK generation
253
+ */
254
+ sdk?: false | SdkConfig;
255
+ /**
256
+ * Type files configuration
257
+ * Set to false to disable all type generation
258
+ */
259
+ types?: false | TypesConfig;
260
+ /**
261
+ * Security configuration for production environments
262
+ * Auto-detects NODE_ENV and applies secure defaults in production
263
+ */
264
+ security?: CoreSecurityConfig;
265
+ /**
266
+ * Extend GraphQL server with external packages
267
+ * Auto-appends /resolvers and /schema to each package path
268
+ * @example extend: ['@myorg/graphql', './generated']
269
+ */
270
+ extend?: ExtendSource[];
271
+ /**
272
+ * Skip local file scanning, use only extend sources
273
+ * When true, only files from `extend` are used (local server/graphql ignored)
274
+ * @default false
275
+ */
276
+ skipLocalScan?: boolean;
277
+ /**
278
+ * GraphQL Subscriptions configuration
279
+ * Enables real-time subscriptions via WebSocket and/or SSE transports
280
+ */
281
+ subscriptions?: SubscriptionsConfig;
282
+ }
283
+ /**
284
+ * Extended options for standalone CLI usage
285
+ * Adds fields that are implicit in Nitro module context (rootDir, buildDir, etc.)
286
+ */
287
+ interface CLIGraphQLOptions extends NitroGraphQLOptions {
288
+ /** Root directory of the project (implicit in Nitro module context) */
289
+ rootDir: string;
290
+ /** Build output directory (implicit in Nitro module context) */
291
+ buildDir: string;
292
+ /** Server GraphQL directory (resolved) */
293
+ serverDir: string;
294
+ /** Client GraphQL directory (resolved) */
295
+ clientDir: string;
296
+ /** Types output directory */
297
+ typesDir: string;
298
+ /**
299
+ * Client utilities configuration
300
+ * Controls auto-generation of client utility files (index.ts, ofetch.ts)
301
+ * Set to false to disable all client utilities generation
302
+ */
303
+ clientUtils?: false | ClientUtilsConfig;
304
+ /**
305
+ * Path configuration with placeholders
306
+ * Allows overriding default paths for generated files
307
+ */
308
+ paths?: PathsConfig;
309
+ /**
310
+ * Patterns to ignore during file scanning
311
+ * Defaults to node_modules and dist directories
312
+ */
313
+ ignore: string[];
314
+ /**
315
+ * Watch mode configuration
316
+ * Enables automatic type regeneration on file changes
317
+ */
318
+ watch?: WatchConfig;
319
+ /**
320
+ * Runtime file generation configuration
321
+ * Generates resolvers.ts, schema.ts for standalone server usage
322
+ * Set to true for default behavior or provide config object
323
+ */
324
+ runtime?: boolean | RuntimeConfig;
325
+ }
326
+ //#endregion
327
+ export { CLIGraphQLOptions, ClientUtilsConfig, ExplicitPathsExtendSource, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, type LocalDirExtendSource$1 as LocalDirExtendSource, NitroGraphQLOptions, PathsConfig, PubSubConfig, RuntimeConfig, SSETransportConfig, SdkConfig, SubscriptionsConfig, TypesConfig, WatchConfig, WebSocketTransportConfig };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { ClientCodegenConfig, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig } from "../../core/types/codegen.mjs";
2
+ import { CoreSecurityConfig } from "../../core/types/config.mjs";
3
+ import { DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "../../core/types/define.mjs";
4
+ import { StandardSchemaV1 } from "../../core/types/standard-schema.mjs";
5
+ import { ApolloServerOptions } from "@apollo/server";
6
+ import { YogaServerOptions } from "graphql-yoga";
7
+ import { H3Event } from "nitro/h3";
8
+ import { NPMConfig } from "#graphql/server";
9
+
10
+ //#region src/nitro/types/define.d.ts
11
+ type DefineServerConfig<T extends NPMConfig = NPMConfig> = T['framework'] extends 'graphql-yoga' ? Partial<YogaServerOptions<H3Event, Partial<H3Event>>> : T['framework'] extends 'apollo-server' ? Partial<ApolloServerOptions<H3Event>> : Partial<YogaServerOptions<H3Event, Partial<H3Event>>> | Partial<ApolloServerOptions<H3Event>>;
12
+ //#endregion
13
+ export { type ClientCodegenConfig, type ClientCodegenConfig as CodegenClientConfig, type ServerCodegenConfig as CodegenServerConfig, type DefineDirectiveConfig, DefineServerConfig, type DirectiveArg, type DirectiveArgument, type DirectiveDefinition, type DirectiveLocationName, type ExternalServiceCodegenConfig, type Flatten, type SdkCodegenConfig as GenericSdkConfig, type GraphQLArgumentType, type GraphQLBaseType, type GraphQLScalarType, type SdkCodegenConfig, type CoreSecurityConfig as SecurityConfig, type ServerCodegenConfig, type StandardSchemaV1 };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ClientCodegenConfig, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig } from "../../core/types/codegen.mjs";
2
+ import { CoreSecurityConfig } from "../../core/types/config.mjs";
3
+ import { ResolverImport, ScannedResolver } from "../../core/types/scanning.mjs";
4
+ import { DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "../../core/types/define.mjs";
5
+ import { StandardSchemaV1 } from "../../core/types/standard-schema.mjs";
6
+ import { DefineServerConfig } from "./define.mjs";
7
+ import { LocalDirExtendSource } from "../../core/extend/loader.mjs";
8
+ import { CLIGraphQLOptions, ClientUtilsConfig, ExplicitPathsExtendSource, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, NitroGraphQLOptions, PathsConfig, PubSubConfig, RuntimeConfig, SSETransportConfig, SdkConfig, SubscriptionsConfig, TypesConfig, WatchConfig, WebSocketTransportConfig } from "./config.mjs";
9
+ import { GraphQLScanState } from "./augmentation.mjs";
10
+ export { type CLIGraphQLOptions, type ClientCodegenConfig, type ClientUtilsConfig, type ClientCodegenConfig as CodegenClientConfig, type ServerCodegenConfig as CodegenServerConfig, type DefineDirectiveConfig, type DefineServerConfig, type DirectiveArg, type DirectiveArgument, type DirectiveDefinition, type DirectiveLocationName, type ExplicitPathsExtendSource, type ExtendSource, type ExternalGraphQLService, type ExternalServiceCodegenConfig, type ExternalServicePaths, type FederationConfig, type FileGenerationConfig, type Flatten, type SdkCodegenConfig as GenericSdkConfig, type GraphQLArgumentType, type GraphQLBaseType, type GraphQLScalarType, type GraphQLScanState, type LocalDirExtendSource, type NitroGraphQLOptions, type PathsConfig, type PubSubConfig, type ResolverImport, type RuntimeConfig, type SSETransportConfig, type ScannedResolver, type SdkCodegenConfig, type SdkConfig, type CoreSecurityConfig as SecurityConfig, type ServerCodegenConfig, type StandardSchemaV1, type SubscriptionsConfig, type TypesConfig, type WatchConfig, type WebSocketTransportConfig };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/nitro/virtual/debug-info.d.ts
4
+ declare const debugInfo: {
5
+ id: string;
6
+ getCode: (nitro: Nitro) => string;
7
+ };
8
+ //#endregion
9
+ export { debugInfo };
@@ -0,0 +1,35 @@
1
+ import { safeGenerateModuleCode } from "./utils.mjs";
2
+ //#region src/nitro/virtual/debug-info.ts
3
+ const debugInfo = {
4
+ id: "#nitro-graphql/debug-info",
5
+ getCode: (nitro) => {
6
+ const virtualModuleCodes = {
7
+ "server-schemas": safeGenerateModuleCode(nitro, "#nitro-graphql/server-schemas"),
8
+ "server-resolvers": safeGenerateModuleCode(nitro, "#nitro-graphql/server-resolvers"),
9
+ "server-directives": safeGenerateModuleCode(nitro, "#nitro-graphql/server-directives"),
10
+ "module-config": safeGenerateModuleCode(nitro, "#nitro-graphql/module-config"),
11
+ "graphql-config": safeGenerateModuleCode(nitro, "#nitro-graphql/graphql-config"),
12
+ "pubsub": safeGenerateModuleCode(nitro, "#nitro-graphql/pubsub")
13
+ };
14
+ const info = {
15
+ isDev: nitro.options.dev,
16
+ framework: nitro.options.framework.name,
17
+ graphqlFramework: nitro.options.graphql?.framework,
18
+ federation: nitro.options.graphql?.federation,
19
+ scanned: {
20
+ schemas: nitro.graphql.state.schemas.length,
21
+ schemaFiles: [...nitro.graphql.state.schemas],
22
+ resolvers: nitro.graphql.state.resolvers.length,
23
+ resolverFiles: [...nitro.graphql.state.resolvers],
24
+ directives: nitro.graphql.state.directives.length,
25
+ directiveFiles: [...nitro.graphql.state.directives],
26
+ documents: nitro.graphql.state.documents.length,
27
+ documentFiles: [...nitro.graphql.state.documents]
28
+ },
29
+ virtualModules: virtualModuleCodes
30
+ };
31
+ return `export const debugInfo = ${JSON.stringify(info, null, 2)};`;
32
+ }
33
+ };
34
+ //#endregion
35
+ export { debugInfo };
@@ -0,0 +1,9 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/nitro/virtual/graphql-config.d.ts
4
+ declare const graphqlConfig: {
5
+ id: string;
6
+ getCode: (nitro: Nitro) => string;
7
+ };
8
+ //#endregion
9
+ export { graphqlConfig };
@@ -0,0 +1,33 @@
1
+ import { resolve } from "pathe";
2
+ import { existsSync } from "node:fs";
3
+ //#region src/nitro/virtual/graphql-config.ts
4
+ const graphqlConfig = {
5
+ id: "#nitro-graphql/graphql-config",
6
+ getCode: (nitro) => {
7
+ const localConfigPath = resolve(nitro.graphql.serverDir, "config.ts");
8
+ const extendConfigs = [...nitro.graphql.state.extendConfigs];
9
+ const hasLocalConfig = existsSync(localConfigPath);
10
+ if (!hasLocalConfig && extendConfigs.length === 0) return `const importedConfig = {}
11
+ export { importedConfig }
12
+ `;
13
+ const imports = ["import { defu } from 'defu'"];
14
+ const configNames = [];
15
+ extendConfigs.forEach((configPath, index) => {
16
+ const configName = `extendConfig${index}`;
17
+ imports.push(`import ${configName} from '${configPath}'`);
18
+ configNames.push(configName);
19
+ });
20
+ if (hasLocalConfig) {
21
+ imports.push(`import localConfig from '${localConfigPath}'`);
22
+ configNames.push("localConfig");
23
+ }
24
+ const mergeArgs = configNames.reverse().join(", ");
25
+ return `${imports.join("\n")}
26
+
27
+ const importedConfig = defu(${mergeArgs})
28
+ export { importedConfig }
29
+ `;
30
+ }
31
+ };
32
+ //#endregion
33
+ export { graphqlConfig };
@@ -0,0 +1,25 @@
1
+ import { debugInfo } from "./debug-info.mjs";
2
+ import { graphqlConfig } from "./graphql-config.mjs";
3
+ import { moduleConfig } from "./module-config.mjs";
4
+ import { pubsub } from "./pubsub.mjs";
5
+ import { serverDirectives } from "./server-directives.mjs";
6
+ import { serverResolvers } from "./server-resolvers.mjs";
7
+ import { serverSchemas } from "./server-schemas.mjs";
8
+ import { validationSchemas } from "./validation-schemas.mjs";
9
+ import { Nitro } from "nitro/types";
10
+
11
+ //#region src/nitro/virtual/index.d.ts
12
+ /**
13
+ * Register all virtual modules with Nitro using eager snapshots.
14
+ * Code is generated immediately and captured as a string,
15
+ * so Rolldown always reads a consistent state.
16
+ */
17
+ declare function registerAllVirtualModules(nitro: Nitro): void;
18
+ /**
19
+ * Refresh virtual module snapshots after a rescan.
20
+ * Call this after nitro.scan* arrays have been fully updated
21
+ * (including extend results) to re-snapshot the virtual modules.
22
+ */
23
+ declare function refreshVirtualModules(nitro: Nitro): void;
24
+ //#endregion
25
+ export { debugInfo, graphqlConfig, moduleConfig, pubsub, refreshVirtualModules, registerAllVirtualModules, serverDirectives, serverResolvers, serverSchemas, validationSchemas };
@@ -0,0 +1,45 @@
1
+ import { debugInfo } from "./debug-info.mjs";
2
+ import { graphqlConfig } from "./graphql-config.mjs";
3
+ import { moduleConfig } from "./module-config.mjs";
4
+ import { pubsub } from "./pubsub.mjs";
5
+ import { serverDirectives } from "./server-directives.mjs";
6
+ import { serverResolvers } from "./server-resolvers.mjs";
7
+ import { serverSchemas } from "./server-schemas.mjs";
8
+ import { validationSchemas } from "./validation-schemas.mjs";
9
+ //#region src/nitro/virtual/index.ts
10
+ const allModules = [
11
+ serverSchemas,
12
+ serverResolvers,
13
+ serverDirectives,
14
+ graphqlConfig,
15
+ moduleConfig,
16
+ validationSchemas,
17
+ pubsub,
18
+ debugInfo
19
+ ];
20
+ /**
21
+ * Register all virtual modules with Nitro using eager snapshots.
22
+ * Code is generated immediately and captured as a string,
23
+ * so Rolldown always reads a consistent state.
24
+ */
25
+ function registerAllVirtualModules(nitro) {
26
+ nitro.options.virtual ??= {};
27
+ for (const mod of allModules) {
28
+ const code = mod.getCode(nitro);
29
+ nitro.options.virtual[mod.id] = () => code;
30
+ }
31
+ }
32
+ /**
33
+ * Refresh virtual module snapshots after a rescan.
34
+ * Call this after nitro.scan* arrays have been fully updated
35
+ * (including extend results) to re-snapshot the virtual modules.
36
+ */
37
+ function refreshVirtualModules(nitro) {
38
+ if (!nitro.options.virtual) return;
39
+ for (const mod of allModules) {
40
+ const code = mod.getCode(nitro);
41
+ nitro.options.virtual[mod.id] = () => code;
42
+ }
43
+ }
44
+ //#endregion
45
+ export { debugInfo, graphqlConfig, moduleConfig, pubsub, refreshVirtualModules, registerAllVirtualModules, serverDirectives, serverResolvers, serverSchemas, validationSchemas };
@@ -0,0 +1,9 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/nitro/virtual/module-config.d.ts
4
+ declare const moduleConfig: {
5
+ id: string;
6
+ getCode: (nitro: Nitro) => string;
7
+ };
8
+ //#endregion
9
+ export { moduleConfig };
@@ -0,0 +1,10 @@
1
+ //#region src/nitro/virtual/module-config.ts
2
+ const moduleConfig = {
3
+ id: "#nitro-graphql/module-config",
4
+ getCode: (nitro) => {
5
+ const config = nitro.options.graphql || {};
6
+ return `export const moduleConfig = ${JSON.stringify(config, null, 2)};`;
7
+ }
8
+ };
9
+ //#endregion
10
+ export { moduleConfig };
@@ -0,0 +1,9 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/nitro/virtual/pubsub.d.ts
4
+ declare const pubsub: {
5
+ id: string;
6
+ getCode: (nitro: Nitro) => string;
7
+ };
8
+ //#endregion
9
+ export { pubsub };
@@ -0,0 +1,17 @@
1
+ //#region src/nitro/virtual/pubsub.ts
2
+ const pubsub = {
3
+ id: "#nitro-graphql/pubsub",
4
+ getCode: (nitro) => {
5
+ const subscriptions = nitro.options.graphql?.subscriptions;
6
+ const pubsubConfig = subscriptions?.pubsub;
7
+ if (!subscriptions?.enabled) return `export const pubsub = null`;
8
+ if (pubsubConfig?.customPath) return `import customPubSub from '${pubsubConfig.customPath}'
9
+ export const pubsub = customPubSub
10
+ `;
11
+ return `import { createPubSub } from 'nitro-graphql/pubsub'
12
+ export const pubsub = createPubSub()
13
+ `;
14
+ }
15
+ };
16
+ //#endregion
17
+ export { pubsub };
@@ -0,0 +1,9 @@
1
+ import { Nitro } from "nitro/types";
2
+
3
+ //#region src/nitro/virtual/server-directives.d.ts
4
+ declare const serverDirectives: {
5
+ id: string;
6
+ getCode: (nitro: Nitro) => string;
7
+ };
8
+ //#endregion
9
+ export { serverDirectives };
@@ -0,0 +1,12 @@
1
+ import { generateImportModule } from "./utils.mjs";
2
+ //#region src/nitro/virtual/server-directives.ts
3
+ const serverDirectives = {
4
+ id: "#nitro-graphql/server-directives",
5
+ getCode: (nitro) => {
6
+ const imports = [...nitro.graphql.state.directives];
7
+ if (!imports.length) return "export const directives = []";
8
+ return generateImportModule(imports, "directives", "directive");
9
+ }
10
+ };
11
+ //#endregion
12
+ export { serverDirectives };