nitro-graphql 2.0.0-beta.37 → 2.0.0-beta.38

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 (200) hide show
  1. package/dist/cli/commands/generate.d.mts +26 -0
  2. package/dist/cli/commands/generate.mjs +196 -0
  3. package/dist/cli/commands/index.d.mts +4 -0
  4. package/dist/cli/commands/index.mjs +5 -0
  5. package/dist/cli/commands/init.d.mts +12 -0
  6. package/dist/cli/commands/init.mjs +100 -0
  7. package/dist/cli/commands/validate.d.mts +10 -0
  8. package/dist/cli/commands/validate.mjs +69 -0
  9. package/dist/cli/config.d.mts +75 -0
  10. package/dist/cli/config.mjs +20 -0
  11. package/dist/cli/index.d.mts +24 -0
  12. package/dist/cli/index.mjs +219 -0
  13. package/dist/core/codegen/client.d.mts +23 -0
  14. package/dist/core/codegen/client.mjs +150 -0
  15. package/dist/core/codegen/document-loader.d.mts +10 -0
  16. package/dist/core/codegen/document-loader.mjs +18 -0
  17. package/dist/core/codegen/index.d.mts +8 -0
  18. package/dist/core/codegen/index.mjs +9 -0
  19. package/dist/{utils/codegen-plugin.d.mts → core/codegen/plugin.d.mts} +2 -2
  20. package/dist/{utils/codegen-plugin.mjs → core/codegen/plugin.mjs} +1 -1
  21. package/dist/core/codegen/runtime.d.mts +20 -0
  22. package/dist/core/codegen/runtime.mjs +60 -0
  23. package/dist/core/codegen/schema-loader.d.mts +28 -0
  24. package/dist/core/codegen/schema-loader.mjs +128 -0
  25. package/dist/core/codegen/server.d.mts +28 -0
  26. package/dist/core/codegen/server.mjs +143 -0
  27. package/dist/{codegen → core/codegen}/validation.d.mts +1 -1
  28. package/dist/{codegen → core/codegen}/validation.mjs +1 -1
  29. package/dist/core/config.d.mts +50 -0
  30. package/dist/core/config.mjs +82 -0
  31. package/dist/core/constants.d.mts +188 -0
  32. package/dist/core/constants.mjs +210 -0
  33. package/dist/core/index.d.mts +32 -0
  34. package/dist/core/index.mjs +26 -0
  35. package/dist/core/scanning/ast-scanner.d.mts +23 -0
  36. package/dist/core/scanning/ast-scanner.mjs +103 -0
  37. package/dist/core/scanning/common.d.mts +37 -0
  38. package/dist/core/scanning/common.mjs +60 -0
  39. package/dist/core/scanning/directives.d.mts +10 -0
  40. package/dist/core/scanning/directives.mjs +29 -0
  41. package/dist/core/scanning/documents.d.mts +21 -0
  42. package/dist/core/scanning/documents.mjs +43 -0
  43. package/dist/core/scanning/index.d.mts +7 -0
  44. package/dist/core/scanning/index.mjs +8 -0
  45. package/dist/core/scanning/resolvers.d.mts +10 -0
  46. package/dist/core/scanning/resolvers.mjs +58 -0
  47. package/dist/core/scanning/schemas.d.mts +14 -0
  48. package/dist/core/scanning/schemas.mjs +64 -0
  49. package/dist/{utils/schema-builder.d.mts → core/schema/builder.d.mts} +7 -2
  50. package/dist/{utils/schema-builder.mjs → core/schema/builder.mjs} +22 -3
  51. package/dist/{utils → core/schema}/federation.d.mts +10 -5
  52. package/dist/{utils → core/schema}/federation.mjs +1 -1
  53. package/dist/core/schema/index.d.mts +3 -0
  54. package/dist/core/schema/index.mjs +4 -0
  55. package/dist/core/types/adapter.d.mts +58 -0
  56. package/dist/core/types/codegen.d.mts +133 -0
  57. package/dist/core/types/config.d.mts +212 -0
  58. package/dist/{types → core/types}/define.d.mts +3 -7
  59. package/dist/core/types/index.d.mts +5 -0
  60. package/dist/core/types/scanning.d.mts +69 -0
  61. package/dist/core/types/scanning.mjs +1 -0
  62. package/dist/{utils → core/utils}/directive-parser.d.mts +21 -5
  63. package/dist/{utils → core/utils}/directive-parser.mjs +25 -36
  64. package/dist/{utils → core/utils}/errors.d.mts +8 -4
  65. package/dist/{utils → core/utils}/errors.mjs +8 -4
  66. package/dist/core/utils/file-io.d.mts +24 -0
  67. package/dist/core/utils/file-io.mjs +47 -0
  68. package/dist/{utils → core/utils}/imports.d.mts +1 -1
  69. package/dist/{utils → core/utils}/imports.mjs +1 -1
  70. package/dist/core/utils/index.d.mts +7 -0
  71. package/dist/core/utils/index.mjs +8 -0
  72. package/dist/core/utils/logger.d.mts +19 -0
  73. package/dist/core/utils/logger.mjs +38 -0
  74. package/dist/{utils → core/utils}/ofetch-templates.d.mts +1 -1
  75. package/dist/{utils → core/utils}/ofetch-templates.mjs +1 -1
  76. package/dist/core/validation/external-services.d.mts +11 -0
  77. package/dist/{utils/validation.mjs → core/validation/external-services.mjs} +3 -3
  78. package/dist/core/validation/index.d.mts +2 -0
  79. package/dist/core/validation/index.mjs +3 -0
  80. package/dist/define.d.mts +1 -3
  81. package/dist/index.d.mts +6 -44
  82. package/dist/index.mjs +5 -62
  83. package/dist/nitro/adapter.d.mts +30 -0
  84. package/dist/nitro/adapter.mjs +97 -0
  85. package/dist/{utils → nitro}/apollo.d.mts +1 -1
  86. package/dist/{utils → nitro}/apollo.mjs +1 -1
  87. package/dist/nitro/codegen.d.mts +19 -0
  88. package/dist/nitro/codegen.mjs +141 -0
  89. package/dist/nitro/config.d.mts +52 -0
  90. package/dist/nitro/config.mjs +58 -0
  91. package/dist/nitro/index.d.mts +46 -0
  92. package/dist/nitro/index.mjs +65 -0
  93. package/dist/{utils/path-resolver.d.mts → nitro/paths.d.mts} +3 -19
  94. package/dist/{utils/path-resolver.mjs → nitro/paths.mjs} +2 -36
  95. package/dist/{rollup.d.mts → nitro/rollup.d.mts} +1 -1
  96. package/dist/{rollup.mjs → nitro/rollup.mjs} +11 -23
  97. package/dist/{routes → nitro/routes}/apollo-server.d.mts +1 -1
  98. package/dist/{routes → nitro/routes}/apollo-server.mjs +5 -5
  99. package/dist/{routes → nitro/routes}/debug-template.d.mts +1 -1
  100. package/dist/{routes → nitro/routes}/debug-template.mjs +1 -1
  101. package/dist/{routes → nitro/routes}/debug.d.mts +10 -16
  102. package/dist/{routes → nitro/routes}/debug.mjs +2 -2
  103. package/dist/{routes → nitro/routes}/graphql-yoga.d.mts +1 -1
  104. package/dist/{routes → nitro/routes}/graphql-yoga.mjs +3 -3
  105. package/dist/{routes → nitro/routes}/health.d.mts +1 -1
  106. package/dist/{routes → nitro/routes}/health.mjs +1 -1
  107. package/dist/nitro/setup/file-watcher.d.mts +16 -0
  108. package/dist/{setup → nitro/setup}/file-watcher.mjs +14 -18
  109. package/dist/{setup.d.mts → nitro/setup/logging.d.mts} +5 -6
  110. package/dist/nitro/setup/logging.mjs +66 -0
  111. package/dist/nitro/setup/rollup-integration.d.mts +16 -0
  112. package/dist/{setup → nitro/setup}/rollup-integration.mjs +2 -2
  113. package/dist/nitro/setup/routes.d.mts +10 -0
  114. package/dist/nitro/setup/routes.mjs +35 -0
  115. package/dist/nitro/setup/ts-config.d.mts +11 -0
  116. package/dist/{setup → nitro/setup}/ts-config.mjs +3 -3
  117. package/dist/nitro/setup.d.mts +12 -0
  118. package/dist/{setup.mjs → nitro/setup.mjs} +33 -100
  119. package/dist/{types/index.d.mts → nitro/types.d.mts} +125 -43
  120. package/dist/nitro/types.mjs +1 -0
  121. package/dist/nitro/virtual/generators.d.mts +31 -0
  122. package/dist/nitro/virtual/generators.mjs +193 -0
  123. package/dist/nitro/virtual/stubs.d.mts +20 -0
  124. package/dist/nitro/virtual/stubs.mjs +31 -0
  125. package/dist/{ecosystem/nuxt.d.mts → nuxt.d.mts} +1 -1
  126. package/dist/{ecosystem/nuxt.mjs → nuxt.mjs} +2 -2
  127. package/dist/{graphql/server.d.mts → stubs/index.d.mts} +5 -1
  128. package/dist/stubs/index.mjs +1 -0
  129. package/package.json +43 -42
  130. package/dist/codegen/client-types.d.mts +0 -13
  131. package/dist/codegen/client-types.mjs +0 -131
  132. package/dist/codegen/external-types.d.mts +0 -12
  133. package/dist/codegen/external-types.mjs +0 -88
  134. package/dist/codegen/index.d.mts +0 -18
  135. package/dist/codegen/index.mjs +0 -24
  136. package/dist/codegen/server-types.d.mts +0 -13
  137. package/dist/codegen/server-types.mjs +0 -64
  138. package/dist/config/defaults.mjs +0 -36
  139. package/dist/constants/scalars.mjs +0 -27
  140. package/dist/constants.mjs +0 -106
  141. package/dist/graphql/index.d.mts +0 -5
  142. package/dist/setup/graphql-scanner.mjs +0 -25
  143. package/dist/setup/scaffold-generator.mjs +0 -109
  144. package/dist/types/standard-schema.d.mts +0 -59
  145. package/dist/utils/client-codegen.d.mts +0 -41
  146. package/dist/utils/client-codegen.mjs +0 -277
  147. package/dist/utils/file-generator.d.mts +0 -37
  148. package/dist/utils/file-generator.mjs +0 -72
  149. package/dist/utils/file-writer.d.mts +0 -35
  150. package/dist/utils/file-writer.mjs +0 -32
  151. package/dist/utils/index.d.mts +0 -13
  152. package/dist/utils/index.mjs +0 -13
  153. package/dist/utils/layers.d.mts +0 -22
  154. package/dist/utils/layers.mjs +0 -28
  155. package/dist/utils/scanning/common.d.mts +0 -23
  156. package/dist/utils/scanning/common.mjs +0 -39
  157. package/dist/utils/scanning/directives.d.mts +0 -11
  158. package/dist/utils/scanning/directives.mjs +0 -43
  159. package/dist/utils/scanning/documents.d.mts +0 -15
  160. package/dist/utils/scanning/documents.mjs +0 -46
  161. package/dist/utils/scanning/index.d.mts +0 -6
  162. package/dist/utils/scanning/index.mjs +0 -7
  163. package/dist/utils/scanning/resolvers.d.mts +0 -11
  164. package/dist/utils/scanning/resolvers.mjs +0 -100
  165. package/dist/utils/scanning/schemas.d.mts +0 -15
  166. package/dist/utils/scanning/schemas.mjs +0 -29
  167. package/dist/utils/server-codegen.d.mts +0 -7
  168. package/dist/utils/server-codegen.mjs +0 -113
  169. package/dist/utils/type-generation.d.mts +0 -6
  170. package/dist/utils/type-generation.mjs +0 -7
  171. package/dist/utils/validation.d.mts +0 -11
  172. package/dist/virtual/debug-info.d.mts +0 -9
  173. package/dist/virtual/debug-info.mjs +0 -26
  174. package/dist/virtual/generators/config.d.mts +0 -22
  175. package/dist/virtual/generators/config.mjs +0 -36
  176. package/dist/virtual/generators/debug.d.mts +0 -14
  177. package/dist/virtual/generators/debug.mjs +0 -53
  178. package/dist/virtual/generators/directives.d.mts +0 -14
  179. package/dist/virtual/generators/directives.mjs +0 -52
  180. package/dist/virtual/generators/index.d.mts +0 -6
  181. package/dist/virtual/generators/index.mjs +0 -7
  182. package/dist/virtual/generators/resolvers.d.mts +0 -14
  183. package/dist/virtual/generators/resolvers.mjs +0 -55
  184. package/dist/virtual/generators/schemas.d.mts +0 -14
  185. package/dist/virtual/generators/schemas.mjs +0 -43
  186. package/dist/virtual/graphql-config.d.mts +0 -9
  187. package/dist/virtual/graphql-config.mjs +0 -10
  188. package/dist/virtual/module-config.d.mts +0 -9
  189. package/dist/virtual/module-config.mjs +0 -10
  190. package/dist/virtual/server-directives.d.mts +0 -11
  191. package/dist/virtual/server-directives.mjs +0 -10
  192. package/dist/virtual/server-resolvers.d.mts +0 -11
  193. package/dist/virtual/server-resolvers.mjs +0 -10
  194. package/dist/virtual/server-schemas.d.mts +0 -11
  195. package/dist/virtual/server-schemas.mjs +0 -10
  196. /package/dist/{graphql/index.mjs → core/types/adapter.mjs} +0 -0
  197. /package/dist/{graphql/server.mjs → core/types/codegen.mjs} +0 -0
  198. /package/dist/{types/define.mjs → core/types/config.mjs} +0 -0
  199. /package/dist/{types/index.mjs → core/types/define.mjs} +0 -0
  200. /package/dist/{types/standard-schema.mjs → core/types/index.mjs} +0 -0
@@ -0,0 +1,58 @@
1
+ import { DEFINE_FUNCTIONS, RESOLVER_GLOB_PATTERN } from "../constants.mjs";
2
+ import { scanWithAST } from "./ast-scanner.mjs";
3
+ import { hash } from "ohash";
4
+
5
+ //#region src/core/scanning/resolvers.ts
6
+ /**
7
+ * Parse a define* function call and return the import info
8
+ */
9
+ function parseResolverCall(calleeName, exportName, filePath) {
10
+ const aliasHash = `_${hash(exportName + filePath).replace(/-/g, "").slice(0, 6)}`;
11
+ switch (calleeName) {
12
+ case "defineResolver": return {
13
+ name: exportName,
14
+ type: "resolver",
15
+ as: aliasHash
16
+ };
17
+ case "defineQuery": return {
18
+ name: exportName,
19
+ type: "query",
20
+ as: aliasHash
21
+ };
22
+ case "defineMutation": return {
23
+ name: exportName,
24
+ type: "mutation",
25
+ as: aliasHash
26
+ };
27
+ case "defineField": return {
28
+ name: exportName,
29
+ type: "type",
30
+ as: aliasHash
31
+ };
32
+ case "defineSubscription": return {
33
+ name: exportName,
34
+ type: "subscription",
35
+ as: aliasHash
36
+ };
37
+ case "defineDirective": return {
38
+ name: exportName,
39
+ type: "directive",
40
+ as: aliasHash
41
+ };
42
+ default: return null;
43
+ }
44
+ }
45
+ /**
46
+ * Scan for resolver files and parse their exports
47
+ */
48
+ function scanResolversCore(ctx) {
49
+ return scanWithAST(ctx, {
50
+ pattern: RESOLVER_GLOB_PATTERN,
51
+ parseCall: parseResolverCall,
52
+ emitWarnings: true,
53
+ validFunctions: DEFINE_FUNCTIONS
54
+ });
55
+ }
56
+
57
+ //#endregion
58
+ export { scanResolversCore };
@@ -0,0 +1,14 @@
1
+ import { ScanContext, ScanResult } from "../types/scanning.mjs";
2
+
3
+ //#region src/core/scanning/schemas.d.ts
4
+
5
+ /**
6
+ * Scan for GraphQL schema files (.graphql) in server directory
7
+ */
8
+ declare function scanSchemasCore(ctx: ScanContext): Promise<ScanResult<string>>;
9
+ /**
10
+ * Scan for GraphQL files (.graphql, .gql) in server directory
11
+ */
12
+ declare function scanGraphqlCore(ctx: ScanContext): Promise<ScanResult<string>>;
13
+ //#endregion
14
+ export { scanGraphqlCore, scanSchemasCore };
@@ -0,0 +1,64 @@
1
+ import { GRAPHQL_GLOB_PATTERN } from "../constants.mjs";
2
+ import { extractPaths, scanWithLayers } from "./common.mjs";
3
+ import { relative } from "pathe";
4
+
5
+ //#region src/core/scanning/schemas.ts
6
+ /**
7
+ * Scan for GraphQL schema files (.graphql) in server directory
8
+ */
9
+ async function scanSchemasCore(ctx) {
10
+ const warnings = [];
11
+ const errors = [];
12
+ try {
13
+ const serverDirRelative = relative(ctx.rootDir, ctx.serverDir);
14
+ return {
15
+ items: extractPaths(await scanWithLayers(ctx, {
16
+ mainDir: ctx.rootDir,
17
+ mainSubDir: serverDirRelative,
18
+ layerDirs: ctx.layerServerDirs,
19
+ layerSubDir: "graphql",
20
+ pattern: GRAPHQL_GLOB_PATTERN
21
+ })),
22
+ warnings,
23
+ errors
24
+ };
25
+ } catch (error) {
26
+ errors.push(`Schema scanning error: ${error}`);
27
+ return {
28
+ items: [],
29
+ warnings,
30
+ errors
31
+ };
32
+ }
33
+ }
34
+ /**
35
+ * Scan for GraphQL files (.graphql, .gql) in server directory
36
+ */
37
+ async function scanGraphqlCore(ctx) {
38
+ const warnings = [];
39
+ const errors = [];
40
+ try {
41
+ const serverDirRelative = relative(ctx.rootDir, ctx.serverDir);
42
+ return {
43
+ items: extractPaths(await scanWithLayers(ctx, {
44
+ mainDir: ctx.rootDir,
45
+ mainSubDir: serverDirRelative,
46
+ layerDirs: ctx.layerServerDirs,
47
+ layerSubDir: "graphql",
48
+ pattern: "**/*.{graphql,gql}"
49
+ })),
50
+ warnings,
51
+ errors
52
+ };
53
+ } catch (error) {
54
+ errors.push(`GraphQL scanning error: ${error}`);
55
+ return {
56
+ items: [],
57
+ warnings,
58
+ errors
59
+ };
60
+ }
61
+ }
62
+
63
+ //#endregion
64
+ export { scanGraphqlCore, scanSchemasCore };
@@ -1,7 +1,7 @@
1
1
  import { DirectiveDefinition } from "../types/define.mjs";
2
2
  import { GraphQLSchema } from "graphql";
3
3
 
4
- //#region src/utils/schema-builder.d.ts
4
+ //#region src/core/schema/builder.d.ts
5
5
 
6
6
  /**
7
7
  * Schema definition from virtual module
@@ -44,5 +44,10 @@ interface CreateMergedSchemaOptions {
44
44
  * Supports Apollo Federation when enabled
45
45
  */
46
46
  declare function createMergedSchema(options: CreateMergedSchemaOptions): Promise<GraphQLSchema>;
47
+ /**
48
+ * Build a GraphQL schema from file paths (CLI usage)
49
+ * Reads schema files, merges them, and builds an executable schema
50
+ */
51
+ declare function buildGraphQLSchema(schemaPaths: string[]): Promise<GraphQLSchema | null>;
47
52
  //#endregion
48
- export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, createMergedSchema };
53
+ export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema };
@@ -1,10 +1,11 @@
1
1
  import { loadFederationSupport, warnFederationUnavailable } from "./federation.mjs";
2
2
  import { consola as consola$1 } from "consola";
3
- import { parse } from "graphql";
3
+ import { buildSchema, parse, print } from "graphql";
4
+ import { readFileSync } from "node:fs";
4
5
  import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
5
6
  import { makeExecutableSchema } from "@graphql-tools/schema";
6
7
 
7
- //#region src/utils/schema-builder.ts
8
+ //#region src/core/schema/builder.ts
8
9
  /**
9
10
  * Create a merged GraphQL schema from schemas, resolvers, and directives
10
11
  * Supports Apollo Federation when enabled
@@ -46,6 +47,24 @@ async function createMergedSchema(options) {
46
47
  throw error;
47
48
  }
48
49
  }
50
+ /**
51
+ * Build a GraphQL schema from file paths (CLI usage)
52
+ * Reads schema files, merges them, and builds an executable schema
53
+ */
54
+ async function buildGraphQLSchema(schemaPaths) {
55
+ if (schemaPaths.length === 0) return null;
56
+ try {
57
+ const mergedTypeDefs = mergeTypeDefs(schemaPaths.map((path) => readFileSync(path, "utf-8")), {
58
+ throwOnConflict: true,
59
+ commentDescriptions: true,
60
+ sort: true
61
+ });
62
+ return buildSchema(typeof mergedTypeDefs === "string" ? mergedTypeDefs : print(mergedTypeDefs));
63
+ } catch (error) {
64
+ consola$1.error("Failed to build GraphQL schema:", error);
65
+ return null;
66
+ }
67
+ }
49
68
 
50
69
  //#endregion
51
- export { createMergedSchema };
70
+ export { buildGraphQLSchema, createMergedSchema };
@@ -1,14 +1,19 @@
1
1
  import { DocumentNode, GraphQLSchema } from "graphql";
2
2
 
3
- //#region src/utils/federation.d.ts
3
+ //#region src/core/schema/federation.d.ts
4
4
 
5
5
  /**
6
- * Type for buildSubgraphSchema function from @apollo/subgraph
6
+ * Module type for buildSubgraphSchema
7
7
  */
8
- type BuildSubgraphSchemaFn = (options: {
8
+ interface SubgraphModule {
9
9
  typeDefs: DocumentNode;
10
- resolvers: Record<string, unknown>;
11
- }) => GraphQLSchema;
10
+ resolvers?: Record<string, unknown>;
11
+ }
12
+ /**
13
+ * Type for buildSubgraphSchema function from @apollo/subgraph
14
+ * Accepts either an array of modules or a single options object
15
+ */
16
+ type BuildSubgraphSchemaFn = (modulesOrOptions: SubgraphModule[] | SubgraphModule) => GraphQLSchema;
12
17
  /**
13
18
  * Dynamically load @apollo/subgraph for federation support.
14
19
  * Returns the buildSubgraphSchema function if available, or false if the package is not installed.
@@ -1,7 +1,7 @@
1
1
  import { LOG_TAG } from "../constants.mjs";
2
2
  import { consola as consola$1 } from "consola";
3
3
 
4
- //#region src/utils/federation.ts
4
+ //#region src/core/schema/federation.ts
5
5
  const logger = consola$1.withTag(LOG_TAG);
6
6
  /**
7
7
  * Cached result: function if available, false if not available, null if not checked yet
@@ -0,0 +1,3 @@
1
+ import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
2
+ import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
3
+ export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -0,0 +1,4 @@
1
+ import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
2
+ import { buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
3
+
4
+ export { buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -0,0 +1,58 @@
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
+ /**
8
+ * Framework adapter interface
9
+ * Adapters convert framework-specific types to core types
10
+ */
11
+ interface FrameworkAdapter<TFramework = unknown> {
12
+ /** Adapter name for logging */
13
+ readonly name: string;
14
+ /** Create core config from framework instance */
15
+ createCoreConfig: (framework: TFramework) => CoreConfig;
16
+ /** Create core context from framework instance */
17
+ createCoreContext: (framework: TFramework) => CoreContext;
18
+ /** Create scan context from framework instance */
19
+ createScanContext: (framework: TFramework) => ScanContext;
20
+ /** Get framework logger adapted to CoreLogger interface */
21
+ getLogger: (framework: TFramework) => CoreLogger;
22
+ }
23
+ /**
24
+ * Scan adapter interface
25
+ * Provides high-level scanning operations using the framework adapter
26
+ */
27
+ interface ScanAdapter<TFramework = unknown> {
28
+ /** Scan for GraphQL schema files */
29
+ scanSchemas: (framework: TFramework) => Promise<ScanResult<string>>;
30
+ /** Scan for GraphQL files (schemas + operations) */
31
+ scanGraphql: (framework: TFramework) => Promise<ScanResult<string>>;
32
+ /** Scan for resolver files */
33
+ scanResolvers: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
34
+ /** Scan for directive files */
35
+ scanDirectives: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
36
+ /** Scan for client documents */
37
+ scanDocuments: (framework: TFramework) => Promise<ScanResult<string>>;
38
+ }
39
+ /**
40
+ * Codegen adapter interface
41
+ * Provides high-level codegen operations using the framework adapter
42
+ */
43
+ interface CodegenAdapter<TFramework = unknown> {
44
+ /** Generate server types */
45
+ generateServerTypes: (framework: TFramework, options?: {
46
+ silent?: boolean;
47
+ }) => Promise<void>;
48
+ /** Generate client types */
49
+ generateClientTypes: (framework: TFramework, options?: {
50
+ silent?: boolean;
51
+ }) => Promise<void>;
52
+ }
53
+ /**
54
+ * Combined full adapter interface
55
+ */
56
+ interface FullFrameworkAdapter<TFramework = unknown> extends FrameworkAdapter<TFramework>, ScanAdapter<TFramework>, CodegenAdapter<TFramework> {}
57
+ //#endregion
58
+ export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
@@ -0,0 +1,133 @@
1
+ import { Source } from "@graphql-tools/utils";
2
+ import { GraphQLSchema } from "graphql";
3
+
4
+ //#region src/core/types/codegen.d.ts
5
+
6
+ /**
7
+ * Scalar type mapping (can be string or input/output object)
8
+ */
9
+ type ScalarType = string | {
10
+ input: string;
11
+ output: string;
12
+ };
13
+ /**
14
+ * Server codegen configuration
15
+ */
16
+ interface ServerCodegenConfig {
17
+ scalars?: Record<string, ScalarType>;
18
+ defaultScalarType?: string;
19
+ defaultMapper?: string;
20
+ contextType?: string;
21
+ maybeValue?: string;
22
+ inputMaybeValue?: string;
23
+ declarationKind?: string;
24
+ enumsAsTypes?: boolean;
25
+ federation?: boolean;
26
+ [key: string]: unknown;
27
+ }
28
+ /**
29
+ * Client codegen configuration
30
+ */
31
+ interface ClientCodegenConfig {
32
+ emitLegacyCommonJSImports?: boolean;
33
+ useTypeImports?: boolean;
34
+ enumsAsTypes?: boolean;
35
+ strictScalars?: boolean;
36
+ maybeValue?: string;
37
+ inputMaybeValue?: string;
38
+ documentMode?: string;
39
+ pureMagicComment?: boolean;
40
+ dedupeOperationSuffix?: boolean;
41
+ rawRequest?: boolean;
42
+ scalars?: Record<string, ScalarType>;
43
+ typedDocumentNode?: boolean;
44
+ [key: string]: unknown;
45
+ }
46
+ /**
47
+ * SDK codegen configuration
48
+ */
49
+ interface SdkCodegenConfig extends ClientCodegenConfig {
50
+ [key: string]: unknown;
51
+ }
52
+ /**
53
+ * Input for server type generation
54
+ */
55
+ interface ServerCodegenInput {
56
+ /** GraphQL framework name */
57
+ framework: string;
58
+ /** Parsed GraphQL schema */
59
+ schema: GraphQLSchema;
60
+ /** Server codegen configuration */
61
+ config?: ServerCodegenConfig;
62
+ /** Whether federation is enabled */
63
+ federationEnabled?: boolean;
64
+ /** Output filename (optional) */
65
+ outputPath?: string;
66
+ }
67
+ /**
68
+ * Result of server type generation
69
+ */
70
+ interface ServerCodegenResult {
71
+ /** Generated TypeScript types content */
72
+ types: string;
73
+ /** Printed GraphQL schema */
74
+ schemaString: string;
75
+ }
76
+ /**
77
+ * Input for client type generation
78
+ */
79
+ interface ClientCodegenInput {
80
+ /** Parsed GraphQL schema */
81
+ schema: GraphQLSchema;
82
+ /** Loaded GraphQL documents */
83
+ documents: Source[];
84
+ /** Client codegen configuration */
85
+ config?: ClientCodegenConfig;
86
+ /** SDK codegen configuration */
87
+ sdkConfig?: SdkCodegenConfig;
88
+ /** Output filename (optional) */
89
+ outputPath?: string;
90
+ /** Service name for external services */
91
+ serviceName?: string;
92
+ /** Virtual types import path */
93
+ virtualTypesPath?: string;
94
+ /** Generation options */
95
+ options?: {
96
+ silent?: boolean;
97
+ isInitial?: boolean;
98
+ };
99
+ }
100
+ /**
101
+ * Result of client type generation
102
+ */
103
+ interface ClientCodegenResult {
104
+ /** Generated TypeScript types content */
105
+ types: string;
106
+ /** Generated SDK content */
107
+ sdk: string;
108
+ }
109
+ /**
110
+ * External service configuration for codegen
111
+ */
112
+ interface ExternalServiceCodegenConfig {
113
+ name: string;
114
+ schema: string | string[];
115
+ endpoint: string;
116
+ headers?: Record<string, string> | (() => Record<string, string>);
117
+ documents?: string[];
118
+ downloadSchema?: boolean | 'once' | 'always' | 'manual';
119
+ downloadPath?: string;
120
+ codegen?: {
121
+ client?: ClientCodegenConfig;
122
+ clientSDK?: SdkCodegenConfig;
123
+ };
124
+ }
125
+ /**
126
+ * Schema loading options
127
+ */
128
+ interface SchemaLoadOptions {
129
+ headers?: Record<string, string>;
130
+ loaders?: unknown[];
131
+ }
132
+ //#endregion
133
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
@@ -0,0 +1,212 @@
1
+ import { GraphQLFramework } from "../constants.mjs";
2
+
3
+ //#region src/core/types/config.d.ts
4
+
5
+ /**
6
+ * Core logger interface
7
+ * Abstracts logging functionality for framework independence
8
+ */
9
+ interface CoreLogger {
10
+ info: (message: string, ...args: unknown[]) => void;
11
+ warn: (message: string, ...args: unknown[]) => void;
12
+ error: (message: string, ...args: unknown[]) => void;
13
+ success: (message: string, ...args: unknown[]) => void;
14
+ debug: (message: string, ...args: unknown[]) => void;
15
+ }
16
+ /**
17
+ * GraphQL codegen configuration
18
+ */
19
+ interface CoreCodegenConfig {
20
+ /** Server-side codegen options */
21
+ server?: Record<string, unknown>;
22
+ /** Client-side codegen options */
23
+ client?: Record<string, unknown>;
24
+ /** Client SDK codegen options */
25
+ clientSDK?: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Security configuration options
29
+ */
30
+ interface CoreSecurityConfig {
31
+ /** Enable/disable GraphQL introspection */
32
+ introspection?: boolean;
33
+ /** Enable/disable GraphQL playground */
34
+ playground?: boolean;
35
+ /** Enable/disable error masking in responses */
36
+ maskErrors?: boolean;
37
+ /** Disable field suggestions in error messages */
38
+ disableSuggestions?: boolean;
39
+ }
40
+ /**
41
+ * External GraphQL service configuration
42
+ */
43
+ interface CoreExternalService {
44
+ /** Unique service name */
45
+ name: string;
46
+ /** GraphQL schema URL or file path */
47
+ schema: string;
48
+ /** GraphQL endpoint URL */
49
+ endpoint: string;
50
+ /** Headers for schema introspection */
51
+ headers?: Record<string, string> | (() => Record<string, string>);
52
+ /** Document patterns for this service */
53
+ documents?: string[];
54
+ /** Service-specific path overrides */
55
+ paths?: {
56
+ sdk?: string;
57
+ types?: string;
58
+ ofetch?: string;
59
+ };
60
+ }
61
+ /**
62
+ * Apollo Federation configuration
63
+ */
64
+ interface CoreFederationConfig {
65
+ /** Enable federation support */
66
+ enabled?: boolean;
67
+ /** Service name for federation */
68
+ serviceName?: string;
69
+ }
70
+ /**
71
+ * Path configuration with placeholders
72
+ */
73
+ interface CorePathsConfig {
74
+ /** Server GraphQL directory (default: 'server/graphql') */
75
+ serverGraphql?: string;
76
+ /** Client GraphQL directory (default: 'app/graphql' or 'graphql') */
77
+ clientGraphql?: string;
78
+ /** Build directory (default: '.nitro' or '.nuxt') */
79
+ buildDir?: string;
80
+ /** Types output directory (default: '{buildDir}/types') */
81
+ typesDir?: string;
82
+ }
83
+ /**
84
+ * Scaffold file generation configuration
85
+ */
86
+ interface CoreScaffoldConfig {
87
+ /** Master switch for all scaffold files */
88
+ enabled?: boolean;
89
+ /** Generate graphql.config.ts */
90
+ graphqlConfig?: boolean | string;
91
+ /** Generate server schema.ts */
92
+ serverSchema?: boolean | string;
93
+ /** Generate server config.ts */
94
+ serverConfig?: boolean | string;
95
+ /** Generate server context.d.ts */
96
+ serverContext?: boolean | string;
97
+ }
98
+ /**
99
+ * Type generation configuration
100
+ */
101
+ interface CoreTypesConfig {
102
+ /** Master switch for type generation */
103
+ enabled?: boolean;
104
+ /** Server types output path */
105
+ server?: boolean | string;
106
+ /** Client types output path */
107
+ client?: boolean | string;
108
+ /** External service types output path */
109
+ external?: boolean | string;
110
+ }
111
+ /**
112
+ * SDK generation configuration
113
+ */
114
+ interface CoreSdkConfig {
115
+ /** Master switch for SDK generation */
116
+ enabled?: boolean;
117
+ /** Main SDK output path */
118
+ main?: boolean | string;
119
+ /** External service SDK output path */
120
+ external?: boolean | string;
121
+ }
122
+ /**
123
+ * Client utilities configuration
124
+ */
125
+ interface CoreClientUtilsConfig {
126
+ /** Master switch for client utilities */
127
+ enabled?: boolean;
128
+ /** Index file output path */
129
+ index?: boolean | string;
130
+ /** Ofetch client output path */
131
+ ofetch?: boolean | string;
132
+ }
133
+ /**
134
+ * Core GraphQL options
135
+ * Framework-agnostic GraphQL configuration
136
+ */
137
+ interface CoreGraphQLOptions {
138
+ /** GraphQL framework to use */
139
+ framework?: GraphQLFramework;
140
+ /** GraphQL endpoint path */
141
+ endpoint?: string;
142
+ /** Codegen configuration */
143
+ codegen?: CoreCodegenConfig;
144
+ /** Security configuration */
145
+ security?: CoreSecurityConfig;
146
+ /** External GraphQL services */
147
+ externalServices?: CoreExternalService[];
148
+ /** Apollo Federation configuration */
149
+ federation?: CoreFederationConfig;
150
+ /** Path configuration */
151
+ paths?: CorePathsConfig;
152
+ /** Scaffold file configuration */
153
+ scaffold?: false | CoreScaffoldConfig;
154
+ /** Type generation configuration */
155
+ types?: false | CoreTypesConfig;
156
+ /** SDK generation configuration */
157
+ sdk?: false | CoreSdkConfig;
158
+ /** Client utilities configuration */
159
+ clientUtils?: false | CoreClientUtilsConfig;
160
+ }
161
+ /**
162
+ * Core configuration
163
+ * Main configuration interface that replaces Nitro-specific options
164
+ */
165
+ interface CoreConfig {
166
+ /** Root directory of the project */
167
+ rootDir: string;
168
+ /** Build output directory */
169
+ buildDir: string;
170
+ /** Server GraphQL directory */
171
+ serverDir: string;
172
+ /** Client GraphQL directory */
173
+ clientDir: string;
174
+ /** Types output directory */
175
+ typesDir: string;
176
+ /** GraphQL framework to use */
177
+ framework: GraphQLFramework;
178
+ /** Whether running in Nuxt context */
179
+ isNuxt: boolean;
180
+ /** Whether running in development mode */
181
+ isDev: boolean;
182
+ /** GraphQL options */
183
+ graphqlOptions: CoreGraphQLOptions;
184
+ /** Logger instance */
185
+ logger: CoreLogger;
186
+ /** Patterns to ignore during scanning */
187
+ ignorePatterns: string[];
188
+ /** Layer server directories (Nuxt) */
189
+ layerServerDirs?: string[];
190
+ /** Layer app directories (Nuxt) */
191
+ layerAppDirs?: string[];
192
+ }
193
+ /**
194
+ * Core context for runtime operations
195
+ * Holds resolved configuration and state
196
+ */
197
+ interface CoreContext {
198
+ /** Resolved configuration */
199
+ config: CoreConfig;
200
+ /** GraphQL build directory */
201
+ graphqlBuildDir: string;
202
+ /** Watch directories for file watching */
203
+ watchDirs: string[];
204
+ /** Relative directory paths */
205
+ dir: {
206
+ build: string;
207
+ client: string;
208
+ server: string;
209
+ };
210
+ }
211
+ //#endregion
212
+ export { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig };
@@ -1,12 +1,8 @@
1
1
  import { GraphQLSchema } from "graphql";
2
- import { ApolloServerOptions } from "@apollo/server";
3
- import { H3Event } from "nitro/h3";
4
- import { YogaServerOptions } from "graphql-yoga";
5
- import { NPMConfig } from "#graphql/server";
6
2
 
7
- //#region src/types/define.d.ts
3
+ //#region src/core/types/define.d.ts
4
+
8
5
  type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
9
- 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>>;
10
6
  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';
11
7
  type GraphQLScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'ID' | 'JSON' | 'DateTime';
12
8
  type GraphQLBaseType = GraphQLScalarType | (string & {});
@@ -46,4 +42,4 @@ interface DefineDirectiveConfig {
46
42
  transformer?: (schema: GraphQLSchema) => GraphQLSchema;
47
43
  }
48
44
  //#endregion
49
- export { DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
45
+ export { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
@@ -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, CoreScaffoldConfig, 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, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig, DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, ExternalServiceCodegenConfig, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverImport, ScalarType, ScanContext, ScanResult, ScannedFile, ScannedResolver, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };