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

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 (242) hide show
  1. package/README.md +31 -1196
  2. package/dist/cli/adapter.d.mts +13 -0
  3. package/dist/cli/adapter.mjs +67 -0
  4. package/dist/cli/commands/build.d.mts +21 -0
  5. package/dist/cli/commands/build.mjs +50 -0
  6. package/dist/cli/commands/dev.d.mts +40 -0
  7. package/dist/cli/commands/dev.mjs +74 -0
  8. package/dist/cli/commands/generate.d.mts +25 -0
  9. package/dist/cli/commands/generate.mjs +198 -0
  10. package/dist/cli/commands/index.d.mts +5 -0
  11. package/dist/cli/commands/index.mjs +5 -0
  12. package/dist/cli/commands/init.d.mts +45 -0
  13. package/dist/cli/commands/init.mjs +195 -0
  14. package/dist/cli/commands/validate.d.mts +9 -0
  15. package/dist/cli/commands/validate.mjs +65 -0
  16. package/dist/cli/completions.d.mts +6 -0
  17. package/dist/cli/completions.mjs +32 -0
  18. package/dist/cli/config.d.mts +18 -0
  19. package/dist/cli/config.mjs +19 -0
  20. package/dist/cli/index.d.mts +26 -0
  21. package/dist/cli/index.mjs +315 -0
  22. package/dist/cli/server/debug-handler.d.mts +9 -0
  23. package/dist/cli/server/debug-handler.mjs +68 -0
  24. package/dist/cli/server/dev-server.d.mts +29 -0
  25. package/dist/cli/server/dev-server.mjs +62 -0
  26. package/dist/cli/server/graphql-handler.d.mts +21 -0
  27. package/dist/cli/server/graphql-handler.mjs +43 -0
  28. package/dist/cli/server/health-handler.d.mts +12 -0
  29. package/dist/cli/server/health-handler.mjs +29 -0
  30. package/dist/cli/server/loader.d.mts +33 -0
  31. package/dist/cli/server/loader.mjs +144 -0
  32. package/dist/cli/server/sandbox-handler.d.mts +12 -0
  33. package/dist/cli/server/sandbox-handler.mjs +17 -0
  34. package/dist/cli/server/watcher.d.mts +20 -0
  35. package/dist/cli/server/watcher.mjs +64 -0
  36. package/dist/cli/server/ws-handler.d.mts +28 -0
  37. package/dist/cli/server/ws-handler.mjs +48 -0
  38. package/dist/config.d.mts +2 -0
  39. package/dist/config.mjs +2 -0
  40. package/dist/core/codegen/client.d.mts +42 -0
  41. package/dist/core/codegen/client.mjs +551 -0
  42. package/dist/core/codegen/document-loader.d.mts +9 -0
  43. package/dist/core/codegen/document-loader.mjs +16 -0
  44. package/dist/core/codegen/index.d.mts +8 -0
  45. package/dist/core/codegen/index.mjs +8 -0
  46. package/dist/core/codegen/plugin.d.mts +19 -0
  47. package/dist/core/codegen/plugin.mjs +29 -0
  48. package/dist/core/codegen/runtime.d.mts +17 -0
  49. package/dist/core/codegen/runtime.mjs +61 -0
  50. package/dist/core/codegen/schema-loader.d.mts +27 -0
  51. package/dist/core/codegen/schema-loader.mjs +126 -0
  52. package/dist/core/codegen/server.d.mts +27 -0
  53. package/dist/core/codegen/server.mjs +142 -0
  54. package/dist/core/codegen/validation.d.mts +17 -0
  55. package/dist/core/codegen/validation.mjs +33 -0
  56. package/dist/core/config.d.mts +45 -0
  57. package/dist/core/config.mjs +76 -0
  58. package/dist/core/constants.d.mts +188 -0
  59. package/dist/core/constants.mjs +208 -0
  60. package/dist/core/debug/index.d.mts +2 -0
  61. package/dist/core/debug/index.mjs +2 -0
  62. package/dist/core/debug/template.d.mts +52 -0
  63. package/dist/core/debug/template.mjs +384 -0
  64. package/dist/core/extend/index.d.mts +2 -0
  65. package/dist/core/extend/index.mjs +2 -0
  66. package/dist/core/extend/loader.d.mts +40 -0
  67. package/dist/core/extend/loader.mjs +196 -0
  68. package/dist/core/index.d.mts +33 -0
  69. package/dist/core/index.mjs +28 -0
  70. package/dist/core/manifest.d.mts +56 -0
  71. package/dist/core/manifest.mjs +100 -0
  72. package/dist/core/pubsub/index.d.mts +109 -0
  73. package/dist/core/pubsub/index.mjs +146 -0
  74. package/dist/core/scanning/ast-scanner.d.mts +27 -0
  75. package/dist/core/scanning/ast-scanner.mjs +114 -0
  76. package/dist/core/scanning/common.d.mts +25 -0
  77. package/dist/core/scanning/common.mjs +57 -0
  78. package/dist/core/scanning/directives.d.mts +13 -0
  79. package/dist/core/scanning/directives.mjs +28 -0
  80. package/dist/core/scanning/documents.d.mts +20 -0
  81. package/dist/core/scanning/documents.mjs +36 -0
  82. package/dist/core/scanning/index.d.mts +7 -0
  83. package/dist/core/scanning/index.mjs +7 -0
  84. package/dist/core/scanning/resolvers.d.mts +14 -0
  85. package/dist/core/scanning/resolvers.mjs +58 -0
  86. package/dist/core/scanning/schemas.d.mts +13 -0
  87. package/dist/core/scanning/schemas.mjs +50 -0
  88. package/dist/core/schema/builder.d.mts +59 -0
  89. package/dist/core/schema/builder.mjs +76 -0
  90. package/dist/core/schema/federation.d.mts +33 -0
  91. package/dist/core/schema/federation.mjs +38 -0
  92. package/dist/core/schema/index.d.mts +3 -0
  93. package/dist/core/schema/index.mjs +3 -0
  94. package/dist/core/server/index.d.mts +4 -0
  95. package/dist/core/server/index.mjs +3 -0
  96. package/dist/core/server/sandbox.d.mts +18 -0
  97. package/dist/core/server/sandbox.mjs +38 -0
  98. package/dist/core/server/types.d.mts +54 -0
  99. package/dist/core/server/types.mjs +1 -0
  100. package/dist/core/server/yoga.d.mts +42 -0
  101. package/dist/core/server/yoga.mjs +87 -0
  102. package/dist/core/types/adapter.d.mts +55 -0
  103. package/dist/core/types/adapter.mjs +1 -0
  104. package/dist/core/types/codegen.d.mts +136 -0
  105. package/dist/core/types/codegen.mjs +1 -0
  106. package/dist/core/types/config.d.mts +188 -0
  107. package/dist/core/types/config.mjs +1 -0
  108. package/dist/{utils/define.d.ts → core/types/define.d.mts} +2 -30
  109. package/dist/core/types/define.mjs +1 -0
  110. package/dist/core/types/index.d.mts +5 -0
  111. package/dist/core/types/index.mjs +1 -0
  112. package/dist/core/types/scanning.d.mts +64 -0
  113. package/dist/core/types/scanning.mjs +1 -0
  114. package/dist/{utils/directive-parser.d.ts → core/utils/directive-parser.d.mts} +18 -4
  115. package/dist/{utils/directive-parser.js → core/utils/directive-parser.mjs} +29 -36
  116. package/dist/core/utils/errors.d.mts +77 -0
  117. package/dist/core/utils/errors.mjs +91 -0
  118. package/dist/core/utils/file-io.d.mts +24 -0
  119. package/dist/core/utils/file-io.mjs +45 -0
  120. package/dist/core/utils/imports.d.mts +15 -0
  121. package/dist/core/utils/imports.mjs +24 -0
  122. package/dist/core/utils/index.d.mts +7 -0
  123. package/dist/core/utils/index.mjs +7 -0
  124. package/dist/core/utils/logger.d.mts +18 -0
  125. package/dist/core/utils/logger.mjs +36 -0
  126. package/dist/core/utils/ofetch-templates.d.mts +30 -0
  127. package/dist/core/utils/ofetch-templates.mjs +134 -0
  128. package/dist/core/utils/runtime.d.mts +74 -0
  129. package/dist/core/utils/runtime.mjs +109 -0
  130. package/dist/core/utils/subscribe-templates.d.mts +8 -0
  131. package/dist/core/utils/subscribe-templates.mjs +58 -0
  132. package/dist/core/validation/external-services.d.mts +11 -0
  133. package/dist/core/validation/external-services.mjs +33 -0
  134. package/dist/core/validation/index.d.mts +2 -0
  135. package/dist/core/validation/index.mjs +2 -0
  136. package/dist/core/watcher/index.d.mts +107 -0
  137. package/dist/core/watcher/index.mjs +140 -0
  138. package/dist/define.d.mts +294 -0
  139. package/dist/define.mjs +323 -0
  140. package/dist/index.d.mts +6 -0
  141. package/dist/index.mjs +5 -0
  142. package/dist/nitro/adapter.d.mts +28 -0
  143. package/dist/nitro/adapter.mjs +90 -0
  144. package/dist/{utils/apollo.d.ts → nitro/apollo.d.mts} +3 -3
  145. package/dist/nitro/apollo.mjs +57 -0
  146. package/dist/nitro/codegen.d.mts +18 -0
  147. package/dist/nitro/codegen.mjs +171 -0
  148. package/dist/nitro/config.d.mts +50 -0
  149. package/dist/nitro/config.mjs +55 -0
  150. package/dist/nitro/index.d.mts +45 -0
  151. package/dist/nitro/index.mjs +63 -0
  152. package/dist/{utils/path-resolver.d.ts → nitro/paths.d.mts} +8 -25
  153. package/dist/nitro/paths.mjs +97 -0
  154. package/dist/nitro/rollup.d.mts +6 -0
  155. package/dist/nitro/rollup.mjs +52 -0
  156. package/dist/nitro/routes/apollo-sandbox-script.d.mts +6 -0
  157. package/dist/nitro/routes/apollo-sandbox-script.mjs +12 -0
  158. package/dist/nitro/routes/apollo-server-ws.d.mts +15 -0
  159. package/dist/nitro/routes/apollo-server-ws.mjs +50 -0
  160. package/dist/nitro/routes/apollo-server.d.mts +6 -0
  161. package/dist/nitro/routes/apollo-server.mjs +69 -0
  162. package/dist/{routes/debug.d.ts → nitro/routes/debug.d.mts} +12 -19
  163. package/dist/nitro/routes/debug.mjs +98 -0
  164. package/dist/nitro/routes/graphql-yoga-ws.d.mts +12 -0
  165. package/dist/nitro/routes/graphql-yoga-ws.mjs +50 -0
  166. package/dist/nitro/routes/graphql-yoga.d.mts +12 -0
  167. package/dist/nitro/routes/graphql-yoga.mjs +39 -0
  168. package/dist/nitro/routes/health.d.mts +10 -0
  169. package/dist/{routes/health.js → nitro/routes/health.mjs} +5 -6
  170. package/dist/nitro/setup/extend-loader.d.mts +16 -0
  171. package/dist/nitro/setup/extend-loader.mjs +80 -0
  172. package/dist/nitro/setup/file-watcher.d.mts +18 -0
  173. package/dist/nitro/setup/file-watcher.mjs +62 -0
  174. package/dist/nitro/setup/logging.d.mts +16 -0
  175. package/dist/nitro/setup/logging.mjs +64 -0
  176. package/dist/nitro/setup/rollup-integration.d.mts +24 -0
  177. package/dist/nitro/setup/rollup-integration.mjs +64 -0
  178. package/dist/nitro/setup/routes.d.mts +13 -0
  179. package/dist/nitro/setup/routes.mjs +69 -0
  180. package/dist/nitro/setup/scanner.d.mts +59 -0
  181. package/dist/nitro/setup/scanner.mjs +118 -0
  182. package/dist/nitro/setup/ts-config.d.mts +10 -0
  183. package/dist/nitro/setup/ts-config.mjs +67 -0
  184. package/dist/nitro/setup.d.mts +11 -0
  185. package/dist/nitro/setup.mjs +189 -0
  186. package/dist/nitro/types.d.mts +549 -0
  187. package/dist/nitro/types.mjs +1 -0
  188. package/dist/nitro/virtual/generators.d.mts +38 -0
  189. package/dist/nitro/virtual/generators.mjs +190 -0
  190. package/dist/nitro/virtual/stubs.d.mts +21 -0
  191. package/dist/nitro/virtual/stubs.mjs +31 -0
  192. package/dist/{ecosystem/nuxt.d.ts → nuxt.d.mts} +1 -1
  193. package/dist/nuxt.mjs +111 -0
  194. package/dist/{graphql/server.d.ts → stubs/index.d.mts} +5 -1
  195. package/dist/stubs/index.mjs +1 -0
  196. package/dist/subscribe/index.d.mts +78 -0
  197. package/dist/subscribe/index.mjs +205 -0
  198. package/native/index.d.ts +20 -0
  199. package/native/index.js +585 -0
  200. package/package.json +202 -112
  201. package/dist/ecosystem/nuxt.js +0 -67
  202. package/dist/graphql/index.d.ts +0 -5
  203. package/dist/graphql/index.js +0 -1
  204. package/dist/graphql/server.js +0 -1
  205. package/dist/index.d.ts +0 -8
  206. package/dist/index.js +0 -318
  207. package/dist/rollup.js +0 -277
  208. package/dist/routes/apollo-server.d.ts +0 -6
  209. package/dist/routes/apollo-server.js +0 -89
  210. package/dist/routes/debug.js +0 -449
  211. package/dist/routes/graphql-yoga.d.ts +0 -6
  212. package/dist/routes/graphql-yoga.js +0 -91
  213. package/dist/routes/health.d.ts +0 -10
  214. package/dist/types/index.d.ts +0 -246
  215. package/dist/types/standard-schema.d.ts +0 -59
  216. package/dist/utils/apollo.js +0 -61
  217. package/dist/utils/client-codegen.d.ts +0 -38
  218. package/dist/utils/client-codegen.js +0 -290
  219. package/dist/utils/define.js +0 -57
  220. package/dist/utils/file-generator.d.ts +0 -37
  221. package/dist/utils/file-generator.js +0 -72
  222. package/dist/utils/index.d.ts +0 -39
  223. package/dist/utils/index.js +0 -278
  224. package/dist/utils/path-resolver.js +0 -127
  225. package/dist/utils/server-codegen.d.ts +0 -7
  226. package/dist/utils/server-codegen.js +0 -136
  227. package/dist/utils/type-generation.d.ts +0 -7
  228. package/dist/utils/type-generation.js +0 -360
  229. package/dist/virtual/debug-info.d.ts +0 -9
  230. package/dist/virtual/debug-info.js +0 -26
  231. package/dist/virtual/graphql-config.d.ts +0 -9
  232. package/dist/virtual/graphql-config.js +0 -10
  233. package/dist/virtual/module-config.d.ts +0 -9
  234. package/dist/virtual/module-config.js +0 -10
  235. package/dist/virtual/server-directives.d.ts +0 -11
  236. package/dist/virtual/server-directives.js +0 -10
  237. package/dist/virtual/server-resolvers.d.ts +0 -11
  238. package/dist/virtual/server-resolvers.js +0 -10
  239. package/dist/virtual/server-schemas.d.ts +0 -11
  240. package/dist/virtual/server-schemas.js +0 -10
  241. package/dist/vite.d.ts +0 -25
  242. package/dist/vite.js +0 -40
@@ -0,0 +1,87 @@
1
+ import { BASE_SCHEMA as BASE_SCHEMA$1, createMergedSchema } from "../schema/builder.mjs";
2
+ import defu from "defu";
3
+ import { createYoga } from "graphql-yoga";
4
+ //#region src/core/server/yoga.ts
5
+ /**
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
+ * Apollo Sandbox HTML template
12
+ * Shared between CLI and Nitro for consistent playground experience
13
+ */
14
+ const apolloSandboxHtml = `<!DOCTYPE html>
15
+ <html lang="en">
16
+ <head>
17
+ <link rel="preload" href="/api/graphql/sandbox.js" as="script">
18
+ </head>
19
+ <body style="margin: 0; overflow-x: hidden; overflow-y: hidden">
20
+ <div id="sandbox" style="height:100vh; width:100vw;"></div>
21
+ <script src="/api/graphql/sandbox.js"><\/script>
22
+ <script>
23
+ new window.EmbeddedSandbox({
24
+ target: "#sandbox",
25
+ initialEndpoint: window.location.href.replace('/sandbox.js', ''),
26
+ hideCookieToggle: false,
27
+ initialState: {
28
+ includeCookies: true
29
+ }
30
+ });
31
+ <\/script>
32
+ </body>
33
+ </html>`;
34
+ /**
35
+ * Create a GraphQL Yoga server instance
36
+ *
37
+ * This is the core server factory used by both:
38
+ * - Nitro routes (via virtual module imports)
39
+ * - CLI dev server (via file-based loading)
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // In Nitro route
44
+ * const server = await createYogaServer({
45
+ * schemas, resolvers, directives, moduleConfig,
46
+ * security: moduleConfig.security,
47
+ * importedConfig,
48
+ * })
49
+ *
50
+ * // In CLI
51
+ * const server = await createYogaServer({
52
+ * schemas: await loadSchemas(ctx),
53
+ * resolvers: await loadResolvers(ctx),
54
+ * moduleConfig: { federation: ctx.config.federation },
55
+ * endpoint: '/graphql',
56
+ * })
57
+ * ```
58
+ */
59
+ async function createYogaServer(options) {
60
+ const { schemas, resolvers, directives, moduleConfig, endpoint = "/api/graphql", security, importedConfig } = options;
61
+ const schema = await createMergedSchema({
62
+ schemas,
63
+ resolvers,
64
+ directives: directives || [],
65
+ moduleConfig
66
+ });
67
+ const securityConfig = security || {
68
+ introspection: true,
69
+ playground: true,
70
+ maskErrors: false,
71
+ disableSuggestions: false
72
+ };
73
+ const yoga = createYoga(defu({
74
+ schema,
75
+ graphqlEndpoint: endpoint,
76
+ landingPage: securityConfig.playground,
77
+ graphiql: securityConfig.playground ? { defaultQuery: "# Welcome to GraphQL\n#\n# Try running a query!\n" } : false,
78
+ renderGraphiQL: securityConfig.playground ? () => apolloSandboxHtml : void 0,
79
+ maskedErrors: securityConfig.maskErrors
80
+ }, importedConfig));
81
+ return {
82
+ fetch: (request, context) => Promise.resolve(yoga.fetch(request, context)),
83
+ schema
84
+ };
85
+ }
86
+ //#endregion
87
+ export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
@@ -0,0 +1,55 @@
1
+ import { CoreConfig, CoreContext, CoreLogger } from "./config.mjs";
2
+ import { ScanContext, ScanResult, ScannedResolver } from "./scanning.mjs";
3
+ //#region src/core/types/adapter.d.ts
4
+ /**
5
+ * Framework adapter interface
6
+ * Adapters convert framework-specific types to core types
7
+ */
8
+ interface FrameworkAdapter<TFramework = unknown> {
9
+ /** Adapter name for logging */
10
+ readonly name: string;
11
+ /** Create core config from framework instance */
12
+ createCoreConfig: (framework: TFramework) => CoreConfig;
13
+ /** Create core context from framework instance */
14
+ createCoreContext: (framework: TFramework) => CoreContext;
15
+ /** Create scan context from framework instance */
16
+ createScanContext: (framework: TFramework) => ScanContext;
17
+ /** Get framework logger adapted to CoreLogger interface */
18
+ getLogger: (framework: TFramework) => CoreLogger;
19
+ }
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
+ //#endregion
55
+ export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,136 @@
1
+ import { Source } from "@graphql-tools/utils";
2
+ import { GraphQLSchema } from "graphql";
3
+
4
+ //#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
+ /**
13
+ * Server codegen configuration
14
+ */
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
+ }
27
+ /**
28
+ * Client codegen configuration
29
+ */
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>;
42
+ typedDocumentNode?: boolean;
43
+ [key: string]: unknown;
44
+ }
45
+ /**
46
+ * SDK codegen configuration
47
+ */
48
+ interface SdkCodegenConfig extends ClientCodegenConfig {
49
+ [key: string]: unknown;
50
+ }
51
+ /**
52
+ * Input for server type generation
53
+ */
54
+ interface ServerCodegenInput {
55
+ /** GraphQL framework name */
56
+ framework: string;
57
+ /** Parsed GraphQL schema (optional if schemaString provided) */
58
+ schema?: GraphQLSchema;
59
+ /** Schema as string (avoids graphql instance mismatch issues) */
60
+ schemaString?: string;
61
+ /** Server codegen configuration */
62
+ config?: ServerCodegenConfig;
63
+ /** Whether federation is enabled */
64
+ federationEnabled?: boolean;
65
+ /** Output filename (optional) */
66
+ outputPath?: string;
67
+ }
68
+ /**
69
+ * Result of server type generation
70
+ */
71
+ interface ServerCodegenResult {
72
+ /** Generated TypeScript types content */
73
+ types: string;
74
+ /** Printed GraphQL schema */
75
+ schemaString: string;
76
+ }
77
+ /**
78
+ * Input for client type generation
79
+ */
80
+ interface ClientCodegenInput {
81
+ /** Parsed GraphQL schema (optional if schemaString provided) */
82
+ schema?: GraphQLSchema;
83
+ /** Schema as string (avoids graphql instance mismatch issues) */
84
+ schemaString?: string;
85
+ /** Loaded GraphQL documents */
86
+ documents: Source[];
87
+ /** Client codegen configuration */
88
+ config?: ClientCodegenConfig;
89
+ /** SDK codegen configuration */
90
+ sdkConfig?: SdkCodegenConfig;
91
+ /** Output filename (optional) */
92
+ outputPath?: string;
93
+ /** Service name for external services */
94
+ serviceName?: string;
95
+ /** Virtual types import path */
96
+ virtualTypesPath?: string;
97
+ /** Generation options */
98
+ options?: {
99
+ silent?: boolean;
100
+ isInitial?: boolean;
101
+ };
102
+ }
103
+ /**
104
+ * Result of client type generation
105
+ */
106
+ interface ClientCodegenResult {
107
+ /** Generated TypeScript types content */
108
+ types: string;
109
+ /** Generated SDK content */
110
+ sdk: string;
111
+ }
112
+ /**
113
+ * External service configuration for codegen
114
+ */
115
+ interface ExternalServiceCodegenConfig {
116
+ name: string;
117
+ schema: string | string[];
118
+ endpoint: string;
119
+ headers?: Record<string, string> | (() => Record<string, string>);
120
+ documents?: string[];
121
+ downloadSchema?: boolean | 'once' | 'always' | 'manual';
122
+ downloadPath?: string;
123
+ codegen?: {
124
+ client?: ClientCodegenConfig;
125
+ clientSDK?: SdkCodegenConfig;
126
+ };
127
+ }
128
+ /**
129
+ * Schema loading options
130
+ */
131
+ interface SchemaLoadOptions {
132
+ headers?: Record<string, string>;
133
+ loaders?: unknown[];
134
+ }
135
+ //#endregion
136
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,188 @@
1
+ import { GraphQLFramework } from "../constants.mjs";
2
+
3
+ //#region src/core/types/config.d.ts
4
+ /**
5
+ * Core logger interface
6
+ * Abstracts logging functionality for framework independence
7
+ */
8
+ interface CoreLogger {
9
+ info: (message: string, ...args: unknown[]) => void;
10
+ warn: (message: string, ...args: unknown[]) => void;
11
+ error: (message: string, ...args: unknown[]) => void;
12
+ success: (message: string, ...args: unknown[]) => void;
13
+ debug: (message: string, ...args: unknown[]) => void;
14
+ }
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
+ /**
27
+ * Security configuration options
28
+ */
29
+ interface CoreSecurityConfig {
30
+ /** Enable/disable GraphQL introspection */
31
+ introspection?: boolean;
32
+ /** Enable/disable GraphQL playground */
33
+ playground?: boolean;
34
+ /** Enable/disable error masking in responses */
35
+ maskErrors?: boolean;
36
+ /** Disable field suggestions in error messages */
37
+ disableSuggestions?: boolean;
38
+ }
39
+ /**
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
62
+ */
63
+ interface CoreFederationConfig {
64
+ /** Enable federation support */
65
+ enabled?: boolean;
66
+ /** Service name for federation */
67
+ serviceName?: string;
68
+ }
69
+ /**
70
+ * Path configuration with placeholders
71
+ */
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;
114
+ }
115
+ /**
116
+ * Core GraphQL options
117
+ * Framework-agnostic GraphQL configuration
118
+ */
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;
140
+ }
141
+ /**
142
+ * Core configuration
143
+ * Main configuration interface that replaces Nitro-specific options
144
+ */
145
+ interface CoreConfig {
146
+ /** Root directory of the project */
147
+ rootDir: string;
148
+ /** Build output directory */
149
+ buildDir: string;
150
+ /** Server GraphQL directory */
151
+ serverDir: string;
152
+ /** Client GraphQL directory */
153
+ clientDir: string;
154
+ /** Types output directory */
155
+ typesDir: string;
156
+ /** GraphQL framework to use */
157
+ framework: GraphQLFramework;
158
+ /** Whether running in Nuxt context */
159
+ isNuxt: boolean;
160
+ /** Whether running in development mode */
161
+ isDev: boolean;
162
+ /** GraphQL options */
163
+ graphqlOptions: CoreGraphQLOptions;
164
+ /** Logger instance */
165
+ logger: CoreLogger;
166
+ /** Patterns to ignore during scanning */
167
+ 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
+ };
186
+ }
187
+ //#endregion
188
+ export { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,23 +1,7 @@
1
1
  import { GraphQLSchema } from "graphql";
2
- import { ApolloServerOptions } from "@apollo/server";
3
- import { H3Event } from "h3";
4
- import { YogaServerOptions } from "graphql-yoga";
5
- import { NPMConfig, Resolvers, ResolversTypes } from "#graphql/server";
6
- import { StandardSchemaV1 } from "nitro-graphql";
7
2
 
8
- //#region src/utils/define.d.ts
3
+ //#region src/core/types/define.d.ts
9
4
  type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
10
- declare function defineSchema<T extends Partial<Record<keyof ResolversTypes, StandardSchemaV1>>>(config: T): Flatten<T>;
11
- declare function defineResolver(resolvers: Resolvers): Resolvers;
12
- type ResolverQuery = Resolvers extends {
13
- Query: infer Q;
14
- } ? Q : never;
15
- declare function defineQuery(resolvers?: Resolvers['Query']): Resolvers;
16
- declare function defineMutation(resolvers?: Resolvers['Mutation']): Resolvers;
17
- declare function defineSubscription(resolvers?: Resolvers['Subscription']): Resolvers;
18
- declare function defineType(resolvers: Resolvers): Resolvers;
19
- 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>>;
20
- declare function defineGraphQLConfig<T extends NPMConfig = NPMConfig>(config: Partial<DefineServerConfig<T>>): Partial<DefineServerConfig<T>>;
21
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';
22
6
  type GraphQLScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'ID' | 'JSON' | 'DateTime';
23
7
  type GraphQLBaseType = GraphQLScalarType | (string & {});
@@ -56,17 +40,5 @@ interface DefineDirectiveConfig {
56
40
  isRepeatable?: boolean;
57
41
  transformer?: (schema: GraphQLSchema) => GraphQLSchema;
58
42
  }
59
- /**
60
- * Helper function to create directive arguments with proper type inference
61
- * @example
62
- * args: {
63
- * myArg: arg('String!', { defaultValue: 'hello' })
64
- * }
65
- */
66
- declare function arg<T extends GraphQLArgumentType>(type: T, options?: {
67
- defaultValue?: any;
68
- description?: string;
69
- }): DirectiveArgument<T>;
70
- declare function defineDirective(config: DefineDirectiveConfig): DirectiveDefinition;
71
43
  //#endregion
72
- export { DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverQuery, arg, defineDirective, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, defineType };
44
+ export { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
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";
4
+ 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 };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ import { CoreLogger } from "./config.mjs";
2
+
3
+ //#region src/core/types/scanning.d.ts
4
+ /**
5
+ * Scan context for file scanning operations
6
+ * Provides all necessary information for scanning without framework dependencies
7
+ */
8
+ interface ScanContext {
9
+ /** Root directory of the project */
10
+ rootDir: string;
11
+ /** Server GraphQL directory */
12
+ serverDir: string;
13
+ /** Client GraphQL directory */
14
+ clientDir: string;
15
+ /** Patterns to ignore during scanning */
16
+ ignorePatterns: string[];
17
+ /** Whether running in development mode */
18
+ isDev: boolean;
19
+ /** Logger instance */
20
+ logger: CoreLogger;
21
+ }
22
+ /**
23
+ * Generic scan result wrapper
24
+ * Provides consistent result structure with warnings and errors
25
+ */
26
+ interface ScanResult<T> {
27
+ /** Scanned items */
28
+ items: T[];
29
+ /** Non-fatal warnings encountered during scanning */
30
+ warnings: string[];
31
+ /** Errors encountered during scanning */
32
+ errors: string[];
33
+ }
34
+ /**
35
+ * File information from scanning
36
+ */
37
+ interface ScannedFile {
38
+ /** Relative path from scan directory */
39
+ path: string;
40
+ /** Absolute file path */
41
+ fullPath: string;
42
+ }
43
+ /**
44
+ * Resolver import information
45
+ */
46
+ interface ResolverImport {
47
+ /** Export name */
48
+ name: string;
49
+ /** Resolver type (query, mutation, resolver, type, subscription, directive) */
50
+ type: 'query' | 'mutation' | 'resolver' | 'type' | 'subscription' | 'directive';
51
+ /** Aliased import name */
52
+ as: string;
53
+ }
54
+ /**
55
+ * Scanned resolver information
56
+ */
57
+ interface ScannedResolver {
58
+ /** File specifier (path) */
59
+ specifier: string;
60
+ /** Exports from this file */
61
+ imports: ResolverImport[];
62
+ }
63
+ //#endregion
64
+ export { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,8 @@
1
- //#region src/utils/directive-parser.d.ts
1
+ //#region src/core/utils/directive-parser.d.ts
2
+ /**
3
+ * Directive parser utilities
4
+ * AST-based parsing for GraphQL directive definitions
5
+ */
2
6
  interface ParsedDirective {
3
7
  name: string;
4
8
  locations: string[];
@@ -69,12 +73,22 @@ declare class DirectiveParser {
69
73
  */
70
74
  declare function generateDirectiveSchema(directive: ParsedDirective): string;
71
75
  /**
72
- * Generate directive schemas file from scanned directives
76
+ * Directive file reference
77
+ * Can be either { fullPath } or { specifier } (for GenImport compatibility)
73
78
  */
74
- declare function generateDirectiveSchemas(nitro: any, directives: any[]): Promise<void>;
79
+ type DirectiveFileRef = {
80
+ fullPath: string;
81
+ } | {
82
+ specifier: string;
83
+ };
75
84
  /**
76
85
  * Singleton instance for reuse
77
86
  */
78
87
  declare const directiveParser: DirectiveParser;
88
+ /**
89
+ * Generate GraphQL schema content from an array of parsed directives
90
+ * Returns the schema string and optionally writes to buildDir/directives.graphql
91
+ */
92
+ declare function generateDirectiveSchemas(directives: DirectiveFileRef[], buildDir?: string): Promise<string | null>;
79
93
  //#endregion
80
- export { DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas };
94
+ export { DirectiveFileRef, DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas };