nitro-graphql 2.0.0-beta.70 → 2.0.0-beta.73
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 +1 -1
- package/dist/cli/adapter.d.mts +0 -3
- package/dist/cli/adapter.mjs +7 -32
- package/dist/cli/commands/build.d.mts +2 -2
- package/dist/cli/commands/build.mjs +1 -3
- package/dist/cli/commands/dev.d.mts +2 -2
- package/dist/cli/commands/dev.mjs +1 -3
- package/dist/cli/commands/generate.mjs +10 -10
- package/dist/cli/commands/init.mjs +4 -4
- package/dist/cli/commands/validate.mjs +1 -3
- package/dist/cli/completions.mjs +1 -3
- package/dist/cli/config.d.mts +4 -5
- package/dist/cli/config.mjs +4 -3
- package/dist/cli/index.d.mts +3 -6
- package/dist/cli/index.mjs +2 -4
- package/dist/cli/server/debug-handler.mjs +2 -5
- package/dist/cli/server/dev-server.mjs +1 -3
- package/dist/cli/server/graphql-handler.mjs +3 -4
- package/dist/cli/server/health-handler.mjs +1 -2
- package/dist/cli/server/loader.mjs +1 -3
- package/dist/cli/server/sandbox-handler.mjs +1 -3
- package/dist/cli/server/watcher.mjs +2 -4
- package/dist/cli/server/ws-handler.mjs +1 -3
- package/dist/config.mjs +1 -2
- package/dist/core/codegen/client.d.mts +4 -27
- package/dist/core/codegen/client.mjs +26 -447
- package/dist/core/codegen/document-loader.mjs +1 -3
- package/dist/core/codegen/file-header.d.mts +7 -0
- package/dist/core/codegen/file-header.mjs +12 -0
- package/dist/core/codegen/index.d.mts +7 -5
- package/dist/core/codegen/index.mjs +7 -6
- package/dist/core/codegen/{runtime.d.mts → runtime-generator.d.mts} +1 -3
- package/dist/core/codegen/{runtime.mjs → runtime-generator.mjs} +7 -6
- package/dist/core/codegen/schema-loader.d.mts +2 -7
- package/dist/core/codegen/schema-loader.mjs +66 -73
- package/dist/core/codegen/server-type-helpers.d.mts +14 -0
- package/dist/core/codegen/server-type-helpers.mjs +76 -0
- package/dist/core/codegen/server.d.mts +1 -15
- package/dist/core/codegen/server.mjs +15 -107
- package/dist/core/codegen/subscription-extractor.d.mts +20 -0
- package/dist/core/codegen/subscription-extractor.mjs +30 -0
- package/dist/core/codegen/validation.mjs +1 -3
- package/dist/core/codegen/vue-subscription-builder.d.mts +10 -0
- package/dist/core/codegen/vue-subscription-builder.mjs +351 -0
- package/dist/core/constants.d.mts +5 -53
- package/dist/core/constants.mjs +13 -56
- package/dist/core/create-config.d.mts +31 -0
- package/dist/core/create-config.mjs +42 -0
- package/dist/core/debug/index.d.mts +2 -2
- package/dist/core/debug/index.mjs +2 -3
- package/dist/core/debug/template.d.mts +1 -5
- package/dist/core/debug/template.mjs +5 -4
- package/dist/core/extend/index.mjs +1 -2
- package/dist/core/extend/loader.d.mts +0 -1
- package/dist/core/extend/loader.mjs +60 -92
- package/dist/core/index.d.mts +22 -21
- package/dist/core/index.mjs +19 -16
- package/dist/core/manifest.mjs +4 -4
- package/dist/core/pubsub/index.d.mts +2 -109
- package/dist/core/pubsub/index.mjs +2 -148
- package/dist/core/pubsub/memory-pubsub.d.mts +109 -0
- package/dist/core/pubsub/memory-pubsub.mjs +146 -0
- package/dist/core/scanning/ast-scanner.mjs +5 -5
- package/dist/core/scanning/directives.mjs +3 -5
- package/dist/core/scanning/documents.d.mts +4 -3
- package/dist/core/scanning/documents.mjs +4 -5
- package/dist/core/scanning/{common.d.mts → file-scanner.d.mts} +1 -1
- package/dist/core/scanning/{common.mjs → file-scanner.mjs} +3 -13
- package/dist/core/scanning/index.d.mts +3 -3
- package/dist/core/scanning/index.mjs +3 -4
- package/dist/core/scanning/resolvers.mjs +9 -11
- package/dist/core/scanning/schemas.d.mts +1 -5
- package/dist/core/scanning/schemas.mjs +2 -26
- package/dist/core/schema/builder.d.mts +4 -2
- package/dist/core/schema/builder.mjs +4 -4
- package/dist/core/schema/federation.mjs +1 -3
- package/dist/core/schema/index.d.mts +2 -2
- package/dist/core/schema/index.mjs +2 -3
- package/dist/core/server/apollo.d.mts +20 -0
- package/dist/core/server/apollo.mjs +54 -0
- package/dist/core/server/index.d.mts +4 -2
- package/dist/core/server/index.mjs +3 -3
- package/dist/core/server/sandbox.mjs +1 -2
- package/dist/core/server/types.d.mts +7 -14
- package/dist/core/server/types.mjs +15 -1
- package/dist/core/server/yoga.d.mts +1 -7
- package/dist/core/server/yoga.mjs +4 -15
- package/dist/core/types/adapter.d.mts +3 -40
- package/dist/core/types/adapter.mjs +1 -1
- package/dist/core/types/codegen.d.mts +22 -45
- package/dist/core/types/codegen.mjs +1 -1
- package/dist/core/types/config.d.mts +33 -121
- package/dist/core/types/config.mjs +1 -1
- package/dist/core/types/define.d.mts +8 -5
- package/dist/core/types/define.mjs +1 -1
- package/dist/core/types/index.d.mts +5 -4
- package/dist/core/types/index.mjs +1 -1
- package/dist/core/types/scanning.d.mts +4 -1
- package/dist/core/types/scanning.mjs +1 -1
- package/dist/core/types/standard-schema.d.mts +64 -0
- package/dist/core/types/standard-schema.mjs +1 -0
- package/dist/core/utils/directive-parser.d.mts +8 -63
- package/dist/core/utils/directive-parser.mjs +114 -167
- package/dist/core/utils/errors.mjs +1 -3
- package/dist/core/utils/file-io.d.mts +1 -5
- package/dist/core/utils/file-io.mjs +1 -13
- package/dist/core/utils/imports.mjs +3 -4
- package/dist/core/utils/index.d.mts +5 -4
- package/dist/core/utils/index.mjs +6 -6
- package/dist/core/utils/logger.d.mts +1 -10
- package/dist/core/utils/logger.mjs +1 -21
- package/dist/core/utils/ofetch-templates.mjs +4 -6
- package/dist/core/utils/runtime.d.mts +1 -30
- package/dist/core/utils/runtime.mjs +2 -46
- package/dist/core/utils/string.d.mts +10 -0
- package/dist/core/utils/string.mjs +12 -0
- package/dist/core/utils/subscribe-templates.mjs +1 -2
- package/dist/core/validation/external-services.mjs +3 -3
- package/dist/core/validation/index.mjs +1 -2
- package/dist/core/watcher/create-watcher.d.mts +103 -0
- package/dist/core/watcher/create-watcher.mjs +143 -0
- package/dist/core/watcher/index.d.mts +2 -107
- package/dist/core/watcher/index.mjs +2 -141
- package/dist/define.d.mts +4 -2
- package/dist/define.mjs +8 -9
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -4
- package/dist/nitro/adapter.d.mts +6 -11
- package/dist/nitro/adapter.mjs +12 -45
- package/dist/nitro/apollo.mjs +1 -3
- package/dist/nitro/codegen/client-types.d.mts +12 -0
- package/dist/nitro/codegen/client-types.mjs +73 -0
- package/dist/nitro/codegen/external-types.d.mts +8 -0
- package/dist/nitro/codegen/external-types.mjs +47 -0
- package/dist/nitro/codegen/index.d.mts +4 -0
- package/dist/nitro/codegen/index.mjs +4 -0
- package/dist/nitro/codegen/server-types.d.mts +12 -0
- package/dist/nitro/codegen/server-types.mjs +81 -0
- package/dist/nitro/defaults.d.mts +28 -0
- package/dist/nitro/defaults.mjs +34 -0
- package/dist/nitro/index.d.mts +11 -3
- package/dist/nitro/index.mjs +4 -6
- package/dist/nitro/paths.d.mts +3 -2
- package/dist/nitro/paths.mjs +14 -5
- package/dist/nitro/rollup.mjs +8 -8
- package/dist/nitro/routes/_ws-handler.d.mts +6 -0
- package/dist/nitro/routes/_ws-handler.mjs +49 -0
- package/dist/nitro/routes/apollo-sandbox-script.d.mts +2 -2
- package/dist/nitro/routes/apollo-sandbox-script.mjs +1 -3
- package/dist/nitro/routes/apollo-server-ws.d.mts +1 -1
- package/dist/nitro/routes/apollo-server-ws.mjs +10 -48
- package/dist/nitro/routes/apollo-server.d.mts +2 -2
- package/dist/nitro/routes/apollo-server.mjs +17 -58
- package/dist/nitro/routes/debug.d.mts +2 -2
- package/dist/nitro/routes/debug.mjs +4 -7
- package/dist/nitro/routes/graphql-yoga-ws.d.mts +3 -3
- package/dist/nitro/routes/graphql-yoga-ws.mjs +7 -48
- package/dist/nitro/routes/graphql-yoga.d.mts +2 -2
- package/dist/nitro/routes/graphql-yoga.mjs +8 -8
- package/dist/nitro/routes/health.d.mts +2 -2
- package/dist/nitro/routes/health.mjs +23 -27
- package/dist/nitro/setup/extend-loader.d.mts +6 -5
- package/dist/nitro/setup/extend-loader.mjs +31 -61
- package/dist/nitro/setup/file-watcher.mjs +9 -8
- package/dist/nitro/setup/logging.d.mts +1 -8
- package/dist/nitro/setup/logging.mjs +7 -24
- package/dist/nitro/setup/rollup-integration.mjs +36 -4
- package/dist/nitro/setup/routes.mjs +1 -3
- package/dist/nitro/setup/scanner.d.mts +8 -43
- package/dist/nitro/setup/scanner.mjs +56 -60
- package/dist/nitro/setup/security.d.mts +10 -0
- package/dist/nitro/setup/security.mjs +17 -0
- package/dist/nitro/setup/ts-config.mjs +1 -3
- package/dist/nitro/setup/type-generation.d.mts +13 -0
- package/dist/nitro/setup/type-generation.mjs +16 -0
- package/dist/nitro/setup.d.mts +4 -3
- package/dist/nitro/setup.mjs +88 -77
- package/dist/nitro/state.d.mts +32 -0
- package/dist/nitro/state.mjs +58 -0
- package/dist/nitro/types/augmentation.d.mts +59 -0
- package/dist/nitro/types/augmentation.mjs +1 -0
- package/dist/nitro/types/config.d.mts +327 -0
- package/dist/nitro/types/config.mjs +1 -0
- package/dist/nitro/types/define.d.mts +13 -0
- package/dist/nitro/types/define.mjs +1 -0
- package/dist/nitro/types/index.d.mts +10 -0
- package/dist/nitro/types/index.mjs +1 -0
- package/dist/nitro/virtual/debug-info.d.mts +9 -0
- package/dist/nitro/virtual/debug-info.mjs +35 -0
- package/dist/nitro/virtual/graphql-config.d.mts +9 -0
- package/dist/nitro/virtual/graphql-config.mjs +33 -0
- package/dist/nitro/virtual/index.d.mts +25 -0
- package/dist/nitro/virtual/index.mjs +45 -0
- package/dist/nitro/virtual/module-config.d.mts +9 -0
- package/dist/nitro/virtual/module-config.mjs +10 -0
- package/dist/nitro/virtual/pubsub.d.mts +9 -0
- package/dist/nitro/virtual/pubsub.mjs +17 -0
- package/dist/nitro/virtual/server-directives.d.mts +9 -0
- package/dist/nitro/virtual/server-directives.mjs +12 -0
- package/dist/nitro/virtual/server-resolvers.d.mts +9 -0
- package/dist/nitro/virtual/server-resolvers.mjs +17 -0
- package/dist/nitro/virtual/server-schemas.d.mts +9 -0
- package/dist/nitro/virtual/server-schemas.mjs +31 -0
- package/dist/nitro/virtual/stubs.d.mts +42 -10
- package/dist/nitro/virtual/stubs.mjs +1 -7
- package/dist/nitro/virtual/utils.d.mts +15 -0
- package/dist/nitro/virtual/utils.mjs +26 -0
- package/dist/nitro/virtual/validation-schemas.d.mts +9 -0
- package/dist/nitro/virtual/validation-schemas.mjs +33 -0
- package/dist/nuxt.mjs +4 -5
- package/dist/stubs/index.mjs +1 -1
- package/dist/subscribe/index.mjs +3 -4
- package/native/index.js +52 -52
- package/package.json +41 -41
- package/dist/cli/commands/index.d.mts +0 -5
- package/dist/cli/commands/index.mjs +0 -6
- package/dist/core/codegen/plugin.d.mts +0 -19
- package/dist/core/codegen/plugin.mjs +0 -30
- package/dist/core/config.d.mts +0 -45
- package/dist/core/config.mjs +0 -78
- package/dist/nitro/codegen.d.mts +0 -18
- package/dist/nitro/codegen.mjs +0 -173
- package/dist/nitro/config.d.mts +0 -50
- package/dist/nitro/config.mjs +0 -57
- package/dist/nitro/types.d.mts +0 -549
- package/dist/nitro/types.mjs +0 -1
- package/dist/nitro/virtual/generators.d.mts +0 -38
- package/dist/nitro/virtual/generators.mjs +0 -192
package/README.md
CHANGED
|
@@ -82,5 +82,5 @@ See the [documentation](https://nitro-graphql.pages.dev) for Nuxt and Vite setup
|
|
|
82
82
|
[docs-href]: https://nitro-graphql.pages.dev
|
|
83
83
|
[beta-src]: https://img.shields.io/npm/v/nitro-graphql/beta?style=flat&logo=rocket&logoColor=white&label=beta&color=7c3aed&colorA=080f12
|
|
84
84
|
[beta-href]: https://github.com/productdevbook/nitro-graphql/releases
|
|
85
|
-
[coverage-src]: https://img.shields.io/badge/coverage-
|
|
85
|
+
[coverage-src]: https://img.shields.io/badge/coverage-71%25-green?style=flat&colorA=080f12
|
|
86
86
|
[coverage-href]: https://github.com/productdevbook/nitro-graphql/actions/workflows/ci.yml
|
package/dist/cli/adapter.d.mts
CHANGED
|
@@ -4,9 +4,6 @@ import { CLIContext } from "./index.mjs";
|
|
|
4
4
|
//#region src/cli/adapter.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* CLI Framework Adapter
|
|
7
|
-
*
|
|
8
|
-
* Enables the CLI to use the same core functions as the Nitro module.
|
|
9
|
-
* The adapter converts CLIContext to the types expected by core functions.
|
|
10
7
|
*/
|
|
11
8
|
declare const CLIAdapter: FrameworkAdapter<CLIContext>;
|
|
12
9
|
//#endregion
|
package/dist/cli/adapter.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { LOG_TAG } from "../core/constants.mjs";
|
|
2
|
-
import { createCoreConfig,
|
|
2
|
+
import { createCoreConfig, createScanContext } from "../core/create-config.mjs";
|
|
3
3
|
import consola from "consola";
|
|
4
|
-
|
|
5
4
|
//#region src/cli/adapter.ts
|
|
6
|
-
/**
|
|
7
|
-
* Create a CoreLogger from consola for CLI usage
|
|
8
|
-
*/
|
|
9
5
|
function createCLILogger() {
|
|
10
6
|
const logger = consola.withTag(LOG_TAG);
|
|
11
7
|
return {
|
|
@@ -18,9 +14,6 @@ function createCLILogger() {
|
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
16
|
* CLI Framework Adapter
|
|
21
|
-
*
|
|
22
|
-
* Enables the CLI to use the same core functions as the Nitro module.
|
|
23
|
-
* The adapter converts CLIContext to the types expected by core functions.
|
|
24
17
|
*/
|
|
25
18
|
const CLIAdapter = {
|
|
26
19
|
name: "cli",
|
|
@@ -32,31 +25,14 @@ const CLIAdapter = {
|
|
|
32
25
|
clientDir: ctx.config.clientDir,
|
|
33
26
|
isNuxt: false,
|
|
34
27
|
isDev: true,
|
|
35
|
-
graphqlOptions: {
|
|
36
|
-
framework: ctx.config.framework,
|
|
37
|
-
endpoint: ctx.config.endpoint?.graphql,
|
|
38
|
-
security: ctx.config.security,
|
|
39
|
-
federation: ctx.config.federation,
|
|
40
|
-
externalServices: ctx.config.externalServices?.map((s) => ({
|
|
41
|
-
name: s.name,
|
|
42
|
-
endpoint: s.endpoint,
|
|
43
|
-
schema: (Array.isArray(s.schema) ? s.schema[0] : s.schema) || s.endpoint,
|
|
44
|
-
headers: s.headers,
|
|
45
|
-
documents: s.documents,
|
|
46
|
-
paths: s.paths ? {
|
|
47
|
-
sdk: typeof s.paths.sdk === "string" ? s.paths.sdk : void 0,
|
|
48
|
-
types: typeof s.paths.types === "string" ? s.paths.types : void 0
|
|
49
|
-
} : void 0
|
|
50
|
-
})),
|
|
51
|
-
codegen: ctx.config.codegen
|
|
52
|
-
},
|
|
53
28
|
logger: createCLILogger(),
|
|
54
|
-
ignorePatterns: ctx.config.ignore || []
|
|
29
|
+
ignorePatterns: ctx.config.ignore || [],
|
|
30
|
+
security: ctx.config.security,
|
|
31
|
+
federation: ctx.config.federation,
|
|
32
|
+
codegen: ctx.config.codegen,
|
|
33
|
+
externalServices: ctx.config.externalServices
|
|
55
34
|
});
|
|
56
35
|
},
|
|
57
|
-
createCoreContext: (ctx) => {
|
|
58
|
-
return createCoreContext(CLIAdapter.createCoreConfig(ctx));
|
|
59
|
-
},
|
|
60
36
|
createScanContext: (ctx) => {
|
|
61
37
|
return createScanContext(CLIAdapter.createCoreConfig(ctx));
|
|
62
38
|
},
|
|
@@ -64,6 +40,5 @@ const CLIAdapter = {
|
|
|
64
40
|
return createCLILogger();
|
|
65
41
|
}
|
|
66
42
|
};
|
|
67
|
-
|
|
68
43
|
//#endregion
|
|
69
|
-
export { CLIAdapter };
|
|
44
|
+
export { CLIAdapter };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as citty from "citty";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/commands/build.d.ts
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import * as citty0 from "citty";
|
|
|
6
6
|
*
|
|
7
7
|
* Builds GraphQL types and validates schemas for production.
|
|
8
8
|
*/
|
|
9
|
-
declare const buildCommand:
|
|
9
|
+
declare const buildCommand: citty.CommandDef<{
|
|
10
10
|
readonly cwd: {
|
|
11
11
|
readonly type: "string";
|
|
12
12
|
readonly description: "Working directory";
|
|
@@ -3,7 +3,6 @@ import { generateAll } from "./generate.mjs";
|
|
|
3
3
|
import { validate } from "./validate.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/build.ts
|
|
8
7
|
/**
|
|
9
8
|
* CLI Build Command
|
|
@@ -47,6 +46,5 @@ const buildCommand = defineCommand({
|
|
|
47
46
|
logger.info(`Output: ${ctx.config.buildDir}`);
|
|
48
47
|
}
|
|
49
48
|
});
|
|
50
|
-
|
|
51
49
|
//#endregion
|
|
52
|
-
export { buildCommand };
|
|
50
|
+
export { buildCommand };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as citty from "citty";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/commands/dev.d.ts
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import * as citty0 from "citty";
|
|
|
7
7
|
* Starts the GraphQL development server with hot reload.
|
|
8
8
|
* Runtime-agnostic: works on Node.js, Bun, and Deno.
|
|
9
9
|
*/
|
|
10
|
-
declare const devCommand:
|
|
10
|
+
declare const devCommand: citty.CommandDef<{
|
|
11
11
|
readonly cwd: {
|
|
12
12
|
readonly type: "string";
|
|
13
13
|
readonly description: "Working directory";
|
|
@@ -4,7 +4,6 @@ import { startDevServer } from "../server/dev-server.mjs";
|
|
|
4
4
|
import { createDevWatcher } from "../server/watcher.mjs";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
|
-
|
|
8
7
|
//#region src/cli/commands/dev.ts
|
|
9
8
|
/**
|
|
10
9
|
* Dev Command
|
|
@@ -71,6 +70,5 @@ const devCommand = defineCommand({
|
|
|
71
70
|
onSignal("SIGTERM", shutdown);
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
|
-
|
|
75
73
|
//#endregion
|
|
76
|
-
export { devCommand };
|
|
74
|
+
export { devCommand };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
-
import { loadGraphQLDocuments } from "../../core/codegen/document-loader.mjs";
|
|
3
2
|
import { generateClientTypesCore } from "../../core/codegen/client.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { loadGraphQLDocuments } from "../../core/codegen/document-loader.mjs";
|
|
4
|
+
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "../../core/codegen/runtime-generator.mjs";
|
|
5
5
|
import { generateServerTypesCore } from "../../core/codegen/server.mjs";
|
|
6
6
|
import { scanDocumentsCore } from "../../core/scanning/documents.mjs";
|
|
7
7
|
import { scanResolversCore } from "../../core/scanning/resolvers.mjs";
|
|
@@ -9,10 +9,11 @@ import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
|
9
9
|
import { buildGraphQLSchema } from "../../core/schema/builder.mjs";
|
|
10
10
|
import { existsSync_, mkdirSync_, onSignal, readFileSync_, writeFileSync_ } from "../../core/utils/runtime.mjs";
|
|
11
11
|
import consola from "consola";
|
|
12
|
-
import { dirname, join, relative, resolve
|
|
13
|
-
|
|
12
|
+
import { dirname, join, relative, resolve } from "pathe";
|
|
14
13
|
//#region src/cli/commands/generate.ts
|
|
15
14
|
const logger = consola.withTag(LOG_TAG);
|
|
15
|
+
const NODE_MODULES_RE = /node_modules/;
|
|
16
|
+
const DOT_GIT_RE = /\.git/;
|
|
16
17
|
/**
|
|
17
18
|
* Create ScanContext from CLI context
|
|
18
19
|
*/
|
|
@@ -67,7 +68,7 @@ async function generateServer(ctx, options = {}) {
|
|
|
67
68
|
writeFileSync_(schemaPath, result.schemaString);
|
|
68
69
|
const typesConfig = ctx.config.types;
|
|
69
70
|
let typesPath;
|
|
70
|
-
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.server === "string") typesPath = resolve
|
|
71
|
+
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.server === "string") typesPath = resolve(ctx.config.rootDir, typesConfig.server);
|
|
71
72
|
else typesPath = join(ctx.config.typesDir, "nitro-graphql-server.d.ts");
|
|
72
73
|
mkdirSync_(dirname(typesPath));
|
|
73
74
|
writeFileSync_(typesPath, result.types);
|
|
@@ -104,7 +105,7 @@ async function generateClient(ctx, options = {}) {
|
|
|
104
105
|
}
|
|
105
106
|
const typesConfig = ctx.config.types;
|
|
106
107
|
let typesPath;
|
|
107
|
-
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.client === "string") typesPath = resolve
|
|
108
|
+
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.client === "string") typesPath = resolve(ctx.config.rootDir, typesConfig.client);
|
|
108
109
|
else typesPath = join(ctx.config.typesDir, "nitro-graphql-client.d.ts");
|
|
109
110
|
mkdirSync_(dirname(typesPath));
|
|
110
111
|
writeFileSync_(typesPath, result.types);
|
|
@@ -158,8 +159,8 @@ async function watchAndRegenerate(ctx, options = {}) {
|
|
|
158
159
|
ignoreInitial: true,
|
|
159
160
|
ignored: [
|
|
160
161
|
...ctx.config.ignore || [],
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
NODE_MODULES_RE,
|
|
163
|
+
DOT_GIT_RE
|
|
163
164
|
],
|
|
164
165
|
persistent: true
|
|
165
166
|
});
|
|
@@ -193,6 +194,5 @@ async function watchAndRegenerate(ctx, options = {}) {
|
|
|
193
194
|
});
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
|
-
|
|
197
197
|
//#endregion
|
|
198
|
-
export { generateAll, generateClient, generateServer };
|
|
198
|
+
export { generateAll, generateClient, generateServer };
|
|
@@ -3,9 +3,10 @@ import consola from "consola";
|
|
|
3
3
|
import { basename, join, relative, resolve } from "pathe";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { downloadTemplate } from "giget";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/init.ts
|
|
8
7
|
const logger = consola.withTag(LOG_TAG);
|
|
8
|
+
const NON_ALPHANUMERIC_HYPHEN_RE = /[^a-z0-9-]/gi;
|
|
9
|
+
const LEADING_TRAILING_HYPHENS_RE = /^-+|-+$/g;
|
|
9
10
|
/**
|
|
10
11
|
* Available templates from the examples directory
|
|
11
12
|
*/
|
|
@@ -83,7 +84,7 @@ async function initFromTemplate(projectName, templateName, options = {}) {
|
|
|
83
84
|
const packageJsonPath = join(targetDir, "package.json");
|
|
84
85
|
if (existsSync(packageJsonPath)) try {
|
|
85
86
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
86
|
-
packageJson.name = basename(projectName).replace(
|
|
87
|
+
packageJson.name = basename(projectName).replace(NON_ALPHANUMERIC_HYPHEN_RE, "-").replace(LEADING_TRAILING_HYPHENS_RE, "").toLowerCase() || "my-graphql-app";
|
|
87
88
|
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
88
89
|
logger.debug(`Updated package.json name to: ${packageJson.name}`);
|
|
89
90
|
} catch {
|
|
@@ -190,6 +191,5 @@ export const helloQueries = defineQuery({
|
|
|
190
191
|
logger.info(" 2. Add more schemas to your server directory");
|
|
191
192
|
logger.info(" 3. Add more queries/mutations to your client directory");
|
|
192
193
|
}
|
|
193
|
-
|
|
194
194
|
//#endregion
|
|
195
|
-
export { AVAILABLE_TEMPLATES, init, initFromTemplate, listTemplates };
|
|
195
|
+
export { AVAILABLE_TEMPLATES, init, initFromTemplate, listTemplates };
|
|
@@ -3,7 +3,6 @@ import { validateNoDuplicateTypes } from "../../core/codegen/validation.mjs";
|
|
|
3
3
|
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/validate.ts
|
|
8
7
|
const logger = consola.withTag(LOG_TAG);
|
|
9
8
|
/**
|
|
@@ -62,6 +61,5 @@ async function validate(ctx) {
|
|
|
62
61
|
return false;
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
//#endregion
|
|
67
|
-
export { validate };
|
|
65
|
+
export { validate };
|
package/dist/cli/completions.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AVAILABLE_TEMPLATES } from "./commands/init.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/cli/completions.ts
|
|
4
3
|
async function initCompletions(command) {
|
|
5
4
|
const { default: tab } = await import("@bomb.sh/tab/citty");
|
|
@@ -29,6 +28,5 @@ async function initCompletions(command) {
|
|
|
29
28
|
} } }
|
|
30
29
|
} });
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
//#endregion
|
|
34
|
-
export { initCompletions };
|
|
32
|
+
export { initCompletions };
|
package/dist/cli/config.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CLIGraphQLOptions } from "../nitro/types/config.mjs";
|
|
3
2
|
//#region src/cli/config.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* CLI configuration options
|
|
6
|
-
*
|
|
5
|
+
* Extends NitroGraphQLOptions with CLI-specific fields (rootDir, buildDir, etc.)
|
|
7
6
|
*/
|
|
8
|
-
type CLIConfig =
|
|
7
|
+
type CLIConfig = CLIGraphQLOptions;
|
|
9
8
|
/**
|
|
10
9
|
* Define CLI configuration with type safety
|
|
11
10
|
*/
|
|
12
|
-
declare function defineConfig(config: CLIConfig): CLIConfig
|
|
11
|
+
declare function defineConfig(config: Partial<CLIConfig>): Partial<CLIConfig>;
|
|
13
12
|
/**
|
|
14
13
|
* Default CLI configuration values
|
|
15
14
|
*/
|
package/dist/cli/config.mjs
CHANGED
|
@@ -10,11 +10,12 @@ function defineConfig(config) {
|
|
|
10
10
|
*/
|
|
11
11
|
const DEFAULT_CLI_CONFIG = {
|
|
12
12
|
framework: "graphql-yoga",
|
|
13
|
+
rootDir: ".",
|
|
14
|
+
buildDir: ".graphql",
|
|
13
15
|
serverDir: "server/graphql",
|
|
14
16
|
clientDir: "graphql",
|
|
15
|
-
|
|
17
|
+
typesDir: ".graphql/types",
|
|
16
18
|
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
17
19
|
};
|
|
18
|
-
|
|
19
20
|
//#endregion
|
|
20
|
-
export { DEFAULT_CLI_CONFIG, defineConfig };
|
|
21
|
+
export { DEFAULT_CLI_CONFIG, defineConfig };
|
package/dist/cli/index.d.mts
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CLIGraphQLOptions } from "../nitro/types/config.mjs";
|
|
2
2
|
import { CLIConfig, defineConfig } from "./config.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* CLI context with resolved configuration
|
|
7
|
-
* Uses NitroGraphQLOptions directly as CLI and module options are now unified
|
|
8
7
|
*/
|
|
9
8
|
interface CLIContext {
|
|
10
|
-
config:
|
|
11
|
-
ignore: string[];
|
|
12
|
-
} & NitroGraphQLOptions;
|
|
9
|
+
config: CLIGraphQLOptions;
|
|
13
10
|
cwd: string;
|
|
14
11
|
}
|
|
15
12
|
/**
|
|
16
13
|
* Load CLI configuration from file or defaults
|
|
17
14
|
*/
|
|
18
|
-
declare function loadConfig(cwd?: string): Promise<
|
|
15
|
+
declare function loadConfig(cwd?: string): Promise<Partial<CLIGraphQLOptions>>;
|
|
19
16
|
/**
|
|
20
17
|
* Create CLI context from configuration
|
|
21
18
|
*/
|
package/dist/cli/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { existsSync_, exit, getCwd } from "../core/utils/runtime.mjs";
|
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { resolve } from "pathe";
|
|
7
7
|
import { defineCommand, runMain } from "citty";
|
|
8
|
-
|
|
9
8
|
//#region src/cli/index.ts
|
|
10
9
|
const logger = consola.withTag(LOG_TAG);
|
|
11
10
|
/**
|
|
@@ -41,7 +40,7 @@ async function createCLIContext(options = {}) {
|
|
|
41
40
|
const cwd = options.cwd || getCwd();
|
|
42
41
|
const config = await loadConfig(cwd);
|
|
43
42
|
const rootDir = config.rootDir ? resolve(cwd, config.rootDir) : cwd;
|
|
44
|
-
const buildDir = config.buildDir ? resolve(rootDir, config.buildDir) : resolve(rootDir, ".
|
|
43
|
+
const buildDir = config.buildDir ? resolve(rootDir, config.buildDir) : resolve(rootDir, ".graphql");
|
|
45
44
|
const serverDir = config.serverDir ? resolve(rootDir, config.serverDir) : resolve(rootDir, "server/graphql");
|
|
46
45
|
const clientDir = config.clientDir ? resolve(rootDir, config.clientDir) : resolve(rootDir, "graphql");
|
|
47
46
|
const typesDir = config.typesDir ? resolve(rootDir, config.typesDir) : resolve(buildDir, "types");
|
|
@@ -312,6 +311,5 @@ async function run() {
|
|
|
312
311
|
return runMain(main);
|
|
313
312
|
}
|
|
314
313
|
run();
|
|
315
|
-
|
|
316
314
|
//#endregion
|
|
317
|
-
export { createCLIContext, defineConfig, loadConfig };
|
|
315
|
+
export { createCLIContext, defineConfig, loadConfig };
|
|
@@ -4,7 +4,6 @@ import { scanResolversCore } from "../../core/scanning/resolvers.mjs";
|
|
|
4
4
|
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
5
5
|
import { CLIAdapter } from "../adapter.mjs";
|
|
6
6
|
import { generateDebugHtml } from "../../core/debug/template.mjs";
|
|
7
|
-
|
|
8
7
|
//#region src/cli/server/debug-handler.ts
|
|
9
8
|
/**
|
|
10
9
|
* Create a debug handler for the CLI dev server
|
|
@@ -28,9 +27,8 @@ async function collectDebugInfo(ctx) {
|
|
|
28
27
|
scanDocumentsCore(scanCtx, { externalServices: ctx.config.externalServices })
|
|
29
28
|
]);
|
|
30
29
|
const resolverFiles = resolversResult.items.map((r) => {
|
|
31
|
-
const parts = r.specifier.split("/");
|
|
32
30
|
return {
|
|
33
|
-
file:
|
|
31
|
+
file: r.specifier.split("/").at(-1) || r.specifier,
|
|
34
32
|
exports: r.imports.map((i) => ({
|
|
35
33
|
name: i.name,
|
|
36
34
|
type: i.type
|
|
@@ -66,6 +64,5 @@ async function collectDebugInfo(ctx) {
|
|
|
66
64
|
virtualModules: { "cli-config": JSON.stringify(ctx.config, null, 2) }
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
|
-
|
|
70
67
|
//#endregion
|
|
71
|
-
export { createDebugHandler };
|
|
68
|
+
export { createDebugHandler };
|
|
@@ -6,7 +6,6 @@ import { createWebSocketPlugin } from "./ws-handler.mjs";
|
|
|
6
6
|
import consola from "consola";
|
|
7
7
|
import { plugin } from "crossws/server";
|
|
8
8
|
import { serve } from "srvx";
|
|
9
|
-
|
|
10
9
|
//#region src/cli/server/dev-server.ts
|
|
11
10
|
const logger = consola.withTag("nitro-graphql");
|
|
12
11
|
/**
|
|
@@ -59,6 +58,5 @@ async function startDevServer(ctx, options = {}) {
|
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
|
-
|
|
63
61
|
//#endregion
|
|
64
|
-
export { startDevServer };
|
|
62
|
+
export { startDevServer };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BASE_SCHEMA
|
|
1
|
+
import { BASE_SCHEMA } from "../../core/schema/builder.mjs";
|
|
2
|
+
import { createYogaServer } from "../../core/server/yoga.mjs";
|
|
2
3
|
import { loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions } from "./loader.mjs";
|
|
3
4
|
import consola from "consola";
|
|
4
|
-
|
|
5
5
|
//#region src/cli/server/graphql-handler.ts
|
|
6
6
|
const logger = consola.withTag("nitro-graphql");
|
|
7
7
|
let serverInstance = null;
|
|
@@ -40,6 +40,5 @@ async function reloadGraphQLHandler(ctx) {
|
|
|
40
40
|
function getServerInstance() {
|
|
41
41
|
return serverInstance;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
43
|
//#endregion
|
|
45
|
-
export { createGraphQLHandler, getServerInstance, reloadGraphQLHandler };
|
|
44
|
+
export { createGraphQLHandler, getServerInstance, reloadGraphQLHandler };
|
|
@@ -5,7 +5,6 @@ import { pathToFileURL, readFileSync_ } from "../../core/utils/runtime.mjs";
|
|
|
5
5
|
import { scanAllExtendSources } from "../../core/extend/loader.mjs";
|
|
6
6
|
import { CLIAdapter } from "../adapter.mjs";
|
|
7
7
|
import consola from "consola";
|
|
8
|
-
|
|
9
8
|
//#region src/cli/server/loader.ts
|
|
10
9
|
const logger = consola.withTag("nitro-graphql");
|
|
11
10
|
let cachedExtendResult = null;
|
|
@@ -141,6 +140,5 @@ async function loadAllComponents(ctx) {
|
|
|
141
140
|
directives
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
|
-
|
|
145
143
|
//#endregion
|
|
146
|
-
export { clearExtendCache, loadAllComponents, loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions };
|
|
144
|
+
export { clearExtendCache, loadAllComponents, loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSandboxResponse } from "../../core/server/sandbox.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/cli/server/sandbox-handler.ts
|
|
4
3
|
/**
|
|
5
4
|
* CLI Sandbox Script Handler
|
|
@@ -14,6 +13,5 @@ function createSandboxHandler() {
|
|
|
14
13
|
return createSandboxResponse();
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
|
-
export { createSandboxHandler };
|
|
17
|
+
export { createSandboxHandler };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
-
import { closeWatcher, createCoreWatcher } from "../../core/watcher/
|
|
2
|
+
import { closeWatcher, createCoreWatcher } from "../../core/watcher/create-watcher.mjs";
|
|
3
3
|
import { generateAll } from "../commands/generate.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
|
-
|
|
6
5
|
//#region src/cli/server/watcher.ts
|
|
7
6
|
const logger = consola.withTag(LOG_TAG);
|
|
8
7
|
/**
|
|
@@ -61,6 +60,5 @@ function createDevWatcher(ctx, onReload) {
|
|
|
61
60
|
logger.debug("File watcher closed");
|
|
62
61
|
} };
|
|
63
62
|
}
|
|
64
|
-
|
|
65
63
|
//#endregion
|
|
66
|
-
export { createDevWatcher };
|
|
64
|
+
export { createDevWatcher };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { handleProtocols } from "graphql-ws";
|
|
2
2
|
import { makeHooks } from "graphql-ws/use/crossws";
|
|
3
|
-
|
|
4
3
|
//#region src/cli/server/ws-handler.ts
|
|
5
4
|
/**
|
|
6
5
|
* Create WebSocket hooks for GraphQL subscriptions
|
|
@@ -45,6 +44,5 @@ function createGraphQLWebSocketHooks(getSchema, context) {
|
|
|
45
44
|
function createWebSocketPlugin(getSchema, context) {
|
|
46
45
|
return createGraphQLWebSocketHooks(getSchema, context);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
//#endregion
|
|
50
|
-
export { createGraphQLWebSocketHooks, createWebSocketPlugin };
|
|
48
|
+
export { createGraphQLWebSocketHooks, createWebSocketPlugin };
|
package/dist/config.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig } from "../types/codegen.mjs";
|
|
2
|
-
import { loadGraphQLDocuments } from "./document-loader.mjs";
|
|
3
|
-
import { GraphQLLoadSchemaOptions, GraphQLTypeDefPointer, downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./schema-loader.mjs";
|
|
4
2
|
import { Source } from "@graphql-tools/utils";
|
|
5
|
-
import
|
|
3
|
+
import * as graphql from "graphql";
|
|
6
4
|
|
|
7
5
|
//#region src/core/codegen/client.d.ts
|
|
8
6
|
/**
|
|
@@ -11,32 +9,11 @@ import { GraphQLSchema } from "graphql";
|
|
|
11
9
|
declare const DEFAULT_CLIENT_CODEGEN_CONFIG: ClientCodegenConfig;
|
|
12
10
|
/**
|
|
13
11
|
* Generate client-side GraphQL types
|
|
14
|
-
* Pure function that generates TypeScript types from a GraphQL schema and documents
|
|
15
12
|
*/
|
|
16
13
|
declare function generateClientTypesCore(input: ClientCodegenInput): Promise<ClientCodegenResult | false>;
|
|
17
14
|
/**
|
|
18
|
-
* Generate client types for external GraphQL service
|
|
15
|
+
* Generate client types for an external GraphQL service
|
|
19
16
|
*/
|
|
20
|
-
declare function generateExternalClientTypesCore(service: ExternalServiceCodegenConfig, schema: GraphQLSchema, documents: Source[], virtualTypesPath?: string): Promise<ClientCodegenResult | false>;
|
|
21
|
-
/**
|
|
22
|
-
* Subscription info extracted from GraphQL documents
|
|
23
|
-
*/
|
|
24
|
-
interface SubscriptionInfo {
|
|
25
|
-
/** Original operation name from GraphQL document (used for method names) */
|
|
26
|
-
name: string;
|
|
27
|
-
/** PascalCase version for type references (matches GraphQL codegen output) */
|
|
28
|
-
typeName: string;
|
|
29
|
-
fieldName: string;
|
|
30
|
-
hasVariables: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Extract subscription operations from GraphQL documents
|
|
34
|
-
*/
|
|
35
|
-
declare function extractSubscriptions(docs: Source[]): SubscriptionInfo[];
|
|
36
|
-
/**
|
|
37
|
-
* Generate subscription builder code (Drizzle-style API) + Vue Composables
|
|
38
|
-
* Returns empty string if subscriptions are not enabled or no subscription operations found
|
|
39
|
-
*/
|
|
40
|
-
declare function generateSubscriptionBuilder(docs: Source[], subscriptionsEnabled: boolean): string;
|
|
17
|
+
declare function generateExternalClientTypesCore(service: ExternalServiceCodegenConfig, schema: graphql.GraphQLSchema, documents: Source[], virtualTypesPath?: string): Promise<ClientCodegenResult | false>;
|
|
41
18
|
//#endregion
|
|
42
|
-
export { DEFAULT_CLIENT_CODEGEN_CONFIG,
|
|
19
|
+
export { DEFAULT_CLIENT_CODEGEN_CONFIG, generateClientTypesCore, generateExternalClientTypesCore };
|