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

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 (239) hide show
  1. package/README.md +31 -1196
  2. package/dist/cli/adapter.d.mts +13 -0
  3. package/dist/cli/adapter.mjs +69 -0
  4. package/dist/cli/commands/build.d.mts +21 -0
  5. package/dist/cli/commands/build.mjs +52 -0
  6. package/dist/cli/commands/dev.d.mts +40 -0
  7. package/dist/cli/commands/dev.mjs +76 -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 +6 -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 +67 -0
  16. package/dist/cli/completions.d.mts +6 -0
  17. package/dist/cli/completions.mjs +34 -0
  18. package/dist/cli/config.d.mts +18 -0
  19. package/dist/cli/config.mjs +20 -0
  20. package/dist/cli/index.d.mts +26 -0
  21. package/dist/cli/index.mjs +317 -0
  22. package/dist/cli/server/debug-handler.d.mts +9 -0
  23. package/dist/cli/server/debug-handler.mjs +71 -0
  24. package/dist/cli/server/dev-server.d.mts +29 -0
  25. package/dist/cli/server/dev-server.mjs +64 -0
  26. package/dist/cli/server/graphql-handler.d.mts +21 -0
  27. package/dist/cli/server/graphql-handler.mjs +45 -0
  28. package/dist/cli/server/health-handler.d.mts +12 -0
  29. package/dist/cli/server/health-handler.mjs +30 -0
  30. package/dist/cli/server/loader.d.mts +33 -0
  31. package/dist/cli/server/loader.mjs +146 -0
  32. package/dist/cli/server/sandbox-handler.d.mts +12 -0
  33. package/dist/cli/server/sandbox-handler.mjs +19 -0
  34. package/dist/cli/server/watcher.d.mts +20 -0
  35. package/dist/cli/server/watcher.mjs +66 -0
  36. package/dist/cli/server/ws-handler.d.mts +28 -0
  37. package/dist/cli/server/ws-handler.mjs +50 -0
  38. package/dist/config.d.mts +2 -0
  39. package/dist/config.mjs +3 -0
  40. package/dist/core/codegen/client.d.mts +42 -0
  41. package/dist/core/codegen/client.mjs +553 -0
  42. package/dist/core/codegen/document-loader.d.mts +9 -0
  43. package/dist/core/codegen/document-loader.mjs +18 -0
  44. package/dist/core/codegen/index.d.mts +8 -0
  45. package/dist/core/codegen/index.mjs +9 -0
  46. package/dist/core/codegen/plugin.d.mts +19 -0
  47. package/dist/core/codegen/plugin.mjs +30 -0
  48. package/dist/core/codegen/runtime.d.mts +19 -0
  49. package/dist/core/codegen/runtime.mjs +60 -0
  50. package/dist/core/codegen/schema-loader.d.mts +27 -0
  51. package/dist/core/codegen/schema-loader.mjs +128 -0
  52. package/dist/core/codegen/server.d.mts +27 -0
  53. package/dist/core/codegen/server.mjs +144 -0
  54. package/dist/core/codegen/validation.d.mts +17 -0
  55. package/dist/core/codegen/validation.mjs +35 -0
  56. package/dist/core/config.d.mts +45 -0
  57. package/dist/core/config.mjs +78 -0
  58. package/dist/core/constants.d.mts +188 -0
  59. package/dist/core/constants.mjs +210 -0
  60. package/dist/core/debug/index.d.mts +2 -0
  61. package/dist/core/debug/index.mjs +3 -0
  62. package/dist/core/debug/template.d.mts +52 -0
  63. package/dist/core/debug/template.mjs +383 -0
  64. package/dist/core/extend/index.d.mts +2 -0
  65. package/dist/core/extend/index.mjs +3 -0
  66. package/dist/core/extend/loader.d.mts +40 -0
  67. package/dist/core/extend/loader.mjs +198 -0
  68. package/dist/core/index.d.mts +37 -0
  69. package/dist/core/index.mjs +29 -0
  70. package/dist/core/manifest.d.mts +56 -0
  71. package/dist/core/manifest.mjs +102 -0
  72. package/dist/core/pubsub/index.d.mts +109 -0
  73. package/dist/core/pubsub/index.mjs +148 -0
  74. package/dist/core/scanning/ast-scanner.d.mts +27 -0
  75. package/dist/core/scanning/ast-scanner.mjs +116 -0
  76. package/dist/core/scanning/common.d.mts +25 -0
  77. package/dist/core/scanning/common.mjs +59 -0
  78. package/dist/core/scanning/directives.d.mts +13 -0
  79. package/dist/core/scanning/directives.mjs +29 -0
  80. package/dist/core/scanning/documents.d.mts +20 -0
  81. package/dist/core/scanning/documents.mjs +37 -0
  82. package/dist/core/scanning/index.d.mts +7 -0
  83. package/dist/core/scanning/index.mjs +8 -0
  84. package/dist/core/scanning/resolvers.d.mts +14 -0
  85. package/dist/core/scanning/resolvers.mjs +59 -0
  86. package/dist/core/scanning/schemas.d.mts +13 -0
  87. package/dist/core/scanning/schemas.mjs +52 -0
  88. package/dist/core/schema/builder.d.mts +59 -0
  89. package/dist/core/schema/builder.mjs +78 -0
  90. package/dist/core/schema/federation.d.mts +33 -0
  91. package/dist/core/schema/federation.mjs +40 -0
  92. package/dist/core/schema/index.d.mts +3 -0
  93. package/dist/core/schema/index.mjs +4 -0
  94. package/dist/core/server/index.d.mts +4 -0
  95. package/dist/core/server/index.mjs +4 -0
  96. package/dist/core/server/sandbox.d.mts +18 -0
  97. package/dist/core/server/sandbox.mjs +39 -0
  98. package/dist/core/server/types.d.mts +54 -0
  99. package/dist/core/server/yoga.d.mts +42 -0
  100. package/dist/core/server/yoga.mjs +89 -0
  101. package/dist/core/types/adapter.d.mts +57 -0
  102. package/dist/core/types/codegen.d.mts +136 -0
  103. package/dist/core/types/codegen.mjs +1 -0
  104. package/dist/core/types/config.d.mts +188 -0
  105. package/dist/core/types/config.mjs +1 -0
  106. package/dist/{utils/define.d.ts → core/types/define.d.mts} +2 -30
  107. package/dist/core/types/define.mjs +1 -0
  108. package/dist/core/types/index.d.mts +5 -0
  109. package/dist/core/types/index.mjs +1 -0
  110. package/dist/core/types/scanning.d.mts +64 -0
  111. package/dist/core/types/scanning.mjs +1 -0
  112. package/dist/{utils/directive-parser.d.ts → core/utils/directive-parser.d.mts} +18 -4
  113. package/dist/{utils/directive-parser.js → core/utils/directive-parser.mjs} +28 -34
  114. package/dist/core/utils/errors.d.mts +77 -0
  115. package/dist/core/utils/errors.mjs +93 -0
  116. package/dist/core/utils/file-io.d.mts +24 -0
  117. package/dist/core/utils/file-io.mjs +47 -0
  118. package/dist/core/utils/imports.d.mts +15 -0
  119. package/dist/core/utils/imports.mjs +25 -0
  120. package/dist/core/utils/index.d.mts +7 -0
  121. package/dist/core/utils/index.mjs +8 -0
  122. package/dist/core/utils/logger.d.mts +18 -0
  123. package/dist/core/utils/logger.mjs +38 -0
  124. package/dist/core/utils/ofetch-templates.d.mts +30 -0
  125. package/dist/core/utils/ofetch-templates.mjs +135 -0
  126. package/dist/core/utils/runtime.d.mts +74 -0
  127. package/dist/core/utils/runtime.mjs +111 -0
  128. package/dist/core/utils/subscribe-templates.d.mts +8 -0
  129. package/dist/core/utils/subscribe-templates.mjs +59 -0
  130. package/dist/core/validation/external-services.d.mts +11 -0
  131. package/dist/core/validation/external-services.mjs +33 -0
  132. package/dist/core/validation/index.d.mts +2 -0
  133. package/dist/core/validation/index.mjs +3 -0
  134. package/dist/core/watcher/index.d.mts +107 -0
  135. package/dist/core/watcher/index.mjs +141 -0
  136. package/dist/define.d.mts +294 -0
  137. package/dist/define.mjs +325 -0
  138. package/dist/index.d.mts +6 -0
  139. package/dist/index.mjs +6 -0
  140. package/dist/nitro/adapter.d.mts +29 -0
  141. package/dist/nitro/adapter.mjs +93 -0
  142. package/dist/{utils/apollo.d.ts → nitro/apollo.d.mts} +3 -3
  143. package/dist/nitro/apollo.mjs +59 -0
  144. package/dist/nitro/codegen.d.mts +18 -0
  145. package/dist/nitro/codegen.mjs +173 -0
  146. package/dist/nitro/config.d.mts +50 -0
  147. package/dist/nitro/config.mjs +57 -0
  148. package/dist/nitro/index.d.mts +45 -0
  149. package/dist/nitro/index.mjs +65 -0
  150. package/dist/{utils/path-resolver.d.ts → nitro/paths.d.mts} +8 -25
  151. package/dist/{utils/path-resolver.js → nitro/paths.mjs} +14 -49
  152. package/dist/nitro/rollup.d.mts +6 -0
  153. package/dist/nitro/rollup.mjs +53 -0
  154. package/dist/nitro/routes/apollo-sandbox-script.d.mts +6 -0
  155. package/dist/nitro/routes/apollo-sandbox-script.mjs +14 -0
  156. package/dist/nitro/routes/apollo-server-ws.d.mts +15 -0
  157. package/dist/nitro/routes/apollo-server-ws.mjs +53 -0
  158. package/dist/nitro/routes/apollo-server.d.mts +6 -0
  159. package/dist/nitro/routes/apollo-server.mjs +71 -0
  160. package/dist/{routes/debug.d.ts → nitro/routes/debug.d.mts} +12 -19
  161. package/dist/nitro/routes/debug.mjs +102 -0
  162. package/dist/nitro/routes/graphql-yoga-ws.d.mts +12 -0
  163. package/dist/nitro/routes/graphql-yoga-ws.mjs +53 -0
  164. package/dist/nitro/routes/graphql-yoga.d.mts +12 -0
  165. package/dist/nitro/routes/graphql-yoga.mjs +41 -0
  166. package/dist/nitro/routes/health.d.mts +10 -0
  167. package/dist/{routes/health.js → nitro/routes/health.mjs} +4 -3
  168. package/dist/nitro/setup/extend-loader.d.mts +16 -0
  169. package/dist/nitro/setup/extend-loader.mjs +82 -0
  170. package/dist/nitro/setup/file-watcher.d.mts +18 -0
  171. package/dist/nitro/setup/file-watcher.mjs +63 -0
  172. package/dist/nitro/setup/logging.d.mts +16 -0
  173. package/dist/nitro/setup/logging.mjs +66 -0
  174. package/dist/nitro/setup/rollup-integration.d.mts +24 -0
  175. package/dist/nitro/setup/rollup-integration.mjs +63 -0
  176. package/dist/nitro/setup/routes.d.mts +13 -0
  177. package/dist/nitro/setup/routes.mjs +71 -0
  178. package/dist/nitro/setup/scanner.d.mts +59 -0
  179. package/dist/nitro/setup/scanner.mjs +120 -0
  180. package/dist/nitro/setup/ts-config.d.mts +10 -0
  181. package/dist/nitro/setup/ts-config.mjs +69 -0
  182. package/dist/nitro/setup.d.mts +11 -0
  183. package/dist/nitro/setup.mjs +191 -0
  184. package/dist/nitro/types.d.mts +549 -0
  185. package/dist/nitro/types.mjs +1 -0
  186. package/dist/nitro/virtual/generators.d.mts +38 -0
  187. package/dist/nitro/virtual/generators.mjs +192 -0
  188. package/dist/nitro/virtual/stubs.d.mts +21 -0
  189. package/dist/nitro/virtual/stubs.mjs +32 -0
  190. package/dist/{ecosystem/nuxt.d.ts → nuxt.d.mts} +1 -1
  191. package/dist/nuxt.mjs +112 -0
  192. package/dist/{graphql/server.d.ts → stubs/index.d.mts} +5 -1
  193. package/dist/stubs/index.mjs +1 -0
  194. package/dist/subscribe/index.d.mts +78 -0
  195. package/dist/subscribe/index.mjs +206 -0
  196. package/native/index.d.ts +20 -0
  197. package/native/index.js +585 -0
  198. package/package.json +201 -111
  199. package/dist/ecosystem/nuxt.js +0 -67
  200. package/dist/graphql/index.d.ts +0 -5
  201. package/dist/index.d.ts +0 -8
  202. package/dist/index.js +0 -318
  203. package/dist/rollup.js +0 -277
  204. package/dist/routes/apollo-server.d.ts +0 -6
  205. package/dist/routes/apollo-server.js +0 -89
  206. package/dist/routes/debug.js +0 -449
  207. package/dist/routes/graphql-yoga.d.ts +0 -6
  208. package/dist/routes/graphql-yoga.js +0 -91
  209. package/dist/routes/health.d.ts +0 -10
  210. package/dist/types/index.d.ts +0 -246
  211. package/dist/types/standard-schema.d.ts +0 -59
  212. package/dist/utils/apollo.js +0 -61
  213. package/dist/utils/client-codegen.d.ts +0 -38
  214. package/dist/utils/client-codegen.js +0 -290
  215. package/dist/utils/define.js +0 -57
  216. package/dist/utils/file-generator.d.ts +0 -37
  217. package/dist/utils/file-generator.js +0 -72
  218. package/dist/utils/index.d.ts +0 -39
  219. package/dist/utils/index.js +0 -278
  220. package/dist/utils/server-codegen.d.ts +0 -7
  221. package/dist/utils/server-codegen.js +0 -136
  222. package/dist/utils/type-generation.d.ts +0 -7
  223. package/dist/utils/type-generation.js +0 -360
  224. package/dist/virtual/debug-info.d.ts +0 -9
  225. package/dist/virtual/debug-info.js +0 -26
  226. package/dist/virtual/graphql-config.d.ts +0 -9
  227. package/dist/virtual/graphql-config.js +0 -10
  228. package/dist/virtual/module-config.d.ts +0 -9
  229. package/dist/virtual/module-config.js +0 -10
  230. package/dist/virtual/server-directives.d.ts +0 -11
  231. package/dist/virtual/server-directives.js +0 -10
  232. package/dist/virtual/server-resolvers.d.ts +0 -11
  233. package/dist/virtual/server-resolvers.js +0 -10
  234. package/dist/virtual/server-schemas.d.ts +0 -11
  235. package/dist/virtual/server-schemas.js +0 -10
  236. package/dist/vite.d.ts +0 -25
  237. package/dist/vite.js +0 -40
  238. /package/dist/{graphql/index.js → core/server/types.mjs} +0 -0
  239. /package/dist/{graphql/server.js → core/types/adapter.mjs} +0 -0
@@ -0,0 +1,42 @@
1
+ import { SchemaDefinition } from "../schema/builder.mjs";
2
+ import { CoreServerInstance, CoreServerOptions } from "./types.mjs";
3
+
4
+ //#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
+ /**
11
+ * Apollo Sandbox HTML template
12
+ * Shared between CLI and Nitro for consistent playground experience
13
+ */
14
+ declare const apolloSandboxHtml = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <link rel=\"preload\" href=\"/api/graphql/sandbox.js\" as=\"script\">\n</head>\n<body style=\"margin: 0; overflow-x: hidden; overflow-y: hidden\">\n<div id=\"sandbox\" style=\"height:100vh; width:100vw;\"></div>\n<script src=\"/api/graphql/sandbox.js\"></script>\n<script>\nnew window.EmbeddedSandbox({\n target: \"#sandbox\",\n initialEndpoint: window.location.href.replace('/sandbox.js', ''),\n hideCookieToggle: false,\n initialState: {\n includeCookies: true\n }\n});\n</script>\n</body>\n</html>";
15
+ /**
16
+ * Create a GraphQL Yoga server instance
17
+ *
18
+ * This is the core server factory used by both:
19
+ * - Nitro routes (via virtual module imports)
20
+ * - CLI dev server (via file-based loading)
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // In Nitro route
25
+ * const server = await createYogaServer({
26
+ * schemas, resolvers, directives, moduleConfig,
27
+ * security: moduleConfig.security,
28
+ * importedConfig,
29
+ * })
30
+ *
31
+ * // In CLI
32
+ * const server = await createYogaServer({
33
+ * schemas: await loadSchemas(ctx),
34
+ * resolvers: await loadResolvers(ctx),
35
+ * moduleConfig: { federation: ctx.config.federation },
36
+ * endpoint: '/graphql',
37
+ * })
38
+ * ```
39
+ */
40
+ declare function createYogaServer(options: CoreServerOptions): Promise<CoreServerInstance>;
41
+ //#endregion
42
+ export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
@@ -0,0 +1,89 @@
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
+
5
+ //#region src/core/server/yoga.ts
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
+ * Apollo Sandbox HTML template
13
+ * Shared between CLI and Nitro for consistent playground experience
14
+ */
15
+ const apolloSandboxHtml = `<!DOCTYPE html>
16
+ <html lang="en">
17
+ <head>
18
+ <link rel="preload" href="/api/graphql/sandbox.js" as="script">
19
+ </head>
20
+ <body style="margin: 0; overflow-x: hidden; overflow-y: hidden">
21
+ <div id="sandbox" style="height:100vh; width:100vw;"></div>
22
+ <script src="/api/graphql/sandbox.js"><\/script>
23
+ <script>
24
+ new window.EmbeddedSandbox({
25
+ target: "#sandbox",
26
+ initialEndpoint: window.location.href.replace('/sandbox.js', ''),
27
+ hideCookieToggle: false,
28
+ initialState: {
29
+ includeCookies: true
30
+ }
31
+ });
32
+ <\/script>
33
+ </body>
34
+ </html>`;
35
+ /**
36
+ * Create a GraphQL Yoga server instance
37
+ *
38
+ * This is the core server factory used by both:
39
+ * - Nitro routes (via virtual module imports)
40
+ * - CLI dev server (via file-based loading)
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * // In Nitro route
45
+ * const server = await createYogaServer({
46
+ * schemas, resolvers, directives, moduleConfig,
47
+ * security: moduleConfig.security,
48
+ * importedConfig,
49
+ * })
50
+ *
51
+ * // In CLI
52
+ * const server = await createYogaServer({
53
+ * schemas: await loadSchemas(ctx),
54
+ * resolvers: await loadResolvers(ctx),
55
+ * moduleConfig: { federation: ctx.config.federation },
56
+ * endpoint: '/graphql',
57
+ * })
58
+ * ```
59
+ */
60
+ async function createYogaServer(options) {
61
+ const { schemas, resolvers, directives, moduleConfig, endpoint = "/api/graphql", security, importedConfig } = options;
62
+ const schema = await createMergedSchema({
63
+ schemas,
64
+ resolvers,
65
+ directives: directives || [],
66
+ moduleConfig
67
+ });
68
+ const securityConfig = security || {
69
+ introspection: true,
70
+ playground: true,
71
+ maskErrors: false,
72
+ disableSuggestions: false
73
+ };
74
+ const yoga = createYoga(defu({
75
+ schema,
76
+ graphqlEndpoint: endpoint,
77
+ landingPage: securityConfig.playground,
78
+ graphiql: securityConfig.playground ? { defaultQuery: "# Welcome to GraphQL\n#\n# Try running a query!\n" } : false,
79
+ renderGraphiQL: securityConfig.playground ? () => apolloSandboxHtml : void 0,
80
+ maskedErrors: securityConfig.maskErrors
81
+ }, importedConfig));
82
+ return {
83
+ fetch: (request, context) => Promise.resolve(yoga.fetch(request, context)),
84
+ schema
85
+ };
86
+ }
87
+
88
+ //#endregion
89
+ export { BASE_SCHEMA, apolloSandboxHtml, createYogaServer };
@@ -0,0 +1,57 @@
1
+ import { CoreConfig, CoreContext, CoreLogger } from "./config.mjs";
2
+ import { ScanContext, ScanResult, ScannedResolver } from "./scanning.mjs";
3
+ import "./index.mjs";
4
+
5
+ //#region src/core/types/adapter.d.ts
6
+ /**
7
+ * Framework adapter interface
8
+ * Adapters convert framework-specific types to core types
9
+ */
10
+ interface FrameworkAdapter<TFramework = unknown> {
11
+ /** Adapter name for logging */
12
+ readonly name: string;
13
+ /** Create core config from framework instance */
14
+ createCoreConfig: (framework: TFramework) => CoreConfig;
15
+ /** Create core context from framework instance */
16
+ createCoreContext: (framework: TFramework) => CoreContext;
17
+ /** Create scan context from framework instance */
18
+ createScanContext: (framework: TFramework) => ScanContext;
19
+ /** Get framework logger adapted to CoreLogger interface */
20
+ getLogger: (framework: TFramework) => CoreLogger;
21
+ }
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
+ //#endregion
57
+ export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
@@ -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 };