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,31 @@
|
|
|
1
|
+
//#region src/nitro/virtual/stubs.ts
|
|
2
|
+
/**
|
|
3
|
+
* Virtual module stubs for #nitro-graphql/*
|
|
4
|
+
* Used during build to prevent import resolution errors.
|
|
5
|
+
* At runtime, Nitro overrides these with actual virtual modules.
|
|
6
|
+
*/
|
|
7
|
+
const schemas = [];
|
|
8
|
+
const resolvers = [];
|
|
9
|
+
const directives = [];
|
|
10
|
+
const moduleConfig = {};
|
|
11
|
+
const importedConfig = {};
|
|
12
|
+
const debugInfo = {
|
|
13
|
+
isDev: false,
|
|
14
|
+
framework: "",
|
|
15
|
+
graphqlFramework: "",
|
|
16
|
+
federation: {},
|
|
17
|
+
scanned: {
|
|
18
|
+
schemas: 0,
|
|
19
|
+
schemaFiles: [],
|
|
20
|
+
resolvers: 0,
|
|
21
|
+
resolverFiles: [],
|
|
22
|
+
directives: 0,
|
|
23
|
+
directiveFiles: [],
|
|
24
|
+
documents: 0,
|
|
25
|
+
documentFiles: []
|
|
26
|
+
},
|
|
27
|
+
virtualModules: {}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { debugInfo, directives, importedConfig, moduleConfig, resolvers, schemas };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getDefaultPaths, getTypesConfig, resolveFilePath } from "
|
|
1
|
+
import { getDefaultPaths, getTypesConfig, resolveFilePath } from "./nitro/paths.mjs";
|
|
2
2
|
import { dirname, join, relative, resolve } from "pathe";
|
|
3
3
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { defineNuxtModule, getLayerDirectories } from "@nuxt/kit";
|
|
5
5
|
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/nuxt.ts
|
|
7
7
|
var nuxt_default = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
9
9
|
name: "nitro-graphql-nuxt",
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/stubs/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Runtime type stubs for GraphQL types
|
|
4
|
+
* These interfaces are replaced by generated types at build time
|
|
5
|
+
*/
|
|
2
6
|
interface StandardSchemaV1 extends Record<string, any> {}
|
|
3
7
|
interface ResolversTypes extends Record<string, any> {}
|
|
4
8
|
interface Resolvers extends Record<string, any> {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-graphql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.39",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -11,32 +11,32 @@
|
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"imports": {
|
|
13
13
|
"#graphql/server": {
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/
|
|
14
|
+
"types": "./dist/stubs/index.d.mts",
|
|
15
|
+
"import": "./dist/stubs/index.mjs"
|
|
16
16
|
},
|
|
17
17
|
"#nitro-graphql/graphql-config": {
|
|
18
|
-
"types": "./dist/virtual/
|
|
19
|
-
"import": "./dist/virtual/
|
|
18
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
19
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
20
20
|
},
|
|
21
21
|
"#nitro-graphql/server-schemas": {
|
|
22
|
-
"types": "./dist/virtual/
|
|
23
|
-
"import": "./dist/virtual/
|
|
22
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
23
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
24
24
|
},
|
|
25
25
|
"#nitro-graphql/server-resolvers": {
|
|
26
|
-
"types": "./dist/virtual/
|
|
27
|
-
"import": "./dist/virtual/
|
|
26
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
27
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
28
28
|
},
|
|
29
29
|
"#nitro-graphql/server-directives": {
|
|
30
|
-
"types": "./dist/virtual/
|
|
31
|
-
"import": "./dist/virtual/
|
|
30
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
31
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
32
32
|
},
|
|
33
33
|
"#nitro-graphql/module-config": {
|
|
34
|
-
"types": "./dist/virtual/
|
|
35
|
-
"import": "./dist/virtual/
|
|
34
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
35
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
36
36
|
},
|
|
37
37
|
"#nitro-graphql/debug-info": {
|
|
38
|
-
"types": "./dist/virtual/
|
|
39
|
-
"import": "./dist/virtual/
|
|
38
|
+
"types": "./dist/nitro/virtual/stubs.d.mts",
|
|
39
|
+
"import": "./dist/nitro/virtual/stubs.mjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
@@ -44,33 +44,32 @@
|
|
|
44
44
|
"types": "./dist/index.d.mts",
|
|
45
45
|
"import": "./dist/index.mjs"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
48
|
-
"types": "./dist/
|
|
49
|
-
"import": "./dist/
|
|
47
|
+
"./core": {
|
|
48
|
+
"types": "./dist/core/index.d.mts",
|
|
49
|
+
"import": "./dist/core/index.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./cli": {
|
|
52
|
+
"types": "./dist/cli/index.d.mts",
|
|
53
|
+
"import": "./dist/cli/index.mjs"
|
|
50
54
|
},
|
|
51
55
|
"./define": {
|
|
52
56
|
"types": "./dist/define.d.mts",
|
|
53
57
|
"import": "./dist/define.mjs"
|
|
54
58
|
},
|
|
55
|
-
"./
|
|
56
|
-
"types": "./dist/
|
|
57
|
-
"import": "./dist/
|
|
59
|
+
"./apollo": {
|
|
60
|
+
"types": "./dist/nitro/apollo.d.mts",
|
|
61
|
+
"import": "./dist/nitro/apollo.mjs"
|
|
58
62
|
},
|
|
59
63
|
"./nuxt": {
|
|
60
|
-
"types": "./dist/
|
|
61
|
-
"import": "./dist/
|
|
62
|
-
},
|
|
63
|
-
"./vite": {
|
|
64
|
-
"types": "./dist/vite.d.mts",
|
|
65
|
-
"import": "./dist/vite.mjs"
|
|
66
|
-
},
|
|
67
|
-
"./types": {
|
|
68
|
-
"types": "./dist/types/index.d.mts",
|
|
69
|
-
"import": "./dist/types/index.mjs"
|
|
64
|
+
"types": "./dist/nuxt.d.mts",
|
|
65
|
+
"import": "./dist/nuxt.mjs"
|
|
70
66
|
}
|
|
71
67
|
},
|
|
72
68
|
"module": "./dist/index.mjs",
|
|
73
69
|
"types": "./dist/index.d.mts",
|
|
70
|
+
"bin": {
|
|
71
|
+
"nitro-graphql": "./dist/cli/index.mjs"
|
|
72
|
+
},
|
|
74
73
|
"files": [
|
|
75
74
|
"dist"
|
|
76
75
|
],
|
|
@@ -86,13 +85,14 @@
|
|
|
86
85
|
},
|
|
87
86
|
"dependencies": {
|
|
88
87
|
"@apollo/subgraph": "^2.12.2",
|
|
88
|
+
"@bomb.sh/tab": "^0.0.11",
|
|
89
89
|
"@graphql-codegen/core": "^5.0.0",
|
|
90
90
|
"@graphql-codegen/import-types-preset": "^3.0.1",
|
|
91
91
|
"@graphql-codegen/typed-document-node": "^6.1.5",
|
|
92
|
-
"@graphql-codegen/typescript": "^5.0.
|
|
92
|
+
"@graphql-codegen/typescript": "^5.0.7",
|
|
93
93
|
"@graphql-codegen/typescript-generic-sdk": "^4.0.2",
|
|
94
|
-
"@graphql-codegen/typescript-operations": "^5.0.
|
|
95
|
-
"@graphql-codegen/typescript-resolvers": "^5.1.
|
|
94
|
+
"@graphql-codegen/typescript-operations": "^5.0.7",
|
|
95
|
+
"@graphql-codegen/typescript-resolvers": "^5.1.5",
|
|
96
96
|
"@graphql-tools/graphql-file-loader": "^8.1.8",
|
|
97
97
|
"@graphql-tools/load": "^8.1.7",
|
|
98
98
|
"@graphql-tools/load-files": "^7.0.1",
|
|
@@ -101,23 +101,25 @@
|
|
|
101
101
|
"@graphql-tools/url-loader": "^9.0.5",
|
|
102
102
|
"@graphql-tools/utils": "^10.11.0",
|
|
103
103
|
"chokidar": "^5.0.0",
|
|
104
|
+
"citty": "^0.1.6",
|
|
104
105
|
"consola": "^3.4.2",
|
|
105
106
|
"defu": "^6.1.4",
|
|
107
|
+
"giget": "^2.0.0",
|
|
106
108
|
"graphql-config": "^5.1.5",
|
|
107
109
|
"graphql-scalars": "^1.25.0",
|
|
108
110
|
"knitwork": "^1.3.0",
|
|
109
111
|
"ohash": "^2.0.11",
|
|
110
|
-
"oxc-parser": "^0.
|
|
112
|
+
"oxc-parser": "^0.106.0",
|
|
111
113
|
"pathe": "^2.0.3",
|
|
112
114
|
"tinyglobby": "^0.2.15"
|
|
113
115
|
},
|
|
114
116
|
"devDependencies": {
|
|
115
|
-
"@antfu/eslint-config": "^6.7.
|
|
117
|
+
"@antfu/eslint-config": "^6.7.3",
|
|
116
118
|
"@nuxt/kit": "^4.2.2",
|
|
117
119
|
"@nuxt/schema": "^4.2.2",
|
|
118
|
-
"@types/node": "^
|
|
120
|
+
"@types/node": "^25.0.3",
|
|
119
121
|
"@vitejs/devtools": "^0.0.0-alpha.16",
|
|
120
|
-
"@vitest/ui": "^4.0.
|
|
122
|
+
"@vitest/ui": "^4.0.16",
|
|
121
123
|
"bumpp": "^10.3.2",
|
|
122
124
|
"changelogen": "^0.6.2",
|
|
123
125
|
"crossws": "^0.4.1",
|
|
@@ -125,11 +127,11 @@
|
|
|
125
127
|
"graphql": "16.12.0",
|
|
126
128
|
"graphql-yoga": "5.16.2",
|
|
127
129
|
"nitro": "3.0.1-alpha.1",
|
|
128
|
-
"tsdown": "^0.
|
|
130
|
+
"tsdown": "^0.18.4",
|
|
129
131
|
"typescript": "^5.9.3",
|
|
130
|
-
"vite": "8.0.0-beta.
|
|
131
|
-
"vitepress-plugin-llms": "^1.
|
|
132
|
-
"vitest": "^4.0.
|
|
132
|
+
"vite": "8.0.0-beta.5",
|
|
133
|
+
"vitepress-plugin-llms": "^1.10.0",
|
|
134
|
+
"vitest": "^4.0.16"
|
|
133
135
|
},
|
|
134
136
|
"resolutions": {
|
|
135
137
|
"nitro-graphql": "link:."
|
|
@@ -145,6 +147,7 @@
|
|
|
145
147
|
"docs:dev": "cd .docs && pnpm install && pnpm update:metadata && pnpm dev",
|
|
146
148
|
"docs:build": "cd .docs && pnpm install && pnpm update:metadata && pnpm build",
|
|
147
149
|
"docs:preview": "cd .docs && pnpm preview",
|
|
150
|
+
"cli": "node ./dist/cli/index.mjs",
|
|
148
151
|
"lint": "eslint .",
|
|
149
152
|
"lint:fix": "eslint . --fix",
|
|
150
153
|
"test": "vitest",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/codegen/client-types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate main client types (for the default service)
|
|
7
|
-
*/
|
|
8
|
-
declare function generateMainClientTypes(nitro: Nitro, options?: {
|
|
9
|
-
silent?: boolean;
|
|
10
|
-
isInitial?: boolean;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { generateMainClientTypes };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { FILE_INDEX_TS, LOG_TAG, SERVICE_DEFAULT } from "../constants.mjs";
|
|
2
|
-
import { generateClientTypes, loadGraphQLDocuments } from "../utils/client-codegen.mjs";
|
|
3
|
-
import { loadFederationSupport } from "../utils/federation.mjs";
|
|
4
|
-
import { writeFileIfNotExists } from "../utils/file-generator.mjs";
|
|
5
|
-
import { generateOfetchTemplate } from "../utils/ofetch-templates.mjs";
|
|
6
|
-
import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils } from "../utils/path-resolver.mjs";
|
|
7
|
-
import consola from "consola";
|
|
8
|
-
import { dirname, join, resolve } from "pathe";
|
|
9
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { buildSchema, parse } from "graphql";
|
|
11
|
-
|
|
12
|
-
//#region src/codegen/client-types.ts
|
|
13
|
-
const logger = consola.withTag(LOG_TAG);
|
|
14
|
-
/**
|
|
15
|
-
* Check for old structure files and warn user about manual migration
|
|
16
|
-
*/
|
|
17
|
-
function warnLegacyGraphQLStructure(clientDir) {
|
|
18
|
-
const oldOfetchPath = resolve(clientDir, "ofetch.ts");
|
|
19
|
-
const oldSdkPath = resolve(clientDir, "sdk.ts");
|
|
20
|
-
if (existsSync(oldOfetchPath) || existsSync(oldSdkPath)) {
|
|
21
|
-
const foundFiles = [];
|
|
22
|
-
if (existsSync(oldOfetchPath)) foundFiles.push("app/graphql/ofetch.ts");
|
|
23
|
-
if (existsSync(oldSdkPath)) foundFiles.push("app/graphql/sdk.ts");
|
|
24
|
-
consola.error(`⚠️ OLD GRAPHQL STRUCTURE DETECTED!
|
|
25
|
-
|
|
26
|
-
📁 Found old files in app/graphql/ directory that need to be moved:
|
|
27
|
-
• ${foundFiles.join("\n • ")}
|
|
28
|
-
|
|
29
|
-
🔄 Please manually move these files to the new structure:
|
|
30
|
-
• app/graphql/ofetch.ts → app/graphql/default/ofetch.ts
|
|
31
|
-
• app/graphql/sdk.ts → app/graphql/default/sdk.ts
|
|
32
|
-
|
|
33
|
-
📝 Also update your app/graphql/index.ts to include:
|
|
34
|
-
export * from './default/ofetch'
|
|
35
|
-
|
|
36
|
-
💡 After moving, update your imports to use:
|
|
37
|
-
import { $sdk } from "#graphql/client"
|
|
38
|
-
|
|
39
|
-
🚫 The old files will cause import conflicts until moved!`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Generate main client types (for the default service)
|
|
44
|
-
*/
|
|
45
|
-
async function generateMainClientTypes(nitro, options = {}) {
|
|
46
|
-
warnLegacyGraphQLStructure(nitro.graphql.clientDir);
|
|
47
|
-
const docs = nitro.scanDocuments;
|
|
48
|
-
const loadedDocs = await loadGraphQLDocuments(docs);
|
|
49
|
-
const schemaFilePath = join(nitro.graphql.buildDir, "schema.graphql");
|
|
50
|
-
if (!existsSync(schemaFilePath)) {
|
|
51
|
-
if (!options.silent) consola.info("Schema file not ready yet for client type generation. Server types need to be generated first.");
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const graphqlString = readFileSync(schemaFilePath, "utf-8");
|
|
55
|
-
const federationEnabled = nitro.options.graphql?.federation?.enabled === true;
|
|
56
|
-
let schema;
|
|
57
|
-
if (federationEnabled) {
|
|
58
|
-
const buildSubgraph = await loadFederationSupport();
|
|
59
|
-
if (!buildSubgraph) throw new Error("Federation is enabled but @apollo/subgraph is not installed. Run: pnpm add @apollo/subgraph");
|
|
60
|
-
schema = buildSubgraph([{ typeDefs: parse(graphqlString) }]);
|
|
61
|
-
} else schema = buildSchema(graphqlString);
|
|
62
|
-
const types = await generateClientTypes(schema, loadedDocs, nitro.options.graphql?.codegen?.client ?? {}, nitro.options.graphql?.codegen?.clientSDK ?? {}, void 0, void 0, void 0, options);
|
|
63
|
-
if (types === false) return;
|
|
64
|
-
const placeholders = getDefaultPaths(nitro);
|
|
65
|
-
const typesConfig = getTypesConfig(nitro);
|
|
66
|
-
const sdkConfig = getSdkConfig(nitro);
|
|
67
|
-
const clientTypesPath = resolveFilePath(typesConfig.client, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client.d.ts", placeholders);
|
|
68
|
-
if (clientTypesPath) {
|
|
69
|
-
mkdirSync(dirname(clientTypesPath), { recursive: true });
|
|
70
|
-
writeFileSync(clientTypesPath, types.types, "utf-8");
|
|
71
|
-
if (!options.silent) logger.success(`Generated client types at: ${clientTypesPath}`);
|
|
72
|
-
}
|
|
73
|
-
const sdkPath = resolveFilePath(sdkConfig.main, sdkConfig.enabled, true, "{clientGraphql}/default/sdk.ts", placeholders);
|
|
74
|
-
if (sdkPath) {
|
|
75
|
-
mkdirSync(dirname(sdkPath), { recursive: true });
|
|
76
|
-
writeFileSync(sdkPath, types.sdk, "utf-8");
|
|
77
|
-
if (!options.silent) logger.success(`Generated SDK at: ${sdkPath}`);
|
|
78
|
-
}
|
|
79
|
-
generateNuxtOfetchClient(nitro, nitro.graphql.clientDir, SERVICE_DEFAULT);
|
|
80
|
-
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
81
|
-
if (externalServices.length > 0) generateGraphQLIndexFile(nitro, nitro.graphql.clientDir, externalServices);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Generate GraphQL index file that exports all services
|
|
85
|
-
*/
|
|
86
|
-
function generateGraphQLIndexFile(nitro, clientDir, externalServices = []) {
|
|
87
|
-
if (!shouldGenerateClientUtils(nitro)) return;
|
|
88
|
-
const placeholders = getDefaultPaths(nitro);
|
|
89
|
-
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
90
|
-
const indexPath = resolveFilePath(clientUtilsConfig.index, clientUtilsConfig.enabled, true, `{clientGraphql}/${FILE_INDEX_TS}`, placeholders);
|
|
91
|
-
if (!indexPath) return;
|
|
92
|
-
if (!existsSync(indexPath)) {
|
|
93
|
-
let indexContent = `// This file is auto-generated once by nitro-graphql for quick start
|
|
94
|
-
// You can modify this file according to your needs
|
|
95
|
-
//
|
|
96
|
-
// Export your main GraphQL service (auto-generated)
|
|
97
|
-
export * from './default/ofetch'
|
|
98
|
-
|
|
99
|
-
// Export external GraphQL services (auto-generated for existing services)
|
|
100
|
-
// When you add new external services, don't forget to add their exports here:
|
|
101
|
-
// export * from './yourServiceName/ofetch'
|
|
102
|
-
`;
|
|
103
|
-
for (const service of externalServices) indexContent += `export * from './${service.name}/ofetch'\n`;
|
|
104
|
-
writeFileIfNotExists(indexPath, indexContent, `client ${FILE_INDEX_TS}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Generate ofetch client wrapper for Nuxt/Nitro
|
|
109
|
-
*/
|
|
110
|
-
function generateNuxtOfetchClient(nitro, clientDir, serviceName = SERVICE_DEFAULT) {
|
|
111
|
-
if (!shouldGenerateClientUtils(nitro)) return;
|
|
112
|
-
const placeholders = {
|
|
113
|
-
...getDefaultPaths(nitro),
|
|
114
|
-
serviceName
|
|
115
|
-
};
|
|
116
|
-
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
117
|
-
const ofetchPath = resolveFilePath(clientUtilsConfig.ofetch, clientUtilsConfig.enabled, true, "{clientGraphql}/{serviceName}/ofetch.ts", placeholders);
|
|
118
|
-
if (!ofetchPath) return;
|
|
119
|
-
const serviceDir = dirname(ofetchPath);
|
|
120
|
-
if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
|
|
121
|
-
if (existsSync(ofetchPath)) return;
|
|
122
|
-
writeFileIfNotExists(ofetchPath, generateOfetchTemplate({
|
|
123
|
-
serviceName,
|
|
124
|
-
isNuxt: nitro.options.framework?.name === "nuxt",
|
|
125
|
-
endpoint: "/api/graphql",
|
|
126
|
-
isExternal: false
|
|
127
|
-
}), `${serviceName} ofetch.ts`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
//#endregion
|
|
131
|
-
export { generateMainClientTypes };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/codegen/external-types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate types for all external GraphQL services
|
|
7
|
-
*/
|
|
8
|
-
declare function generateExternalServicesTypes(nitro: Nitro, options?: {
|
|
9
|
-
silent?: boolean;
|
|
10
|
-
}): Promise<void>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { generateExternalServicesTypes };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { downloadAndSaveSchema, generateExternalClientTypes, loadExternalSchema, loadGraphQLDocuments } from "../utils/client-codegen.mjs";
|
|
2
|
-
import { writeFileIfNotExists } from "../utils/file-generator.mjs";
|
|
3
|
-
import { generateOfetchTemplate } from "../utils/ofetch-templates.mjs";
|
|
4
|
-
import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils } from "../utils/path-resolver.mjs";
|
|
5
|
-
import consola from "consola";
|
|
6
|
-
import { dirname } from "pathe";
|
|
7
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
-
|
|
9
|
-
//#region src/codegen/external-types.ts
|
|
10
|
-
/**
|
|
11
|
-
* Generate types for all external GraphQL services
|
|
12
|
-
*/
|
|
13
|
-
async function generateExternalServicesTypes(nitro, options = {}) {
|
|
14
|
-
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
15
|
-
for (const service of externalServices) try {
|
|
16
|
-
if (!options.silent) consola.info(`[graphql:${service.name}] Processing external service`);
|
|
17
|
-
await downloadAndSaveSchema(service, nitro.options.buildDir);
|
|
18
|
-
const schema = await loadExternalSchema(service, nitro.options.buildDir);
|
|
19
|
-
if (!schema) {
|
|
20
|
-
consola.warn(`[graphql:${service.name}] Failed to load schema, skipping`);
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const documentPatterns = service.documents || [];
|
|
24
|
-
let loadedDocs = [];
|
|
25
|
-
if (documentPatterns.length > 0) try {
|
|
26
|
-
loadedDocs = await loadGraphQLDocuments(documentPatterns);
|
|
27
|
-
if (!loadedDocs || loadedDocs.length === 0) {
|
|
28
|
-
consola.warn(`[graphql:${service.name}] No GraphQL documents found, skipping service generation`);
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
consola.warn(`[graphql:${service.name}] No documents found, skipping service generation:`, error);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const types = await generateExternalClientTypes(service, schema, loadedDocs);
|
|
36
|
-
if (types === false) {
|
|
37
|
-
consola.warn(`[graphql:${service.name}] Type generation failed`);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const placeholders = {
|
|
41
|
-
...getDefaultPaths(nitro),
|
|
42
|
-
serviceName: service.name
|
|
43
|
-
};
|
|
44
|
-
const typesConfig = getTypesConfig(nitro);
|
|
45
|
-
const sdkConfig = getSdkConfig(nitro);
|
|
46
|
-
const serviceTypesPath = resolveFilePath(service.paths?.types ?? typesConfig.external, typesConfig.enabled, true, "{typesDir}/nitro-graphql-client-{serviceName}.d.ts", placeholders);
|
|
47
|
-
if (serviceTypesPath) {
|
|
48
|
-
mkdirSync(dirname(serviceTypesPath), { recursive: true });
|
|
49
|
-
writeFileSync(serviceTypesPath, types.types, "utf-8");
|
|
50
|
-
if (!options.silent) consola.success(`[graphql:${service.name}] Generated types at: ${serviceTypesPath}`);
|
|
51
|
-
}
|
|
52
|
-
const serviceSdkPath = resolveFilePath(service.paths?.sdk ?? sdkConfig.external, sdkConfig.enabled, true, "{clientGraphql}/{serviceName}/sdk.ts", placeholders);
|
|
53
|
-
if (serviceSdkPath) {
|
|
54
|
-
mkdirSync(dirname(serviceSdkPath), { recursive: true });
|
|
55
|
-
writeFileSync(serviceSdkPath, types.sdk, "utf-8");
|
|
56
|
-
if (!options.silent) consola.success(`[graphql:${service.name}] Generated SDK at: ${serviceSdkPath}`);
|
|
57
|
-
}
|
|
58
|
-
generateExternalOfetchClient(nitro, service, service.endpoint);
|
|
59
|
-
if (!options.silent) consola.success(`[graphql:${service.name}] External service types generated successfully`);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
consola.error(`[graphql:${service.name}] External service generation failed:`, error);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Generate ofetch client for external service
|
|
66
|
-
*/
|
|
67
|
-
function generateExternalOfetchClient(nitro, service, endpoint) {
|
|
68
|
-
if (!shouldGenerateClientUtils(nitro)) return;
|
|
69
|
-
const serviceName = service.name;
|
|
70
|
-
const placeholders = {
|
|
71
|
-
...getDefaultPaths(nitro),
|
|
72
|
-
serviceName
|
|
73
|
-
};
|
|
74
|
-
const clientUtilsConfig = getClientUtilsConfig(nitro);
|
|
75
|
-
const ofetchPath = resolveFilePath(service.paths?.ofetch ?? clientUtilsConfig.ofetch, clientUtilsConfig.enabled, true, "{clientGraphql}/{serviceName}/ofetch.ts", placeholders);
|
|
76
|
-
if (!ofetchPath) return;
|
|
77
|
-
const serviceDir = dirname(ofetchPath);
|
|
78
|
-
if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
|
|
79
|
-
if (!existsSync(ofetchPath)) writeFileIfNotExists(ofetchPath, generateOfetchTemplate({
|
|
80
|
-
serviceName,
|
|
81
|
-
isNuxt: nitro.options.framework?.name === "nuxt",
|
|
82
|
-
endpoint,
|
|
83
|
-
isExternal: true
|
|
84
|
-
}), `${serviceName} external ofetch.ts`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
export { generateExternalServicesTypes };
|
package/dist/codegen/index.d.mts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { generateMainClientTypes } from "./client-types.mjs";
|
|
2
|
-
import { generateExternalServicesTypes } from "./external-types.mjs";
|
|
3
|
-
import { generateServerTypes } from "./server-types.mjs";
|
|
4
|
-
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
5
|
-
import { Nitro } from "nitro/types";
|
|
6
|
-
|
|
7
|
-
//#region src/codegen/index.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Generate client-side GraphQL types
|
|
11
|
-
* Generates types for both main service and external services
|
|
12
|
-
*/
|
|
13
|
-
declare function generateClientTypes(nitro: Nitro, options?: {
|
|
14
|
-
silent?: boolean;
|
|
15
|
-
isInitial?: boolean;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { generateClientTypes };
|
package/dist/codegen/index.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { LOG_TAG } from "../constants.mjs";
|
|
2
|
-
import { generateMainClientTypes } from "./client-types.mjs";
|
|
3
|
-
import { generateExternalServicesTypes } from "./external-types.mjs";
|
|
4
|
-
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
5
|
-
import { generateServerTypes } from "./server-types.mjs";
|
|
6
|
-
import consola from "consola";
|
|
7
|
-
|
|
8
|
-
//#region src/codegen/index.ts
|
|
9
|
-
const logger = consola.withTag(LOG_TAG);
|
|
10
|
-
/**
|
|
11
|
-
* Generate client-side GraphQL types
|
|
12
|
-
* Generates types for both main service and external services
|
|
13
|
-
*/
|
|
14
|
-
async function generateClientTypes(nitro, options = {}) {
|
|
15
|
-
try {
|
|
16
|
-
if (nitro.scanSchemas && nitro.scanSchemas.length > 0) await generateMainClientTypes(nitro, options);
|
|
17
|
-
if (nitro.options.graphql?.externalServices?.length) await generateExternalServicesTypes(nitro, options);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
logger.error("Client schema generation error:", error);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { generateClientTypes };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/codegen/server-types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate server-side GraphQL types
|
|
7
|
-
* Creates resolver types from GraphQL schemas
|
|
8
|
-
*/
|
|
9
|
-
declare function generateServerTypes(nitro: Nitro, options?: {
|
|
10
|
-
silent?: boolean;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { generateServerTypes };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { LOG_TAG } from "../constants.mjs";
|
|
2
|
-
import { loadFederationSupport } from "../utils/federation.mjs";
|
|
3
|
-
import { getDefaultPaths, getTypesConfig, resolveFilePath, shouldGenerateTypes } from "../utils/path-resolver.mjs";
|
|
4
|
-
import { generateTypes } from "../utils/server-codegen.mjs";
|
|
5
|
-
import { validateNoDuplicateTypes } from "./validation.mjs";
|
|
6
|
-
import consola from "consola";
|
|
7
|
-
import { dirname, resolve } from "pathe";
|
|
8
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { buildSchema, parse } from "graphql";
|
|
10
|
-
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
11
|
-
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
12
|
-
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
13
|
-
|
|
14
|
-
//#region src/codegen/server-types.ts
|
|
15
|
-
const logger = consola.withTag(LOG_TAG);
|
|
16
|
-
/**
|
|
17
|
-
* Generate server-side GraphQL types
|
|
18
|
-
* Creates resolver types from GraphQL schemas
|
|
19
|
-
*/
|
|
20
|
-
async function generateServerTypes(nitro, options = {}) {
|
|
21
|
-
try {
|
|
22
|
-
if (!shouldGenerateTypes(nitro)) {
|
|
23
|
-
logger.debug("Server type generation is disabled");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const schemas = nitro.scanSchemas || [];
|
|
27
|
-
if (!schemas.length) {
|
|
28
|
-
if (!options.silent) consola.info("No GraphQL definitions found for server type generation.");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const schemaStrings = loadFilesSync(schemas).map((schema$1) => typeof schema$1 === "string" ? schema$1 : schema$1.loc?.source?.body || "").filter(Boolean);
|
|
32
|
-
if (!validateNoDuplicateTypes(schemas, schemaStrings)) return;
|
|
33
|
-
const federationEnabled = nitro.options.graphql?.federation?.enabled === true;
|
|
34
|
-
const mergedSchemas = mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
35
|
-
throwOnConflict: true,
|
|
36
|
-
commentDescriptions: true,
|
|
37
|
-
sort: true
|
|
38
|
-
});
|
|
39
|
-
let schema;
|
|
40
|
-
if (federationEnabled) {
|
|
41
|
-
const buildSubgraph = await loadFederationSupport();
|
|
42
|
-
if (!buildSubgraph) throw new Error("Federation is enabled but @apollo/subgraph is not installed. Run: pnpm add @apollo/subgraph");
|
|
43
|
-
schema = buildSubgraph([{ typeDefs: parse(mergedSchemas) }]);
|
|
44
|
-
} else schema = buildSchema(mergedSchemas);
|
|
45
|
-
const data = await generateTypes(nitro.options.graphql?.framework || "graphql-yoga", schema, nitro.options.graphql ?? {});
|
|
46
|
-
const printSchema = printSchemaWithDirectives(schema);
|
|
47
|
-
const schemaPath = resolve(nitro.graphql.buildDir, "schema.graphql");
|
|
48
|
-
mkdirSync(dirname(schemaPath), { recursive: true });
|
|
49
|
-
writeFileSync(schemaPath, printSchema, "utf-8");
|
|
50
|
-
const placeholders = getDefaultPaths(nitro);
|
|
51
|
-
const typesConfig = getTypesConfig(nitro);
|
|
52
|
-
const serverTypesPath = resolveFilePath(typesConfig.server, typesConfig.enabled, true, "{typesDir}/nitro-graphql-server.d.ts", placeholders);
|
|
53
|
-
if (serverTypesPath) {
|
|
54
|
-
mkdirSync(dirname(serverTypesPath), { recursive: true });
|
|
55
|
-
writeFileSync(serverTypesPath, data, "utf-8");
|
|
56
|
-
if (!options.silent) logger.success(`Generated server types at: ${serverTypesPath}`);
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
logger.error("Server schema generation error:", error);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { generateServerTypes };
|
package/dist/config/defaults.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_CLIENT_TYPES_PATH, DEFAULT_SERVER_TYPES_PATH, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH } from "../constants.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/config/defaults.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 TypeScript strict mode setting
|
|
24
|
-
*/
|
|
25
|
-
const DEFAULT_TYPESCRIPT_STRICT = true;
|
|
26
|
-
/**
|
|
27
|
-
* Default watcher persistence setting
|
|
28
|
-
*/
|
|
29
|
-
const DEFAULT_WATCHER_PERSISTENT = true;
|
|
30
|
-
/**
|
|
31
|
-
* Default watcher ignore initial setting
|
|
32
|
-
*/
|
|
33
|
-
const DEFAULT_WATCHER_IGNORE_INITIAL = true;
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { DEFAULT_RUNTIME_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG, DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT };
|