nitro-graphql 2.0.0-beta.37 → 2.0.0-beta.39
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.
- package/README.md +2 -2
- package/dist/cli/commands/generate.d.mts +26 -0
- package/dist/cli/commands/generate.mjs +196 -0
- package/dist/cli/commands/index.d.mts +4 -0
- package/dist/cli/commands/index.mjs +5 -0
- package/dist/cli/commands/init.d.mts +43 -0
- package/dist/cli/commands/init.mjs +191 -0
- package/dist/cli/commands/validate.d.mts +10 -0
- package/dist/cli/commands/validate.mjs +69 -0
- package/dist/cli/completions.d.mts +7 -0
- package/dist/cli/completions.mjs +34 -0
- package/dist/cli/config.d.mts +75 -0
- package/dist/cli/config.mjs +20 -0
- package/dist/cli/index.d.mts +24 -0
- package/dist/cli/index.mjs +253 -0
- package/dist/core/codegen/client.d.mts +23 -0
- package/dist/core/codegen/client.mjs +150 -0
- package/dist/core/codegen/document-loader.d.mts +10 -0
- package/dist/core/codegen/document-loader.mjs +18 -0
- package/dist/core/codegen/index.d.mts +8 -0
- package/dist/core/codegen/index.mjs +9 -0
- package/dist/{utils/codegen-plugin.d.mts → core/codegen/plugin.d.mts} +2 -2
- package/dist/{utils/codegen-plugin.mjs → core/codegen/plugin.mjs} +1 -1
- package/dist/core/codegen/runtime.d.mts +20 -0
- package/dist/core/codegen/runtime.mjs +60 -0
- package/dist/core/codegen/schema-loader.d.mts +28 -0
- package/dist/core/codegen/schema-loader.mjs +128 -0
- package/dist/core/codegen/server.d.mts +28 -0
- package/dist/core/codegen/server.mjs +143 -0
- package/dist/{codegen → core/codegen}/validation.d.mts +1 -1
- package/dist/{codegen → core/codegen}/validation.mjs +1 -1
- package/dist/core/config.d.mts +50 -0
- package/dist/core/config.mjs +82 -0
- package/dist/core/constants.d.mts +188 -0
- package/dist/core/constants.mjs +210 -0
- package/dist/core/index.d.mts +32 -0
- package/dist/core/index.mjs +26 -0
- package/dist/core/scanning/ast-scanner.d.mts +23 -0
- package/dist/core/scanning/ast-scanner.mjs +103 -0
- package/dist/core/scanning/common.d.mts +37 -0
- package/dist/core/scanning/common.mjs +60 -0
- package/dist/core/scanning/directives.d.mts +10 -0
- package/dist/core/scanning/directives.mjs +29 -0
- package/dist/core/scanning/documents.d.mts +21 -0
- package/dist/core/scanning/documents.mjs +43 -0
- package/dist/core/scanning/index.d.mts +7 -0
- package/dist/core/scanning/index.mjs +8 -0
- package/dist/core/scanning/resolvers.d.mts +10 -0
- package/dist/core/scanning/resolvers.mjs +58 -0
- package/dist/core/scanning/schemas.d.mts +14 -0
- package/dist/core/scanning/schemas.mjs +64 -0
- package/dist/{utils/schema-builder.d.mts → core/schema/builder.d.mts} +7 -2
- package/dist/{utils/schema-builder.mjs → core/schema/builder.mjs} +22 -3
- package/dist/{utils → core/schema}/federation.d.mts +10 -5
- package/dist/{utils → core/schema}/federation.mjs +1 -1
- package/dist/core/schema/index.d.mts +3 -0
- package/dist/core/schema/index.mjs +4 -0
- package/dist/core/types/adapter.d.mts +58 -0
- package/dist/core/types/codegen.d.mts +133 -0
- package/dist/core/types/config.d.mts +212 -0
- package/dist/{types → core/types}/define.d.mts +3 -7
- package/dist/core/types/index.d.mts +5 -0
- package/dist/core/types/scanning.d.mts +69 -0
- package/dist/core/types/scanning.mjs +1 -0
- package/dist/{utils → core/utils}/directive-parser.d.mts +21 -5
- package/dist/{utils → core/utils}/directive-parser.mjs +25 -36
- package/dist/{utils → core/utils}/errors.d.mts +8 -4
- package/dist/{utils → core/utils}/errors.mjs +8 -4
- package/dist/core/utils/file-io.d.mts +24 -0
- package/dist/core/utils/file-io.mjs +47 -0
- package/dist/{utils → core/utils}/imports.d.mts +1 -1
- package/dist/{utils → core/utils}/imports.mjs +1 -1
- package/dist/core/utils/index.d.mts +7 -0
- package/dist/core/utils/index.mjs +8 -0
- package/dist/core/utils/logger.d.mts +19 -0
- package/dist/core/utils/logger.mjs +38 -0
- package/dist/{utils → core/utils}/ofetch-templates.d.mts +1 -1
- package/dist/{utils → core/utils}/ofetch-templates.mjs +1 -1
- package/dist/core/validation/external-services.d.mts +11 -0
- package/dist/{utils/validation.mjs → core/validation/external-services.mjs} +3 -3
- package/dist/core/validation/index.d.mts +2 -0
- package/dist/core/validation/index.mjs +3 -0
- package/dist/define.d.mts +2 -4
- package/dist/define.mjs +1 -1
- package/dist/index.d.mts +6 -44
- package/dist/index.mjs +5 -62
- package/dist/nitro/adapter.d.mts +30 -0
- package/dist/nitro/adapter.mjs +97 -0
- package/dist/{utils → nitro}/apollo.d.mts +1 -1
- package/dist/{utils → nitro}/apollo.mjs +1 -1
- package/dist/nitro/codegen.d.mts +19 -0
- package/dist/nitro/codegen.mjs +141 -0
- package/dist/nitro/config.d.mts +52 -0
- package/dist/nitro/config.mjs +58 -0
- package/dist/nitro/index.d.mts +46 -0
- package/dist/nitro/index.mjs +65 -0
- package/dist/{utils/path-resolver.d.mts → nitro/paths.d.mts} +3 -19
- package/dist/{utils/path-resolver.mjs → nitro/paths.mjs} +2 -36
- package/dist/{rollup.d.mts → nitro/rollup.d.mts} +1 -1
- package/dist/{rollup.mjs → nitro/rollup.mjs} +11 -23
- package/dist/{routes → nitro/routes}/apollo-server.d.mts +1 -1
- package/dist/{routes → nitro/routes}/apollo-server.mjs +5 -5
- package/dist/{routes → nitro/routes}/debug-template.d.mts +1 -1
- package/dist/{routes → nitro/routes}/debug-template.mjs +1 -1
- package/dist/{routes → nitro/routes}/debug.d.mts +10 -16
- package/dist/{routes → nitro/routes}/debug.mjs +2 -2
- package/dist/{routes → nitro/routes}/graphql-yoga.d.mts +1 -1
- package/dist/{routes → nitro/routes}/graphql-yoga.mjs +3 -3
- package/dist/{routes → nitro/routes}/health.d.mts +1 -1
- package/dist/{routes → nitro/routes}/health.mjs +1 -1
- package/dist/nitro/setup/file-watcher.d.mts +16 -0
- package/dist/{setup → nitro/setup}/file-watcher.mjs +14 -18
- package/dist/{setup.d.mts → nitro/setup/logging.d.mts} +5 -6
- package/dist/nitro/setup/logging.mjs +66 -0
- package/dist/nitro/setup/rollup-integration.d.mts +16 -0
- package/dist/{setup → nitro/setup}/rollup-integration.mjs +2 -2
- package/dist/nitro/setup/routes.d.mts +10 -0
- package/dist/nitro/setup/routes.mjs +35 -0
- package/dist/nitro/setup/ts-config.d.mts +11 -0
- package/dist/{setup → nitro/setup}/ts-config.mjs +3 -3
- package/dist/nitro/setup.d.mts +12 -0
- package/dist/{setup.mjs → nitro/setup.mjs} +33 -100
- package/dist/{types/index.d.mts → nitro/types.d.mts} +125 -43
- package/dist/nitro/types.mjs +1 -0
- package/dist/nitro/virtual/generators.d.mts +31 -0
- package/dist/nitro/virtual/generators.mjs +193 -0
- package/dist/nitro/virtual/stubs.d.mts +20 -0
- package/dist/nitro/virtual/stubs.mjs +31 -0
- package/dist/{ecosystem/nuxt.d.mts → nuxt.d.mts} +1 -1
- package/dist/{ecosystem/nuxt.mjs → nuxt.mjs} +2 -2
- package/dist/{graphql/server.d.mts → stubs/index.d.mts} +5 -1
- package/dist/stubs/index.mjs +1 -0
- package/package.json +45 -42
- package/dist/codegen/client-types.d.mts +0 -13
- package/dist/codegen/client-types.mjs +0 -131
- package/dist/codegen/external-types.d.mts +0 -12
- package/dist/codegen/external-types.mjs +0 -88
- package/dist/codegen/index.d.mts +0 -18
- package/dist/codegen/index.mjs +0 -24
- package/dist/codegen/server-types.d.mts +0 -13
- package/dist/codegen/server-types.mjs +0 -64
- package/dist/config/defaults.mjs +0 -36
- package/dist/constants/scalars.mjs +0 -27
- package/dist/constants.mjs +0 -106
- package/dist/graphql/index.d.mts +0 -5
- package/dist/setup/graphql-scanner.mjs +0 -25
- package/dist/setup/scaffold-generator.mjs +0 -109
- package/dist/types/standard-schema.d.mts +0 -59
- package/dist/utils/client-codegen.d.mts +0 -41
- package/dist/utils/client-codegen.mjs +0 -277
- package/dist/utils/file-generator.d.mts +0 -37
- package/dist/utils/file-generator.mjs +0 -72
- package/dist/utils/file-writer.d.mts +0 -35
- package/dist/utils/file-writer.mjs +0 -32
- package/dist/utils/index.d.mts +0 -13
- package/dist/utils/index.mjs +0 -13
- package/dist/utils/layers.d.mts +0 -22
- package/dist/utils/layers.mjs +0 -28
- package/dist/utils/scanning/common.d.mts +0 -23
- package/dist/utils/scanning/common.mjs +0 -39
- package/dist/utils/scanning/directives.d.mts +0 -11
- package/dist/utils/scanning/directives.mjs +0 -43
- package/dist/utils/scanning/documents.d.mts +0 -15
- package/dist/utils/scanning/documents.mjs +0 -46
- package/dist/utils/scanning/index.d.mts +0 -6
- package/dist/utils/scanning/index.mjs +0 -7
- package/dist/utils/scanning/resolvers.d.mts +0 -11
- package/dist/utils/scanning/resolvers.mjs +0 -100
- package/dist/utils/scanning/schemas.d.mts +0 -15
- package/dist/utils/scanning/schemas.mjs +0 -29
- package/dist/utils/server-codegen.d.mts +0 -7
- package/dist/utils/server-codegen.mjs +0 -113
- package/dist/utils/type-generation.d.mts +0 -6
- package/dist/utils/type-generation.mjs +0 -7
- package/dist/utils/validation.d.mts +0 -11
- package/dist/virtual/debug-info.d.mts +0 -9
- package/dist/virtual/debug-info.mjs +0 -26
- package/dist/virtual/generators/config.d.mts +0 -22
- package/dist/virtual/generators/config.mjs +0 -36
- package/dist/virtual/generators/debug.d.mts +0 -14
- package/dist/virtual/generators/debug.mjs +0 -53
- package/dist/virtual/generators/directives.d.mts +0 -14
- package/dist/virtual/generators/directives.mjs +0 -52
- package/dist/virtual/generators/index.d.mts +0 -6
- package/dist/virtual/generators/index.mjs +0 -7
- package/dist/virtual/generators/resolvers.d.mts +0 -14
- package/dist/virtual/generators/resolvers.mjs +0 -55
- package/dist/virtual/generators/schemas.d.mts +0 -14
- package/dist/virtual/generators/schemas.mjs +0 -43
- package/dist/virtual/graphql-config.d.mts +0 -9
- package/dist/virtual/graphql-config.mjs +0 -10
- package/dist/virtual/module-config.d.mts +0 -9
- package/dist/virtual/module-config.mjs +0 -10
- package/dist/virtual/server-directives.d.mts +0 -11
- package/dist/virtual/server-directives.mjs +0 -10
- package/dist/virtual/server-resolvers.d.mts +0 -11
- package/dist/virtual/server-resolvers.mjs +0 -10
- package/dist/virtual/server-schemas.d.mts +0 -11
- package/dist/virtual/server-schemas.mjs +0 -10
- /package/dist/{graphql/index.mjs → core/types/adapter.mjs} +0 -0
- /package/dist/{graphql/server.mjs → core/types/codegen.mjs} +0 -0
- /package/dist/{types/define.mjs → core/types/config.mjs} +0 -0
- /package/dist/{types/index.mjs → core/types/define.mjs} +0 -0
- /package/dist/{types/standard-schema.mjs → core/types/index.mjs} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/core/validation/external-services.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* External services validation utilities
|
|
4
|
+
* Framework-agnostic validation helpers
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validate external GraphQL service configuration
|
|
8
|
+
*/
|
|
9
|
+
declare function validateExternalServices(services: unknown[]): string[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { validateExternalServices };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/core/validation/external-services.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* External services validation utilities
|
|
4
|
+
* Framework-agnostic validation helpers
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Validate external GraphQL service configuration
|
package/dist/define.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "./types
|
|
2
|
-
import "./types/index.mjs";
|
|
3
|
-
import { DefineDirectiveConfig, DefineServerConfig, DirectiveDefinition, Flatten } from "./types/define.mjs";
|
|
1
|
+
import { DefineDirectiveConfig, DefineServerConfig, DirectiveDefinition, Flatten, StandardSchemaV1 } from "./nitro/types.mjs";
|
|
4
2
|
import { NPMConfig, Resolvers, ResolversTypes } from "#graphql/server";
|
|
5
3
|
|
|
6
4
|
//#region src/define.d.ts
|
|
@@ -197,7 +195,7 @@ declare function defineField(resolvers: Resolvers): Resolvers;
|
|
|
197
195
|
*
|
|
198
196
|
* @example
|
|
199
197
|
* ```typescript
|
|
200
|
-
* import { createDefaultMaskError } from 'nitro-graphql/
|
|
198
|
+
* import { createDefaultMaskError } from 'nitro-graphql/core'
|
|
201
199
|
*
|
|
202
200
|
* // GraphQL Yoga configuration
|
|
203
201
|
* export default defineGraphQLConfig({
|
package/dist/define.mjs
CHANGED
|
@@ -203,7 +203,7 @@ function defineField(resolvers) {
|
|
|
203
203
|
*
|
|
204
204
|
* @example
|
|
205
205
|
* ```typescript
|
|
206
|
-
* import { createDefaultMaskError } from 'nitro-graphql/
|
|
206
|
+
* import { createDefaultMaskError } from 'nitro-graphql/core'
|
|
207
207
|
*
|
|
208
208
|
* // GraphQL Yoga configuration
|
|
209
209
|
* export default defineGraphQLConfig({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,44 +1,6 @@
|
|
|
1
|
-
import { NitroGraphQLOptions } from "./types
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Vite plugin to load GraphQL files as strings AND auto-register Nitro module
|
|
10
|
-
* This prevents Vite from trying to parse .graphql/.gql files as JavaScript
|
|
11
|
-
* and automatically sets up the nitro-graphql module via the nitro: hook
|
|
12
|
-
*
|
|
13
|
-
* @example - Vite usage
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { defineConfig } from 'vite'
|
|
16
|
-
* import { nitro } from 'nitro/vite'
|
|
17
|
-
* import graphql from 'nitro-graphql'
|
|
18
|
-
*
|
|
19
|
-
* export default defineConfig({
|
|
20
|
-
* plugins: [
|
|
21
|
-
* graphql({ framework: 'graphql-yoga' }), // Auto-registers Nitro module
|
|
22
|
-
* nitro()
|
|
23
|
-
* ]
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @example - Nitro direct usage
|
|
29
|
-
* ```ts
|
|
30
|
-
*
|
|
31
|
-
* import graphql from 'nitro-graphql'
|
|
32
|
-
*
|
|
33
|
-
* export default defineConfig({
|
|
34
|
-
* modules: [
|
|
35
|
-
* graphql({ framework: 'graphql-yoga' }) // Auto-registers Nitro module
|
|
36
|
-
* ]
|
|
37
|
-
* })
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function graphqlModule(options?: NitroGraphQLOptions): Plugin & {
|
|
41
|
-
nitro?: NitroModule;
|
|
42
|
-
};
|
|
43
|
-
//#endregion
|
|
44
|
-
export { graphqlModule as default, resolveSecurityConfig };
|
|
1
|
+
import { ExternalGraphQLService, NitroGraphQLOptions, SecurityConfig } from "./nitro/types.mjs";
|
|
2
|
+
import { NitroAdapter } from "./nitro/adapter.mjs";
|
|
3
|
+
import { resolveSecurityConfig } from "./nitro/setup/logging.mjs";
|
|
4
|
+
import { setupNitroGraphQL } from "./nitro/setup.mjs";
|
|
5
|
+
import graphqlModule from "./nitro/index.mjs";
|
|
6
|
+
export { type ExternalGraphQLService, NitroAdapter, type NitroGraphQLOptions, type SecurityConfig, graphqlModule as default, resolveSecurityConfig, setupNitroGraphQL };
|
package/dist/index.mjs
CHANGED
|
@@ -1,63 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { NitroAdapter } from "./nitro/adapter.mjs";
|
|
2
|
+
import { resolveSecurityConfig } from "./nitro/setup/logging.mjs";
|
|
3
|
+
import { setupNitroGraphQL } from "./nitro/setup.mjs";
|
|
4
|
+
import nitro_default from "./nitro/index.mjs";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Vite plugin to load GraphQL files as strings AND auto-register Nitro module
|
|
8
|
-
* This prevents Vite from trying to parse .graphql/.gql files as JavaScript
|
|
9
|
-
* and automatically sets up the nitro-graphql module via the nitro: hook
|
|
10
|
-
*
|
|
11
|
-
* @example - Vite usage
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { defineConfig } from 'vite'
|
|
14
|
-
* import { nitro } from 'nitro/vite'
|
|
15
|
-
* import graphql from 'nitro-graphql'
|
|
16
|
-
*
|
|
17
|
-
* export default defineConfig({
|
|
18
|
-
* plugins: [
|
|
19
|
-
* graphql({ framework: 'graphql-yoga' }), // Auto-registers Nitro module
|
|
20
|
-
* nitro()
|
|
21
|
-
* ]
|
|
22
|
-
* })
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @example - Nitro direct usage
|
|
27
|
-
* ```ts
|
|
28
|
-
*
|
|
29
|
-
* import graphql from 'nitro-graphql'
|
|
30
|
-
*
|
|
31
|
-
* export default defineConfig({
|
|
32
|
-
* modules: [
|
|
33
|
-
* graphql({ framework: 'graphql-yoga' }) // Auto-registers Nitro module
|
|
34
|
-
* ]
|
|
35
|
-
* })
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
function graphqlModule(options) {
|
|
39
|
-
return {
|
|
40
|
-
name: "nitro-graphql",
|
|
41
|
-
enforce: "pre",
|
|
42
|
-
async load(id) {
|
|
43
|
-
if (!/\.(?:graphql|gql)$/i.test(id)) return null;
|
|
44
|
-
try {
|
|
45
|
-
const content = await readFile(id, "utf-8");
|
|
46
|
-
return `export default ${JSON.stringify(content)}`;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
nitro: { async setup(nitro) {
|
|
53
|
-
if (options) nitro.options.graphql = defu(nitro.options.graphql || {}, options);
|
|
54
|
-
nitro.options.graphql = nitro.options.graphql || {};
|
|
55
|
-
nitro.options.graphql._vitePlugin = true;
|
|
56
|
-
await setupNitroGraphQL(nitro);
|
|
57
|
-
} }
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
var src_default = graphqlModule;
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { src_default as default, resolveSecurityConfig };
|
|
6
|
+
export { NitroAdapter, nitro_default as default, resolveSecurityConfig, setupNitroGraphQL };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CoreConfig, CoreContext, CoreLogger } from "../core/types/config.mjs";
|
|
2
|
+
import { ScanContext } from "../core/types/scanning.mjs";
|
|
3
|
+
import "../core/types/index.mjs";
|
|
4
|
+
import { FrameworkAdapter, ScanAdapter } from "../core/types/adapter.mjs";
|
|
5
|
+
import { Nitro } from "nitro/types";
|
|
6
|
+
|
|
7
|
+
//#region src/nitro/adapter.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a CoreLogger from Nitro's logger
|
|
11
|
+
*/
|
|
12
|
+
declare function createLoggerFromNitro(nitro: Nitro): CoreLogger;
|
|
13
|
+
/**
|
|
14
|
+
* Create a ScanContext from Nitro instance
|
|
15
|
+
*/
|
|
16
|
+
declare function createScanContextFromNitro(nitro: Nitro): ScanContext;
|
|
17
|
+
/**
|
|
18
|
+
* Create a CoreConfig from Nitro instance
|
|
19
|
+
*/
|
|
20
|
+
declare function createCoreConfigFromNitro(nitro: Nitro): CoreConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Create a CoreContext from Nitro instance
|
|
23
|
+
*/
|
|
24
|
+
declare function createCoreContextFromNitro(nitro: Nitro): CoreContext;
|
|
25
|
+
/**
|
|
26
|
+
* Nitro framework adapter implementation
|
|
27
|
+
*/
|
|
28
|
+
declare const NitroAdapter: FrameworkAdapter<Nitro> & ScanAdapter<Nitro>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { NitroAdapter, NitroAdapter as default, createCoreConfigFromNitro, createCoreContextFromNitro, createLoggerFromNitro, createScanContextFromNitro };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { scanDirectivesCore } from "../core/scanning/directives.mjs";
|
|
2
|
+
import { scanDocumentsCore } from "../core/scanning/documents.mjs";
|
|
3
|
+
import { scanResolversCore } from "../core/scanning/resolvers.mjs";
|
|
4
|
+
import { scanGraphqlCore, scanSchemasCore } from "../core/scanning/schemas.mjs";
|
|
5
|
+
import { join, relative } from "pathe";
|
|
6
|
+
|
|
7
|
+
//#region src/nitro/adapter.ts
|
|
8
|
+
/**
|
|
9
|
+
* Create a CoreLogger from Nitro's logger
|
|
10
|
+
*/
|
|
11
|
+
function createLoggerFromNitro(nitro) {
|
|
12
|
+
return {
|
|
13
|
+
info: (msg, ...args) => nitro.logger.info(msg, ...args),
|
|
14
|
+
warn: (msg, ...args) => nitro.logger.warn(msg, ...args),
|
|
15
|
+
error: (msg, ...args) => nitro.logger.error(msg, ...args),
|
|
16
|
+
success: (msg, ...args) => nitro.logger.success(msg, ...args),
|
|
17
|
+
debug: (msg, ...args) => nitro.logger.debug(msg, ...args)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a ScanContext from Nitro instance
|
|
22
|
+
*/
|
|
23
|
+
function createScanContextFromNitro(nitro) {
|
|
24
|
+
return {
|
|
25
|
+
rootDir: nitro.options.rootDir,
|
|
26
|
+
serverDir: nitro.graphql.serverDir,
|
|
27
|
+
clientDir: nitro.graphql.clientDir,
|
|
28
|
+
ignorePatterns: nitro.options.ignore,
|
|
29
|
+
isDev: nitro.options.dev,
|
|
30
|
+
logger: createLoggerFromNitro(nitro),
|
|
31
|
+
layerServerDirs: nitro.options.graphql?.layerServerDirs || [],
|
|
32
|
+
layerAppDirs: nitro.options.graphql?.layerAppDirs || []
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a CoreConfig from Nitro instance
|
|
37
|
+
*/
|
|
38
|
+
function createCoreConfigFromNitro(nitro) {
|
|
39
|
+
const graphqlOptions = nitro.options.graphql || {};
|
|
40
|
+
const isNuxt = nitro.options.framework?.name === "nuxt";
|
|
41
|
+
const typesDir = join(nitro.graphql.buildDir, "types");
|
|
42
|
+
return {
|
|
43
|
+
rootDir: nitro.options.rootDir,
|
|
44
|
+
buildDir: nitro.graphql.buildDir,
|
|
45
|
+
serverDir: nitro.graphql.serverDir,
|
|
46
|
+
clientDir: nitro.graphql.clientDir,
|
|
47
|
+
typesDir,
|
|
48
|
+
framework: graphqlOptions.framework || "graphql-yoga",
|
|
49
|
+
isNuxt,
|
|
50
|
+
isDev: nitro.options.dev,
|
|
51
|
+
graphqlOptions: {
|
|
52
|
+
framework: graphqlOptions.framework,
|
|
53
|
+
endpoint: typeof graphqlOptions.endpoint === "object" ? graphqlOptions.endpoint?.graphql : graphqlOptions.endpoint,
|
|
54
|
+
federation: graphqlOptions.federation,
|
|
55
|
+
security: graphqlOptions.security
|
|
56
|
+
},
|
|
57
|
+
logger: createLoggerFromNitro(nitro),
|
|
58
|
+
ignorePatterns: nitro.options.ignore,
|
|
59
|
+
layerServerDirs: nitro.options.graphql?.layerServerDirs || [],
|
|
60
|
+
layerAppDirs: nitro.options.graphql?.layerAppDirs || []
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a CoreContext from Nitro instance
|
|
65
|
+
*/
|
|
66
|
+
function createCoreContextFromNitro(nitro) {
|
|
67
|
+
return {
|
|
68
|
+
config: createCoreConfigFromNitro(nitro),
|
|
69
|
+
graphqlBuildDir: nitro.graphql.buildDir,
|
|
70
|
+
watchDirs: nitro.graphql.watchDirs,
|
|
71
|
+
dir: nitro.graphql.dir
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Nitro framework adapter implementation
|
|
76
|
+
*/
|
|
77
|
+
const NitroAdapter = {
|
|
78
|
+
name: "nitro",
|
|
79
|
+
createCoreConfig: createCoreConfigFromNitro,
|
|
80
|
+
createCoreContext: createCoreContextFromNitro,
|
|
81
|
+
createScanContext: createScanContextFromNitro,
|
|
82
|
+
getLogger: createLoggerFromNitro,
|
|
83
|
+
scanSchemas: (nitro) => scanSchemasCore(createScanContextFromNitro(nitro)),
|
|
84
|
+
scanGraphql: (nitro) => scanGraphqlCore(createScanContextFromNitro(nitro)),
|
|
85
|
+
scanResolvers: (nitro) => scanResolversCore(createScanContextFromNitro(nitro)),
|
|
86
|
+
scanDirectives: (nitro) => scanDirectivesCore(createScanContextFromNitro(nitro)),
|
|
87
|
+
scanDocuments(nitro) {
|
|
88
|
+
return scanDocumentsCore(createScanContextFromNitro(nitro), {
|
|
89
|
+
externalServices: nitro.options.graphql?.externalServices,
|
|
90
|
+
clientDirRelative: relative(nitro.options.rootDir, nitro.graphql.clientDir)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var adapter_default = NitroAdapter;
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { NitroAdapter, createCoreConfigFromNitro, createCoreContextFromNitro, createLoggerFromNitro, createScanContextFromNitro, adapter_default as default };
|
|
@@ -2,7 +2,7 @@ import { ApolloServer, BaseContext, ContextFunction } from "@apollo/server";
|
|
|
2
2
|
import { EventHandler, H3Event } from "nitro/h3";
|
|
3
3
|
import { Hooks } from "crossws";
|
|
4
4
|
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/nitro/apollo.d.ts
|
|
6
6
|
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
7
7
|
interface H3ContextFunctionArgument {
|
|
8
8
|
event: H3Event;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HeaderMap } from "@apollo/server";
|
|
2
2
|
import { eventHandler, getRequestURL, readBody } from "nitro/h3";
|
|
3
3
|
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/nitro/apollo.ts
|
|
5
5
|
function startServerAndCreateH3Handler(server, options) {
|
|
6
6
|
const defaultContext = () => Promise.resolve({});
|
|
7
7
|
const contextFunction = options?.context ?? defaultContext;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Nitro } from "nitro/types";
|
|
2
|
+
|
|
3
|
+
//#region src/nitro/codegen.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate server-side resolver types
|
|
7
|
+
*/
|
|
8
|
+
declare function generateServerTypes(nitro: Nitro, options?: {
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Generate client-side operation types
|
|
13
|
+
*/
|
|
14
|
+
declare function generateClientTypes(nitro: Nitro, options?: {
|
|
15
|
+
silent?: boolean;
|
|
16
|
+
isInitial?: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { generateClientTypes, generateServerTypes };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { LOG_TAG } from "../core/constants.mjs";
|
|
2
|
+
import { loadGraphQLDocuments } from "../core/codegen/document-loader.mjs";
|
|
3
|
+
import { writeFile } from "../core/utils/file-io.mjs";
|
|
4
|
+
import { downloadAndSaveSchema, loadExternalSchema } from "../core/codegen/schema-loader.mjs";
|
|
5
|
+
import { generateClientTypesCore, generateExternalClientTypesCore } from "../core/codegen/client.mjs";
|
|
6
|
+
import { generateServerTypesCore } from "../core/codegen/server.mjs";
|
|
7
|
+
import { validateNoDuplicateTypes } from "../core/codegen/validation.mjs";
|
|
8
|
+
import { loadFederationSupport } from "../core/schema/federation.mjs";
|
|
9
|
+
import { getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateTypes } from "./paths.mjs";
|
|
10
|
+
import consola from "consola";
|
|
11
|
+
import { join, resolve } from "pathe";
|
|
12
|
+
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
13
|
+
import { buildSchema, parse, print } from "graphql";
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
16
|
+
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
17
|
+
|
|
18
|
+
//#region src/nitro/codegen.ts
|
|
19
|
+
const logger = consola.withTag(LOG_TAG);
|
|
20
|
+
async function buildSchemaFromString(source, federation) {
|
|
21
|
+
if (federation) {
|
|
22
|
+
const buildSubgraph = await loadFederationSupport();
|
|
23
|
+
if (!buildSubgraph) throw new Error("Federation enabled but @apollo/subgraph not installed");
|
|
24
|
+
return buildSubgraph([{ typeDefs: parse(source) }]);
|
|
25
|
+
}
|
|
26
|
+
return buildSchema(source);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate server-side resolver types
|
|
30
|
+
*/
|
|
31
|
+
async function generateServerTypes(nitro, options = {}) {
|
|
32
|
+
if (!shouldGenerateTypes(nitro)) return;
|
|
33
|
+
const schemas = nitro.scanSchemas || [];
|
|
34
|
+
if (!schemas.length) {
|
|
35
|
+
if (!options.silent) consola.info("No GraphQL schemas found");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const strings = loadFilesSync(schemas).map((s) => typeof s === "string" ? s : s.loc?.source?.body || "").filter(Boolean);
|
|
40
|
+
if (!validateNoDuplicateTypes(schemas, strings)) return;
|
|
41
|
+
const merged = mergeTypeDefs([strings.join("\n\n")], { throwOnConflict: true });
|
|
42
|
+
const federation = nitro.options.graphql?.federation?.enabled === true;
|
|
43
|
+
const schema = await buildSchemaFromString(print(merged), federation);
|
|
44
|
+
const result = await generateServerTypesCore({
|
|
45
|
+
framework: nitro.options.graphql?.framework || "graphql-yoga",
|
|
46
|
+
schema,
|
|
47
|
+
config: nitro.options.graphql?.codegen?.server,
|
|
48
|
+
federationEnabled: federation
|
|
49
|
+
});
|
|
50
|
+
writeFile(resolve(nitro.graphql.buildDir, "schema.graphql"), printSchemaWithDirectives(schema));
|
|
51
|
+
const placeholders = getDefaultPaths(nitro);
|
|
52
|
+
const typesConfig = getTypesConfig(nitro);
|
|
53
|
+
const typesPath = resolveFilePath(typesConfig.server, typesConfig.enabled, true, "{typesDir}/nitro-graphql-server.d.ts", placeholders);
|
|
54
|
+
if (typesPath) {
|
|
55
|
+
writeFile(typesPath, result.types);
|
|
56
|
+
if (!options.silent) logger.success(`Server types: ${typesPath}`);
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error("Server type generation failed:", error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate client-side operation types
|
|
64
|
+
*/
|
|
65
|
+
async function generateClientTypes(nitro, options = {}) {
|
|
66
|
+
try {
|
|
67
|
+
if (nitro.scanSchemas?.length) await generateMainClientTypes(nitro, options);
|
|
68
|
+
if (nitro.options.graphql?.externalServices?.length) await generateExternalTypes(nitro, options);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logger.error("Client type generation failed:", error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function generateMainClientTypes(nitro, options = {}) {
|
|
74
|
+
const schemaPath = join(nitro.graphql.buildDir, "schema.graphql");
|
|
75
|
+
if (!existsSync(schemaPath)) {
|
|
76
|
+
if (!options.silent) consola.info("Schema not ready for client types");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const docs = await loadGraphQLDocuments(nitro.scanDocuments);
|
|
80
|
+
const federation = nitro.options.graphql?.federation?.enabled === true;
|
|
81
|
+
const types = await generateClientTypesCore({
|
|
82
|
+
schema: await buildSchemaFromString(readFileSync(schemaPath, "utf-8"), federation),
|
|
83
|
+
documents: docs,
|
|
84
|
+
config: nitro.options.graphql?.codegen?.client,
|
|
85
|
+
sdkConfig: nitro.options.graphql?.codegen?.clientSDK,
|
|
86
|
+
options
|
|
87
|
+
});
|
|
88
|
+
if (types === false) return;
|
|
89
|
+
const placeholders = getDefaultPaths(nitro);
|
|
90
|
+
const typesConfig = getTypesConfig(nitro);
|
|
91
|
+
const sdkConfig = getSdkConfig(nitro);
|
|
92
|
+
const clientPath = resolveFilePath(typesConfig.client, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client.d.ts", placeholders);
|
|
93
|
+
if (clientPath) {
|
|
94
|
+
writeFile(clientPath, types.types);
|
|
95
|
+
if (!options.silent) logger.success(`Client types: ${clientPath}`);
|
|
96
|
+
}
|
|
97
|
+
const sdkPath = resolveFilePath(sdkConfig.main, sdkConfig.enabled, true, "{clientGraphql}/default/sdk.ts", placeholders);
|
|
98
|
+
if (sdkPath) {
|
|
99
|
+
writeFile(sdkPath, types.sdk);
|
|
100
|
+
if (!options.silent) logger.success(`SDK: ${sdkPath}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function generateExternalTypes(nitro, options = {}) {
|
|
104
|
+
for (const service of nitro.options.graphql?.externalServices || []) try {
|
|
105
|
+
if (!options.silent) consola.info(`[${service.name}] Processing external service`);
|
|
106
|
+
await downloadAndSaveSchema(service, nitro.options.buildDir);
|
|
107
|
+
const schema = await loadExternalSchema(service, nitro.options.buildDir);
|
|
108
|
+
if (!schema) {
|
|
109
|
+
consola.warn(`[${service.name}] Failed to load schema`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const docs = service.documents?.length ? await loadGraphQLDocuments(service.documents).catch(() => []) : [];
|
|
113
|
+
if (service.documents?.length && !docs.length) {
|
|
114
|
+
consola.warn(`[${service.name}] No documents found`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const types = await generateExternalClientTypesCore(service, schema, docs);
|
|
118
|
+
if (types === false) continue;
|
|
119
|
+
const placeholders = {
|
|
120
|
+
...getDefaultPaths(nitro),
|
|
121
|
+
serviceName: service.name
|
|
122
|
+
};
|
|
123
|
+
const typesConfig = getTypesConfig(nitro);
|
|
124
|
+
const sdkConfig = getSdkConfig(nitro);
|
|
125
|
+
const typesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", placeholders);
|
|
126
|
+
if (typesPath) {
|
|
127
|
+
writeFile(typesPath, types.types);
|
|
128
|
+
if (!options.silent) consola.success(`[${service.name}] Types: ${typesPath}`);
|
|
129
|
+
}
|
|
130
|
+
const sdkPath = resolveFilePath(service.paths?.sdk ?? sdkConfig.external, sdkConfig.enabled, true, "{clientGraphql}/{serviceName}/sdk.ts", placeholders);
|
|
131
|
+
if (sdkPath) {
|
|
132
|
+
writeFile(sdkPath, types.sdk);
|
|
133
|
+
if (!options.silent) consola.success(`[${service.name}] SDK: ${sdkPath}`);
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
consola.error(`[${service.name}] External service failed:`, error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { generateClientTypes, generateServerTypes };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NitroGraphQLOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/nitro/config.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default type generation configuration
|
|
7
|
+
*/
|
|
8
|
+
declare const DEFAULT_TYPES_CONFIG: {
|
|
9
|
+
readonly server: ".graphql/nitro-graphql-server.d.ts";
|
|
10
|
+
readonly client: ".graphql/nitro-graphql-client.d.ts";
|
|
11
|
+
readonly enabled: true;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Default runtime GraphQL configuration
|
|
15
|
+
*/
|
|
16
|
+
declare const DEFAULT_RUNTIME_CONFIG: NitroGraphQLOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Default ignore patterns for file watching
|
|
19
|
+
*/
|
|
20
|
+
declare const DEFAULT_IGNORE_PATTERNS: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Default SDK configuration
|
|
23
|
+
*/
|
|
24
|
+
declare const DEFAULT_SDK_CONFIG: {
|
|
25
|
+
readonly enabled: true;
|
|
26
|
+
readonly main: true;
|
|
27
|
+
readonly external: true;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Default paths configuration
|
|
31
|
+
* These are used as placeholders and resolved based on framework
|
|
32
|
+
*/
|
|
33
|
+
declare const DEFAULT_PATHS_CONFIG: {
|
|
34
|
+
readonly serverGraphql: "server/graphql";
|
|
35
|
+
readonly clientGraphql: null;
|
|
36
|
+
readonly buildDir: null;
|
|
37
|
+
readonly typesDir: null;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Default TypeScript strict mode setting
|
|
41
|
+
*/
|
|
42
|
+
declare const DEFAULT_TYPESCRIPT_STRICT: true;
|
|
43
|
+
/**
|
|
44
|
+
* Default watcher persistence setting
|
|
45
|
+
*/
|
|
46
|
+
declare const DEFAULT_WATCHER_PERSISTENT: true;
|
|
47
|
+
/**
|
|
48
|
+
* Default watcher ignore initial setting
|
|
49
|
+
*/
|
|
50
|
+
declare const DEFAULT_WATCHER_IGNORE_INITIAL: true;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { DEFAULT_IGNORE_PATTERNS, DEFAULT_PATHS_CONFIG, DEFAULT_RUNTIME_CONFIG, DEFAULT_SDK_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG, DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DEFAULT_CLIENT_TYPES_PATH, DEFAULT_SERVER_TYPES_PATH, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH } from "../core/constants.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/nitro/config.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default type generation configuration
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_TYPES_CONFIG = {
|
|
8
|
+
server: DEFAULT_SERVER_TYPES_PATH,
|
|
9
|
+
client: DEFAULT_CLIENT_TYPES_PATH,
|
|
10
|
+
enabled: true
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Default runtime GraphQL configuration
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_RUNTIME_CONFIG = {
|
|
16
|
+
endpoint: {
|
|
17
|
+
graphql: ENDPOINT_GRAPHQL,
|
|
18
|
+
healthCheck: ENDPOINT_HEALTH
|
|
19
|
+
},
|
|
20
|
+
playground: true
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Default ignore patterns for file watching
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_IGNORE_PATTERNS = [];
|
|
26
|
+
/**
|
|
27
|
+
* Default SDK configuration
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_SDK_CONFIG = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
main: true,
|
|
32
|
+
external: true
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default paths configuration
|
|
36
|
+
* These are used as placeholders and resolved based on framework
|
|
37
|
+
*/
|
|
38
|
+
const DEFAULT_PATHS_CONFIG = {
|
|
39
|
+
serverGraphql: "server/graphql",
|
|
40
|
+
clientGraphql: null,
|
|
41
|
+
buildDir: null,
|
|
42
|
+
typesDir: null
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Default TypeScript strict mode setting
|
|
46
|
+
*/
|
|
47
|
+
const DEFAULT_TYPESCRIPT_STRICT = true;
|
|
48
|
+
/**
|
|
49
|
+
* Default watcher persistence setting
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_WATCHER_PERSISTENT = true;
|
|
52
|
+
/**
|
|
53
|
+
* Default watcher ignore initial setting
|
|
54
|
+
*/
|
|
55
|
+
const DEFAULT_WATCHER_IGNORE_INITIAL = true;
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { DEFAULT_IGNORE_PATTERNS, DEFAULT_PATHS_CONFIG, DEFAULT_RUNTIME_CONFIG, DEFAULT_SDK_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG, DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroGraphQLOptions, PathsConfig, SdkConfig, SecurityConfig, StandardSchemaV1, TypesConfig } from "./types.mjs";
|
|
2
|
+
import { NitroAdapter } from "./adapter.mjs";
|
|
3
|
+
import { resolveSecurityConfig } from "./setup/logging.mjs";
|
|
4
|
+
import { setupNitroGraphQL } from "./setup.mjs";
|
|
5
|
+
import { NitroModule } from "nitro/types";
|
|
6
|
+
import { Plugin } from "vite";
|
|
7
|
+
|
|
8
|
+
//#region src/nitro/index.d.ts
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Vite plugin to load GraphQL files as strings AND auto-register Nitro module
|
|
12
|
+
* This prevents Vite from trying to parse .graphql/.gql files as JavaScript
|
|
13
|
+
* and automatically sets up the nitro-graphql module via the nitro: hook
|
|
14
|
+
*
|
|
15
|
+
* @example - Vite usage
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { defineConfig } from 'vite'
|
|
18
|
+
* import { nitro } from 'nitro/vite'
|
|
19
|
+
* import graphql from 'nitro-graphql'
|
|
20
|
+
*
|
|
21
|
+
* export default defineConfig({
|
|
22
|
+
* plugins: [
|
|
23
|
+
* graphql({ framework: 'graphql-yoga' }), // Auto-registers Nitro module
|
|
24
|
+
* nitro()
|
|
25
|
+
* ]
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
* @example - Nitro direct usage
|
|
31
|
+
* ```ts
|
|
32
|
+
*
|
|
33
|
+
* import graphql from 'nitro-graphql'
|
|
34
|
+
*
|
|
35
|
+
* export default defineConfig({
|
|
36
|
+
* modules: [
|
|
37
|
+
* graphql({ framework: 'graphql-yoga' }) // Auto-registers Nitro module
|
|
38
|
+
* ]
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function graphqlModule(options?: NitroGraphQLOptions): Plugin & {
|
|
43
|
+
nitro?: NitroModule;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { CodegenClientConfig, CodegenServerConfig, DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, ExtendSource, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, Flatten, GenImport, GenericSdkConfig, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, NitroAdapter, NitroGraphQLOptions, PathsConfig, SdkConfig, SecurityConfig, StandardSchemaV1, TypesConfig, graphqlModule as default, resolveSecurityConfig, setupNitroGraphQL };
|