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
|
@@ -1,37 +1,34 @@
|
|
|
1
|
+
import { createMergedSchema } from "../../core/schema/builder.mjs";
|
|
2
|
+
import { execute, parse } from "graphql";
|
|
1
3
|
import { defineEventHandler } from "nitro/h3";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import { moduleConfig } from "#nitro-graphql/module-config";
|
|
5
|
+
import { directives } from "#nitro-graphql/server-directives";
|
|
6
|
+
import { resolvers } from "#nitro-graphql/server-resolvers";
|
|
7
|
+
import { schemas } from "#nitro-graphql/server-schemas";
|
|
5
8
|
//#region src/nitro/routes/health.ts
|
|
9
|
+
let schema = null;
|
|
10
|
+
async function getSchema() {
|
|
11
|
+
if (!schema) schema = await createMergedSchema({
|
|
12
|
+
schemas,
|
|
13
|
+
resolvers,
|
|
14
|
+
directives,
|
|
15
|
+
moduleConfig
|
|
16
|
+
});
|
|
17
|
+
return schema;
|
|
18
|
+
}
|
|
19
|
+
const HEALTH_QUERY = parse("query Health { __typename }");
|
|
6
20
|
var health_default = defineEventHandler(async (event) => {
|
|
7
|
-
const runtime = useRuntimeConfig();
|
|
8
|
-
if (!runtime.graphql || !runtime.graphql.endpoint?.graphql) {
|
|
9
|
-
event.res.status = 404;
|
|
10
|
-
event.res.statusText = "Not Found";
|
|
11
|
-
return {
|
|
12
|
-
status: "error",
|
|
13
|
-
message: "GraphQL health check endpoint is not configured",
|
|
14
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
21
|
try {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
query: "query Health { __typename }",
|
|
22
|
-
operationName: "Health"
|
|
23
|
-
},
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": "application/json",
|
|
26
|
-
"Accept": "application/json"
|
|
27
|
-
}
|
|
22
|
+
const result = await execute({
|
|
23
|
+
schema: await getSchema(),
|
|
24
|
+
document: HEALTH_QUERY
|
|
28
25
|
});
|
|
29
|
-
if (
|
|
26
|
+
if (result.data) return {
|
|
30
27
|
status: "healthy",
|
|
31
28
|
message: "GraphQL server is running",
|
|
32
29
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
33
30
|
};
|
|
34
|
-
throw new Error("Invalid response from GraphQL server");
|
|
31
|
+
throw new Error(result.errors?.map((e) => e.message).join(", ") || "Invalid response from GraphQL server");
|
|
35
32
|
} catch (error) {
|
|
36
33
|
event.res.status = 503;
|
|
37
34
|
event.res.statusText = "Service Unavailable";
|
|
@@ -42,6 +39,5 @@ var health_default = defineEventHandler(async (event) => {
|
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
|
-
|
|
46
42
|
//#endregion
|
|
47
|
-
export { health_default as default };
|
|
43
|
+
export { health_default as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GraphQLScanState } from "../types/augmentation.mjs";
|
|
1
2
|
import { Nitro } from "nitro/types";
|
|
2
3
|
|
|
3
4
|
//#region src/nitro/setup/extend-loader.d.ts
|
|
@@ -5,12 +6,12 @@ import { Nitro } from "nitro/types";
|
|
|
5
6
|
* Resolve extend directories for file watching
|
|
6
7
|
*/
|
|
7
8
|
declare function resolveExtendDirs(nitro: Nitro): Promise<string[]>;
|
|
8
|
-
interface ResolveExtendOptions {
|
|
9
|
-
silent?: boolean;
|
|
10
|
-
}
|
|
11
9
|
/**
|
|
12
|
-
* Resolve extend configuration and
|
|
10
|
+
* Resolve extend configuration and merge into scan state.
|
|
11
|
+
* Returns a new frozen state — does NOT mutate nitro.
|
|
13
12
|
*/
|
|
14
|
-
declare function resolveExtendConfig(nitro: Nitro, options?:
|
|
13
|
+
declare function resolveExtendConfig(nitro: Nitro, state: GraphQLScanState, options?: {
|
|
14
|
+
silent?: boolean;
|
|
15
|
+
}): Promise<GraphQLScanState>;
|
|
15
16
|
//#endregion
|
|
16
17
|
export { resolveExtendConfig, resolveExtendDirs };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
2
|
import { generateDirectiveSchemas } from "../../core/utils/directive-parser.mjs";
|
|
3
3
|
import { resolveExtendDirs as resolveExtendDirs$1, scanAllExtendSources } from "../../core/extend/loader.mjs";
|
|
4
|
+
import { mergeScanState } from "../state.mjs";
|
|
4
5
|
import consola from "consola";
|
|
5
|
-
|
|
6
6
|
//#region src/nitro/setup/extend-loader.ts
|
|
7
7
|
const logger = consola.withTag(LOG_TAG);
|
|
8
8
|
/**
|
|
@@ -13,70 +13,40 @@ async function resolveExtendDirs(nitro) {
|
|
|
13
13
|
return resolveExtendDirs$1(extend, nitro.options.rootDir);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Resolve extend configuration and
|
|
16
|
+
* Resolve extend configuration and merge into scan state.
|
|
17
|
+
* Returns a new frozen state — does NOT mutate nitro.
|
|
17
18
|
*/
|
|
18
|
-
async function resolveExtendConfig(nitro, options = {}) {
|
|
19
|
+
async function resolveExtendConfig(nitro, state, options = {}) {
|
|
19
20
|
const extend = nitro.options.graphql?.extend;
|
|
20
|
-
if (!extend || !Array.isArray(extend) || extend.length === 0) return;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
nitro.graphql.
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
if (!extend || !Array.isArray(extend) || extend.length === 0) return state;
|
|
22
|
+
const result = await scanAllExtendSources(extend, nitro.options.rootDir);
|
|
23
|
+
let newState = mergeScanState(state, result);
|
|
24
|
+
if (result.directives.length > 0) {
|
|
25
|
+
const directiveSchemas = await generateDirectiveSchemas([...newState.directives], nitro.graphql.buildDir);
|
|
26
|
+
newState = Object.freeze({
|
|
27
|
+
...newState,
|
|
28
|
+
directiveSchemas
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const added = {
|
|
32
|
+
schemas: newState.schemas.length - state.schemas.length,
|
|
33
|
+
resolvers: newState.resolvers.length - state.resolvers.length,
|
|
34
|
+
directives: newState.directives.length - state.directives.length,
|
|
35
|
+
documents: newState.documents.length - state.documents.length,
|
|
36
|
+
configs: newState.extendConfigs.length - state.extendConfigs.length,
|
|
37
|
+
programmaticSchemas: newState.extendSchemas.length - state.extendSchemas.length
|
|
38
|
+
};
|
|
39
|
+
if (!options.silent && Object.values(added).some((v) => v > 0)) {
|
|
27
40
|
const parts = [];
|
|
28
|
-
if (
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
41
|
+
if (added.schemas > 0) parts.push(`${added.schemas} schema(s)`);
|
|
42
|
+
if (added.resolvers > 0) parts.push(`${added.resolvers} resolver(s)`);
|
|
43
|
+
if (added.directives > 0) parts.push(`${added.directives} directive(s)`);
|
|
44
|
+
if (added.documents > 0) parts.push(`${added.documents} document(s)`);
|
|
45
|
+
if (added.configs > 0) parts.push(`${added.configs} config(s)`);
|
|
46
|
+
if (added.programmaticSchemas > 0) parts.push(`${added.programmaticSchemas} programmatic schema(s)`);
|
|
34
47
|
logger.info(`Extended with ${parts.join(", ")}`);
|
|
35
48
|
}
|
|
49
|
+
return newState;
|
|
36
50
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Apply extend scan result to Nitro state
|
|
39
|
-
*/
|
|
40
|
-
function applyExtendResult(nitro, result) {
|
|
41
|
-
let schemasAdded = 0;
|
|
42
|
-
let resolversAdded = 0;
|
|
43
|
-
let directivesAdded = 0;
|
|
44
|
-
let documentsAdded = 0;
|
|
45
|
-
let configsAdded = 0;
|
|
46
|
-
let programmaticSchemasAdded = 0;
|
|
47
|
-
for (const schemaPath of result.schemas) if (!nitro.scanSchemas.includes(schemaPath)) {
|
|
48
|
-
nitro.scanSchemas.push(schemaPath);
|
|
49
|
-
schemasAdded++;
|
|
50
|
-
}
|
|
51
|
-
for (const resolver of result.resolvers) if (!nitro.scanResolvers.some((r) => r.specifier === resolver.specifier)) {
|
|
52
|
-
nitro.scanResolvers.push(resolver);
|
|
53
|
-
resolversAdded++;
|
|
54
|
-
}
|
|
55
|
-
for (const directive of result.directives) if (!nitro.scanDirectives.some((d) => d.specifier === directive.specifier)) {
|
|
56
|
-
nitro.scanDirectives.push(directive);
|
|
57
|
-
directivesAdded++;
|
|
58
|
-
}
|
|
59
|
-
for (const docPath of result.documents) if (!nitro.scanDocuments.includes(docPath)) {
|
|
60
|
-
nitro.scanDocuments.push(docPath);
|
|
61
|
-
documentsAdded++;
|
|
62
|
-
}
|
|
63
|
-
if (result.configPath && !nitro.graphql.extendConfigs.includes(result.configPath)) {
|
|
64
|
-
nitro.graphql.extendConfigs.push(result.configPath);
|
|
65
|
-
configsAdded++;
|
|
66
|
-
}
|
|
67
|
-
if (result.schemaPath && !nitro.graphql.extendSchemas.includes(result.schemaPath)) {
|
|
68
|
-
nitro.graphql.extendSchemas.push(result.schemaPath);
|
|
69
|
-
programmaticSchemasAdded++;
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
schemas: schemasAdded,
|
|
73
|
-
resolvers: resolversAdded,
|
|
74
|
-
directives: directivesAdded,
|
|
75
|
-
documents: documentsAdded,
|
|
76
|
-
configs: configsAdded,
|
|
77
|
-
programmaticSchemas: programmaticSchemasAdded
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
51
|
//#endregion
|
|
82
|
-
export { resolveExtendConfig, resolveExtendDirs };
|
|
52
|
+
export { resolveExtendConfig, resolveExtendDirs };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { createCoreWatcher } from "../../core/watcher/
|
|
2
|
+
import { refreshVirtualModules } from "../virtual/index.mjs";
|
|
3
|
+
import { createCoreWatcher } from "../../core/watcher/create-watcher.mjs";
|
|
4
|
+
import { generateClientTypes } from "../codegen/client-types.mjs";
|
|
4
5
|
import { performGraphQLScan, shouldScanLocalFiles } from "./scanner.mjs";
|
|
6
|
+
import { regenerateTypes } from "./type-generation.mjs";
|
|
5
7
|
import consola from "consola";
|
|
6
8
|
import { join } from "pathe";
|
|
7
|
-
|
|
8
9
|
//#region src/nitro/setup/file-watcher.ts
|
|
10
|
+
const TRAILING_SLASH_RE = /\/$/;
|
|
9
11
|
const logger = consola.withTag(LOG_TAG);
|
|
10
12
|
/**
|
|
11
13
|
* Setup file watcher for GraphQL files (schemas, resolvers, directives, documents)
|
|
@@ -24,8 +26,8 @@ function setupFileWatcher(nitro, watchDirs) {
|
|
|
24
26
|
silent: true,
|
|
25
27
|
isRescan: true
|
|
26
28
|
});
|
|
27
|
-
|
|
28
|
-
await
|
|
29
|
+
refreshVirtualModules(nitro);
|
|
30
|
+
await regenerateTypes(nitro, { silent: true });
|
|
29
31
|
logger.success("Types regenerated");
|
|
30
32
|
await nitro.hooks.callHook("dev:reload");
|
|
31
33
|
},
|
|
@@ -51,13 +53,12 @@ function getWatchDirectories(nitro, extendDirs = []) {
|
|
|
51
53
|
if (nitro.options.graphql?.externalServices?.length) {
|
|
52
54
|
for (const service of nitro.options.graphql.externalServices) if (service.documents?.length) for (const pattern of service.documents) {
|
|
53
55
|
if (!pattern) continue;
|
|
54
|
-
const baseDir = pattern.split("**")[0]?.replace(
|
|
56
|
+
const baseDir = pattern.split("**")[0]?.replace(TRAILING_SLASH_RE, "") || ".";
|
|
55
57
|
const resolvedDir = join(nitro.options.rootDir, baseDir);
|
|
56
58
|
if (!watchDirs.includes(resolvedDir)) watchDirs.push(resolvedDir);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
return watchDirs;
|
|
60
62
|
}
|
|
61
|
-
|
|
62
63
|
//#endregion
|
|
63
|
-
export { getWatchDirectories, setupFileWatcher };
|
|
64
|
+
export { getWatchDirectories, setupFileWatcher };
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { SecurityConfig } from "../types.mjs";
|
|
2
1
|
import { Nitro } from "nitro/types";
|
|
3
2
|
|
|
4
3
|
//#region src/nitro/setup/logging.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Resolves security configuration with environment-aware defaults
|
|
7
|
-
* In production: introspection off, playground off, errors masked, suggestions disabled
|
|
8
|
-
* In development: introspection on, playground on, errors shown, suggestions enabled
|
|
9
|
-
*/
|
|
10
|
-
declare function resolveSecurityConfig(config?: SecurityConfig): Required<SecurityConfig>;
|
|
11
4
|
/**
|
|
12
5
|
* Log startup information
|
|
13
6
|
*/
|
|
14
7
|
declare function logStartupInfo(nitro: Nitro, serverEnabled: boolean): void;
|
|
15
8
|
//#endregion
|
|
16
|
-
export { logStartupInfo
|
|
9
|
+
export { logStartupInfo };
|
|
@@ -1,41 +1,25 @@
|
|
|
1
|
+
import { resolveSecurityConfig } from "./security.mjs";
|
|
1
2
|
import consola from "consola";
|
|
2
|
-
|
|
3
3
|
//#region src/nitro/setup/logging.ts
|
|
4
4
|
/**
|
|
5
|
-
* Resolves security configuration with environment-aware defaults
|
|
6
|
-
* In production: introspection off, playground off, errors masked, suggestions disabled
|
|
7
|
-
* In development: introspection on, playground on, errors shown, suggestions enabled
|
|
8
|
-
*/
|
|
9
|
-
function resolveSecurityConfig(config) {
|
|
10
|
-
const isProd = process.env.NODE_ENV === "production";
|
|
11
|
-
return {
|
|
12
|
-
introspection: config?.introspection ?? !isProd,
|
|
13
|
-
playground: config?.playground ?? !isProd,
|
|
14
|
-
maskErrors: config?.maskErrors ?? isProd,
|
|
15
|
-
disableSuggestions: config?.disableSuggestions ?? isProd
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
5
|
* Log startup information
|
|
20
6
|
*/
|
|
21
7
|
function logStartupInfo(nitro, serverEnabled) {
|
|
8
|
+
const { state } = nitro.graphql;
|
|
22
9
|
const externalServicesCount = nitro.options.graphql?.externalServices?.length || 0;
|
|
23
|
-
const docs = nitro.scanDocuments || [];
|
|
24
10
|
const isProd = process.env.NODE_ENV === "production";
|
|
25
11
|
if (serverEnabled) {
|
|
26
12
|
const securityConfig = resolveSecurityConfig(nitro.options.graphql?.security);
|
|
27
13
|
const framework = nitro.options.graphql?.framework || "unknown";
|
|
28
|
-
const schemas = nitro.scanSchemas?.length || 0;
|
|
29
|
-
const resolvers = nitro.scanResolvers?.length || 0;
|
|
30
14
|
consola.box({
|
|
31
15
|
title: "Nitro GraphQL",
|
|
32
16
|
message: [
|
|
33
17
|
`Framework: ${framework}`,
|
|
34
18
|
`Environment: ${isProd ? "production" : "development"}`,
|
|
35
|
-
`Schemas: ${schemas}`,
|
|
36
|
-
`Resolvers: ${resolvers}`,
|
|
19
|
+
`Schemas: ${state.schemas.length}`,
|
|
20
|
+
`Resolvers: ${state.resolvers.length}`,
|
|
37
21
|
externalServicesCount > 0 ? `External Services: ${externalServicesCount}` : "",
|
|
38
|
-
|
|
22
|
+
state.documents.length > 0 ? `Documents: ${state.documents.length}` : "",
|
|
39
23
|
"",
|
|
40
24
|
"Security:",
|
|
41
25
|
`├─ Introspection: ${securityConfig.introspection ? "enabled" : "disabled"}`,
|
|
@@ -53,7 +37,7 @@ function logStartupInfo(nitro, serverEnabled) {
|
|
|
53
37
|
message: [
|
|
54
38
|
"Server mode: disabled",
|
|
55
39
|
`External Services: ${externalServicesCount}`,
|
|
56
|
-
`Documents: ${
|
|
40
|
+
`Documents: ${state.documents.length}`
|
|
57
41
|
].join("\n"),
|
|
58
42
|
style: {
|
|
59
43
|
borderColor: "blue",
|
|
@@ -61,6 +45,5 @@ function logStartupInfo(nitro, serverEnabled) {
|
|
|
61
45
|
}
|
|
62
46
|
});
|
|
63
47
|
}
|
|
64
|
-
|
|
65
48
|
//#endregion
|
|
66
|
-
export { logStartupInfo
|
|
49
|
+
export { logStartupInfo };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_UNKNOWN, GRAPHQL_EXTENSIONS, RESOLVER_EXTENSIONS } from "../../core/constants.mjs";
|
|
1
2
|
//#region src/nitro/setup/rollup-integration.ts
|
|
3
|
+
const NITRO_GRAPHQL_ROUTES_RE = /nitro-graphql[/\\]dist[/\\]nitro[/\\]routes/;
|
|
4
|
+
const NITRO_GRAPHQL_SCHEMA_RE = /nitro-graphql[/\\]dist[/\\]core[/\\]schema/;
|
|
2
5
|
/**
|
|
3
6
|
* Configure noExternals to ensure nitro-graphql route handlers are bundled
|
|
4
7
|
* This is critical for Nuxt integration where node_modules are externalized by default.
|
|
5
8
|
* Without this, the #nitro-graphql/* virtual imports in handlers would fail at runtime.
|
|
6
9
|
*/
|
|
7
10
|
function setupNoExternals(nitro) {
|
|
8
|
-
const routePatterns = [
|
|
11
|
+
const routePatterns = [NITRO_GRAPHQL_ROUTES_RE, NITRO_GRAPHQL_SCHEMA_RE];
|
|
9
12
|
if (nitro.options.noExternals === true) return;
|
|
10
13
|
if (!Array.isArray(nitro.options.noExternals)) nitro.options.noExternals = [];
|
|
11
14
|
nitro.options.noExternals.push(...routePatterns);
|
|
@@ -18,7 +21,37 @@ function setupNoExternals(nitro) {
|
|
|
18
21
|
* interfering with Nitro's node_modules chunking which uses advancedChunks.
|
|
19
22
|
*/
|
|
20
23
|
function setupRollupChunking(nitro) {
|
|
21
|
-
nitro.hooks.hook("rollup:before", (_, rollupConfig) => {
|
|
24
|
+
nitro.hooks.hook("rollup:before", (_, rollupConfig) => {
|
|
25
|
+
if (rollupConfig.output.inlineDynamicImports) return;
|
|
26
|
+
const output = rollupConfig.output;
|
|
27
|
+
if (output.advancedChunks || "codeSplitting" in output) return;
|
|
28
|
+
const existingManualChunks = rollupConfig.output?.manualChunks;
|
|
29
|
+
rollupConfig.output.manualChunks = (id, meta) => {
|
|
30
|
+
if (isGraphQLFile(id)) return `graphql/${CHUNK_NAME_SCHEMAS}`;
|
|
31
|
+
if (isResolverFile(id)) return `graphql/${CHUNK_NAME_RESOLVERS}`;
|
|
32
|
+
if (typeof existingManualChunks === "function") return existingManualChunks(id, meta);
|
|
33
|
+
};
|
|
34
|
+
const existingChunkFileNames = rollupConfig.output.chunkFileNames;
|
|
35
|
+
rollupConfig.output.chunkFileNames = (chunkInfo) => {
|
|
36
|
+
const name = chunkInfo.name || "";
|
|
37
|
+
if (name.startsWith("graphql/")) return `chunks/${name}.mjs`;
|
|
38
|
+
if (typeof existingChunkFileNames === "function") return existingChunkFileNames(chunkInfo);
|
|
39
|
+
if (typeof existingChunkFileNames === "string") return existingChunkFileNames;
|
|
40
|
+
return CHUNK_PATH_UNKNOWN;
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a file is a GraphQL schema file
|
|
46
|
+
*/
|
|
47
|
+
function isGraphQLFile(id) {
|
|
48
|
+
return GRAPHQL_EXTENSIONS.some((ext) => id.endsWith(ext));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if a file is a resolver file
|
|
52
|
+
*/
|
|
53
|
+
function isResolverFile(id) {
|
|
54
|
+
return RESOLVER_EXTENSIONS.some((ext) => id.endsWith(ext));
|
|
22
55
|
}
|
|
23
56
|
/**
|
|
24
57
|
* Configure external dependencies for Rollup
|
|
@@ -58,6 +91,5 @@ function setupRollupExternals(nitro) {
|
|
|
58
91
|
}
|
|
59
92
|
});
|
|
60
93
|
}
|
|
61
|
-
|
|
62
94
|
//#endregion
|
|
63
|
-
export { setupNoExternals, setupRollupChunking, setupRollupExternals };
|
|
95
|
+
export { setupNoExternals, setupRollupChunking, setupRollupExternals };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ENDPOINT_DEBUG, GRAPHQL_HTTP_METHODS } from "../../core/constants.mjs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
3
|
//#region src/nitro/setup/routes.ts
|
|
5
4
|
/**
|
|
6
5
|
* Resolve a module specifier to an absolute filesystem path.
|
|
@@ -66,6 +65,5 @@ function registerRouteHandlers(nitro) {
|
|
|
66
65
|
method: "GET"
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
|
-
|
|
70
68
|
//#endregion
|
|
71
|
-
export { registerRouteHandlers };
|
|
69
|
+
export { registerRouteHandlers };
|
|
@@ -1,59 +1,24 @@
|
|
|
1
|
-
import { ExtendSource } from "../types.mjs";
|
|
1
|
+
import { ExtendSource } from "../types/config.mjs";
|
|
2
2
|
import { Nitro } from "nitro/types";
|
|
3
3
|
|
|
4
4
|
//#region src/nitro/setup/scanner.d.ts
|
|
5
5
|
interface ScanOptions {
|
|
6
|
-
/** Silent mode - suppress logging */
|
|
7
6
|
silent?: boolean;
|
|
8
|
-
/** Is this a rescan (dev mode hot reload) */
|
|
9
7
|
isRescan?: boolean;
|
|
10
8
|
}
|
|
11
|
-
interface ScanResult {
|
|
12
|
-
schemas: number;
|
|
13
|
-
resolvers: number;
|
|
14
|
-
directives: number;
|
|
15
|
-
documents: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Check if local file scanning should be performed
|
|
19
|
-
* Centralized helper to avoid scattered skipLocalScan checks
|
|
20
|
-
*/
|
|
21
9
|
declare function shouldScanLocalFiles(nitro: Nitro): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Check if server-side GraphQL is enabled
|
|
24
|
-
*/
|
|
25
10
|
declare function isServerEnabled(nitro: Nitro): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get extend sources from config
|
|
28
|
-
*/
|
|
29
11
|
declare function getExtendSources(nitro: Nitro): ExtendSource[] | undefined;
|
|
30
12
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
declare function scanLocalFiles(nitro: Nitro): Promise<ScanResult>;
|
|
35
|
-
/**
|
|
36
|
-
* Scan only client documents (for external services or client-only mode)
|
|
37
|
-
*/
|
|
38
|
-
declare function scanDocumentsOnly(nitro: Nitro): Promise<number>;
|
|
39
|
-
/**
|
|
40
|
-
* Initialize empty scan results (for skipLocalScan mode)
|
|
41
|
-
*/
|
|
42
|
-
declare function initializeEmptyScanResults(nitro: Nitro): void;
|
|
43
|
-
/**
|
|
44
|
-
* Perform complete GraphQL scan workflow
|
|
45
|
-
* This is the main entry point for both initial setup and dev mode rescan
|
|
13
|
+
* Perform complete GraphQL scan workflow.
|
|
14
|
+
* Builds an immutable state snapshot and assigns it to nitro.graphql.state atomically.
|
|
46
15
|
*
|
|
47
|
-
*
|
|
48
|
-
* 1.
|
|
49
|
-
* 2.
|
|
50
|
-
* 3.
|
|
51
|
-
* 4. Log diagnostics if needed
|
|
16
|
+
* Flow:
|
|
17
|
+
* 1. Scan local files (or skip if skipLocalScan)
|
|
18
|
+
* 2. Merge extend sources into state
|
|
19
|
+
* 3. Assign frozen state to nitro.graphql.state (single atomic write)
|
|
52
20
|
*/
|
|
53
21
|
declare function performGraphQLScan(nitro: Nitro, options?: ScanOptions): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Log resolver diagnostics for development
|
|
56
|
-
*/
|
|
57
22
|
declare function logResolverDiagnostics(nitro: Nitro): void;
|
|
58
23
|
//#endregion
|
|
59
|
-
export { ScanOptions,
|
|
24
|
+
export { ScanOptions, getExtendSources, isServerEnabled, logResolverDiagnostics, performGraphQLScan, shouldScanLocalFiles };
|
|
@@ -1,99 +1,96 @@
|
|
|
1
1
|
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
+
import { scanDirectivesCore } from "../../core/scanning/directives.mjs";
|
|
3
|
+
import { scanDocumentsCore } from "../../core/scanning/documents.mjs";
|
|
4
|
+
import { scanResolversCore } from "../../core/scanning/resolvers.mjs";
|
|
5
|
+
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
2
6
|
import { generateDirectiveSchemas } from "../../core/utils/directive-parser.mjs";
|
|
3
|
-
import {
|
|
7
|
+
import { createScanContextFromNitro } from "../adapter.mjs";
|
|
8
|
+
import { createScanState } from "../state.mjs";
|
|
4
9
|
import { resolveExtendConfig } from "./extend-loader.mjs";
|
|
5
10
|
import consola from "consola";
|
|
6
|
-
|
|
11
|
+
import { relative } from "pathe";
|
|
7
12
|
//#region src/nitro/setup/scanner.ts
|
|
8
13
|
const logger = consola.withTag(LOG_TAG);
|
|
9
|
-
/**
|
|
10
|
-
* Check if local file scanning should be performed
|
|
11
|
-
* Centralized helper to avoid scattered skipLocalScan checks
|
|
12
|
-
*/
|
|
13
14
|
function shouldScanLocalFiles(nitro) {
|
|
14
15
|
return nitro.options.graphql?.skipLocalScan !== true;
|
|
15
16
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Check if server-side GraphQL is enabled
|
|
18
|
-
*/
|
|
19
17
|
function isServerEnabled(nitro) {
|
|
20
18
|
return nitro.options.graphql?.server !== false;
|
|
21
19
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Get extend sources from config
|
|
24
|
-
*/
|
|
25
20
|
function getExtendSources(nitro) {
|
|
26
21
|
const extend = nitro.options.graphql?.extend;
|
|
27
22
|
return Array.isArray(extend) ? extend : void 0;
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
|
-
* Scan local GraphQL files
|
|
31
|
-
*
|
|
25
|
+
* Scan local GraphQL files and return an immutable state snapshot.
|
|
26
|
+
* Does NOT mutate nitro — caller is responsible for assigning the state.
|
|
32
27
|
*/
|
|
33
28
|
async function scanLocalFiles(nitro) {
|
|
34
|
-
const
|
|
35
|
-
|
|
29
|
+
const ctx = createScanContextFromNitro(nitro);
|
|
30
|
+
const directivesResult = await scanDirectivesCore(ctx);
|
|
36
31
|
const directiveSchemas = await generateDirectiveSchemas(directivesResult.items, nitro.graphql.buildDir);
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
32
|
+
const schemasResult = await scanSchemasCore(ctx);
|
|
33
|
+
const [docsResult, resolversResult] = await Promise.all([scanDocumentsCore(ctx, {
|
|
34
|
+
externalServices: nitro.options.graphql?.externalServices,
|
|
35
|
+
clientDirRelative: relative(nitro.options.rootDir, nitro.graphql.clientDir)
|
|
36
|
+
}), scanResolversCore(ctx)]);
|
|
37
|
+
return createScanState({
|
|
38
|
+
schemas: schemasResult.items,
|
|
39
|
+
resolvers: resolversResult.items,
|
|
40
|
+
directives: directivesResult.items,
|
|
41
|
+
documents: docsResult.items,
|
|
42
|
+
directiveSchemas
|
|
43
|
+
});
|
|
50
44
|
}
|
|
51
45
|
/**
|
|
52
|
-
* Scan only client documents
|
|
46
|
+
* Scan only client documents, preserving existing state for other fields
|
|
53
47
|
*/
|
|
54
48
|
async function scanDocumentsOnly(nitro) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
return createScanState({
|
|
50
|
+
schemas: [],
|
|
51
|
+
resolvers: [],
|
|
52
|
+
directives: [],
|
|
53
|
+
documents: (await scanDocumentsCore(createScanContextFromNitro(nitro), {
|
|
54
|
+
externalServices: nitro.options.graphql?.externalServices,
|
|
55
|
+
clientDirRelative: relative(nitro.options.rootDir, nitro.graphql.clientDir)
|
|
56
|
+
})).items,
|
|
57
|
+
directiveSchemas: null
|
|
58
|
+
});
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
function initializeEmptyScanResults(nitro) {
|
|
63
|
-
nitro.scanSchemas = [];
|
|
64
|
-
nitro.scanResolvers = [];
|
|
65
|
-
nitro.scanDirectives = [];
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Perform complete GraphQL scan workflow
|
|
69
|
-
* This is the main entry point for both initial setup and dev mode rescan
|
|
61
|
+
* Perform complete GraphQL scan workflow.
|
|
62
|
+
* Builds an immutable state snapshot and assigns it to nitro.graphql.state atomically.
|
|
70
63
|
*
|
|
71
|
-
*
|
|
72
|
-
* 1.
|
|
73
|
-
* 2.
|
|
74
|
-
* 3.
|
|
75
|
-
* 4. Log diagnostics if needed
|
|
64
|
+
* Flow:
|
|
65
|
+
* 1. Scan local files (or skip if skipLocalScan)
|
|
66
|
+
* 2. Merge extend sources into state
|
|
67
|
+
* 3. Assign frozen state to nitro.graphql.state (single atomic write)
|
|
76
68
|
*/
|
|
77
69
|
async function performGraphQLScan(nitro, options = {}) {
|
|
78
70
|
const { silent = false, isRescan = false } = options;
|
|
79
71
|
const serverEnabled = isServerEnabled(nitro);
|
|
80
72
|
const scanLocal = shouldScanLocalFiles(nitro);
|
|
81
73
|
const extendSources = getExtendSources(nitro);
|
|
82
|
-
if (isRescan &&
|
|
74
|
+
if (isRescan && extendSources?.length) return;
|
|
75
|
+
let state;
|
|
83
76
|
if (!scanLocal) {
|
|
84
77
|
if (!isRescan && !silent) if (extendSources?.length) logger.info(`Using ${extendSources.length} extend source(s), skipping local scanning`);
|
|
85
78
|
else logger.info("Skipping local scanning (skipLocalScan: true)");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
state = await scanDocumentsOnly(nitro);
|
|
80
|
+
} else if (serverEnabled) state = await scanLocalFiles(nitro);
|
|
81
|
+
else state = await scanDocumentsOnly(nitro);
|
|
82
|
+
state = await resolveExtendConfig(nitro, state, { silent: silent || isRescan });
|
|
83
|
+
nitro.graphql.state = state;
|
|
84
|
+
nitro.scanSchemas = [...state.schemas];
|
|
85
|
+
nitro.scanResolvers = [...state.resolvers];
|
|
86
|
+
nitro.scanDirectives = [...state.directives];
|
|
87
|
+
nitro.scanDocuments = [...state.documents];
|
|
88
|
+
nitro.graphql.directiveSchemas = state.directiveSchemas;
|
|
89
|
+
nitro.graphql.extendConfigs = [...state.extendConfigs];
|
|
90
|
+
nitro.graphql.extendSchemas = [...state.extendSchemas];
|
|
91
91
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Log resolver diagnostics for development
|
|
94
|
-
*/
|
|
95
92
|
function logResolverDiagnostics(nitro) {
|
|
96
|
-
const resolvers = nitro.
|
|
93
|
+
const resolvers = nitro.graphql.state.resolvers;
|
|
97
94
|
if (resolvers.length > 0) {
|
|
98
95
|
const totalExports = resolvers.reduce((sum, r) => sum + r.imports.length, 0);
|
|
99
96
|
const typeCount = {
|
|
@@ -115,6 +112,5 @@ function logResolverDiagnostics(nitro) {
|
|
|
115
112
|
if (breakdown.length > 0) logger.success(`${totalExports} resolver export(s): ${breakdown.join(", ")}`);
|
|
116
113
|
} else logger.warn("No resolvers found. Check /_nitro/graphql/debug for details.");
|
|
117
114
|
}
|
|
118
|
-
|
|
119
115
|
//#endregion
|
|
120
|
-
export { getExtendSources,
|
|
116
|
+
export { getExtendSources, isServerEnabled, logResolverDiagnostics, performGraphQLScan, shouldScanLocalFiles };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CoreSecurityConfig } from "../../core/types/config.mjs";
|
|
2
|
+
//#region src/nitro/setup/security.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resolves security configuration with environment-aware defaults
|
|
5
|
+
* In production: introspection off, playground off, errors masked, suggestions disabled
|
|
6
|
+
* In development: introspection on, playground on, errors shown, suggestions enabled
|
|
7
|
+
*/
|
|
8
|
+
declare function resolveSecurityConfig(config?: CoreSecurityConfig): Required<CoreSecurityConfig>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { resolveSecurityConfig };
|