nitro-graphql 2.0.0-beta.36 → 2.0.0-beta.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +12 -0
- package/dist/cli/commands/init.mjs +100 -0
- package/dist/cli/commands/validate.d.mts +10 -0
- package/dist/cli/commands/validate.mjs +69 -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 +219 -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 +1 -3
- package/dist/index.d.mts +6 -43
- 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/nitro/routes/apollo-server.mjs +71 -0
- 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/nitro/routes/graphql-yoga.d.mts +6 -0
- package/dist/{routes → nitro/routes}/graphql-yoga.mjs +21 -10
- package/dist/nitro/routes/health.d.mts +10 -0
- 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/nitro/setup/logging.d.mts +17 -0
- 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/{setup.d.mts → nitro/setup.d.mts} +3 -2
- package/dist/{setup.mjs → nitro/setup.mjs} +73 -62
- package/dist/nitro/types.d.mts +378 -0
- 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 -43
- 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/routes/apollo-server.mjs +0 -45
- package/dist/routes/graphql-yoga.d.mts +0 -6
- package/dist/routes/health.d.mts +0 -10
- package/dist/setup/graphql-scanner.mjs +0 -25
- package/dist/setup/scaffold-generator.mjs +0 -109
- package/dist/types/index.d.mts +0 -246
- 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 -267
- 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
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import consola from "consola";
|
|
2
|
-
import { dirname } from "pathe";
|
|
3
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/file-generator.ts
|
|
6
|
-
/**
|
|
7
|
-
* Safely write a file to disk, creating parent directories if needed
|
|
8
|
-
*/
|
|
9
|
-
function writeFile(filePath, content, description) {
|
|
10
|
-
try {
|
|
11
|
-
const dir = dirname(filePath);
|
|
12
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
13
|
-
writeFileSync(filePath, content, "utf-8");
|
|
14
|
-
if (description) consola.success(`[nitro-graphql] Generated: ${description}`);
|
|
15
|
-
} catch (error) {
|
|
16
|
-
consola.error(`[nitro-graphql] Failed to write file: ${filePath}`, error);
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Write a file only if it doesn't already exist
|
|
22
|
-
* Returns true if file was created, false if it already existed
|
|
23
|
-
*/
|
|
24
|
-
function writeFileIfNotExists(filePath, content, description) {
|
|
25
|
-
if (existsSync(filePath)) return false;
|
|
26
|
-
writeFile(filePath, content, description);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Write a file and always overwrite (used for generated files like SDK)
|
|
31
|
-
* This is for files that are auto-generated and should be updated on every build
|
|
32
|
-
*/
|
|
33
|
-
function writeGeneratedFile(filePath, content, description) {
|
|
34
|
-
writeFile(filePath, content, description);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Check if a path is configured and should be generated
|
|
38
|
-
* Returns the resolved path if should generate, null otherwise
|
|
39
|
-
*/
|
|
40
|
-
function getGenerationPath(resolvedPath, description) {
|
|
41
|
-
if (!resolvedPath) {
|
|
42
|
-
if (description) consola.debug(`[nitro-graphql] Skipping generation: ${description} (disabled in config)`);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return resolvedPath;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Log skipped file generation (helpful for debugging library mode)
|
|
49
|
-
*/
|
|
50
|
-
function logSkipped(fileName, reason) {
|
|
51
|
-
const message = reason ? `Skipped ${fileName}: ${reason}` : `Skipped ${fileName}`;
|
|
52
|
-
consola.debug(`[nitro-graphql] ${message}`);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Log generated file path
|
|
56
|
-
*/
|
|
57
|
-
function logGenerated(fileName, path) {
|
|
58
|
-
consola.info(`[nitro-graphql] Generated ${fileName} at: ${path}`);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Validate that a Nitro instance has the required GraphQL configuration
|
|
62
|
-
*/
|
|
63
|
-
function validateGraphQLConfig(nitro) {
|
|
64
|
-
if (!nitro.options.graphql?.framework) {
|
|
65
|
-
consola.warn("[nitro-graphql] No GraphQL framework specified. Some features may not work correctly.");
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { getGenerationPath, logGenerated, logSkipped, validateGraphQLConfig, writeFile, writeFileIfNotExists, writeGeneratedFile };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PathPlaceholders } from "./path-resolver.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/file-writer.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Options for writing generated files
|
|
7
|
-
*/
|
|
8
|
-
interface WriteGeneratedFileOptions {
|
|
9
|
-
/** Path configuration (string path, boolean, or undefined) */
|
|
10
|
-
pathConfig: string | boolean | undefined;
|
|
11
|
-
/** Whether the category is enabled */
|
|
12
|
-
categoryEnabled: boolean | undefined;
|
|
13
|
-
/** Default path template with placeholders */
|
|
14
|
-
defaultPath: string;
|
|
15
|
-
/** Content to write */
|
|
16
|
-
content: string;
|
|
17
|
-
/** Path placeholders for resolution */
|
|
18
|
-
placeholders: PathPlaceholders;
|
|
19
|
-
/** Description for logging (e.g., "client types", "SDK") */
|
|
20
|
-
description: string;
|
|
21
|
-
/** Whether to suppress success logs */
|
|
22
|
-
silent?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Write a generated file with path resolution and directory creation
|
|
26
|
-
* Returns the resolved path if file was written, undefined otherwise
|
|
27
|
-
*/
|
|
28
|
-
declare function writeGeneratedFile(options: WriteGeneratedFileOptions): string | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Write multiple generated files
|
|
31
|
-
* Returns array of resolved paths for files that were written
|
|
32
|
-
*/
|
|
33
|
-
declare function writeGeneratedFiles(files: WriteGeneratedFileOptions[]): (string | undefined)[];
|
|
34
|
-
//#endregion
|
|
35
|
-
export { WriteGeneratedFileOptions, writeGeneratedFile, writeGeneratedFiles };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { LOG_TAG } from "../constants.mjs";
|
|
2
|
-
import { resolveFilePath } from "./path-resolver.mjs";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import { dirname } from "pathe";
|
|
5
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
-
|
|
7
|
-
//#region src/utils/file-writer.ts
|
|
8
|
-
const logger = consola.withTag(LOG_TAG);
|
|
9
|
-
/**
|
|
10
|
-
* Write a generated file with path resolution and directory creation
|
|
11
|
-
* Returns the resolved path if file was written, undefined otherwise
|
|
12
|
-
*/
|
|
13
|
-
function writeGeneratedFile(options) {
|
|
14
|
-
const { pathConfig, categoryEnabled, defaultPath, content, placeholders, description, silent = false } = options;
|
|
15
|
-
const resolvedPath = resolveFilePath(pathConfig, categoryEnabled, true, defaultPath, placeholders);
|
|
16
|
-
if (resolvedPath) {
|
|
17
|
-
mkdirSync(dirname(resolvedPath), { recursive: true });
|
|
18
|
-
writeFileSync(resolvedPath, content, "utf-8");
|
|
19
|
-
if (!silent) logger.success(`Generated ${description} at: ${resolvedPath}`);
|
|
20
|
-
return resolvedPath;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Write multiple generated files
|
|
25
|
-
* Returns array of resolved paths for files that were written
|
|
26
|
-
*/
|
|
27
|
-
function writeGeneratedFiles(files) {
|
|
28
|
-
return files.map((file) => writeGeneratedFile(file));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { writeGeneratedFile, writeGeneratedFiles };
|
package/dist/utils/index.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
|
|
2
|
-
import { createDefaultMaskError } from "./errors.mjs";
|
|
3
|
-
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
|
|
4
|
-
import { getImportId, relativeWithDot } from "./imports.mjs";
|
|
5
|
-
import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories } from "./layers.mjs";
|
|
6
|
-
import { FileInfo, deduplicateFiles, scanDir } from "./scanning/common.mjs";
|
|
7
|
-
import { scanDirectives } from "./scanning/directives.mjs";
|
|
8
|
-
import { scanDocuments, scanExternalServiceDocs } from "./scanning/documents.mjs";
|
|
9
|
-
import { scanResolvers } from "./scanning/resolvers.mjs";
|
|
10
|
-
import { scanGraphql, scanSchemas } from "./scanning/schemas.mjs";
|
|
11
|
-
import "./scanning/index.mjs";
|
|
12
|
-
import { validateExternalServices } from "./validation.mjs";
|
|
13
|
-
export { type FileInfo, createDefaultMaskError, deduplicateFiles, directiveParser, generateDirectiveSchema, generateDirectiveSchemas, generateLayerIgnorePatterns, getImportId, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories, loadFederationSupport, relativeWithDot, resetFederationCache, scanDir, scanDirectives, scanDocuments, scanExternalServiceDocs, scanGraphql, scanResolvers, scanSchemas, validateExternalServices, warnFederationUnavailable };
|
package/dist/utils/index.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
|
|
2
|
-
import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
|
|
3
|
-
import { createDefaultMaskError } from "./errors.mjs";
|
|
4
|
-
import { getImportId, relativeWithDot } from "./imports.mjs";
|
|
5
|
-
import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories } from "./layers.mjs";
|
|
6
|
-
import { deduplicateFiles, scanDir } from "./scanning/common.mjs";
|
|
7
|
-
import { scanDirectives } from "./scanning/directives.mjs";
|
|
8
|
-
import { scanDocuments, scanExternalServiceDocs } from "./scanning/documents.mjs";
|
|
9
|
-
import { scanResolvers } from "./scanning/resolvers.mjs";
|
|
10
|
-
import { scanGraphql, scanSchemas } from "./scanning/schemas.mjs";
|
|
11
|
-
import { validateExternalServices } from "./validation.mjs";
|
|
12
|
-
|
|
13
|
-
export { createDefaultMaskError, deduplicateFiles, directiveParser, generateDirectiveSchema, generateDirectiveSchemas, generateLayerIgnorePatterns, getImportId, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories, loadFederationSupport, relativeWithDot, resetFederationCache, scanDir, scanDirectives, scanDocuments, scanExternalServiceDocs, scanGraphql, scanResolvers, scanSchemas, validateExternalServices, warnFederationUnavailable };
|
package/dist/utils/layers.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/layers.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get all Nuxt layer directories from Nitro config
|
|
7
|
-
*/
|
|
8
|
-
declare function getLayerDirectories(nitro: Nitro): string[];
|
|
9
|
-
/**
|
|
10
|
-
* Get all Nuxt layer server directories from Nitro config
|
|
11
|
-
*/
|
|
12
|
-
declare function getLayerServerDirectories(nitro: Nitro): string[];
|
|
13
|
-
/**
|
|
14
|
-
* Get all Nuxt layer app directories from Nitro config
|
|
15
|
-
*/
|
|
16
|
-
declare function getLayerAppDirectories(nitro: Nitro): string[];
|
|
17
|
-
/**
|
|
18
|
-
* Generate layer-aware ignore patterns for auto-generated files
|
|
19
|
-
*/
|
|
20
|
-
declare function generateLayerIgnorePatterns(): string[];
|
|
21
|
-
//#endregion
|
|
22
|
-
export { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories };
|
package/dist/utils/layers.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region src/utils/layers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Get all Nuxt layer directories from Nitro config
|
|
4
|
-
*/
|
|
5
|
-
function getLayerDirectories(nitro) {
|
|
6
|
-
return nitro.options.graphql?.layerDirectories || [];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Get all Nuxt layer server directories from Nitro config
|
|
10
|
-
*/
|
|
11
|
-
function getLayerServerDirectories(nitro) {
|
|
12
|
-
return nitro.options.graphql?.layerServerDirs || [];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get all Nuxt layer app directories from Nitro config
|
|
16
|
-
*/
|
|
17
|
-
function getLayerAppDirectories(nitro) {
|
|
18
|
-
return nitro.options.graphql?.layerAppDirs || [];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Generate layer-aware ignore patterns for auto-generated files
|
|
22
|
-
*/
|
|
23
|
-
function generateLayerIgnorePatterns() {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerDirectories, getLayerServerDirectories };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/scanning/common.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* File information returned from scanning operations
|
|
7
|
-
*/
|
|
8
|
-
interface FileInfo {
|
|
9
|
-
path: string;
|
|
10
|
-
fullPath: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Scan a directory for files matching a glob pattern
|
|
14
|
-
*/
|
|
15
|
-
declare function scanDir(nitro: Nitro, dir: string, name: string, globPattern?: string): Promise<FileInfo[]>;
|
|
16
|
-
/**
|
|
17
|
-
* Deduplicate files by fullPath
|
|
18
|
-
*/
|
|
19
|
-
declare function deduplicateFiles<T extends {
|
|
20
|
-
fullPath: string;
|
|
21
|
-
}>(files: T[]): T[];
|
|
22
|
-
//#endregion
|
|
23
|
-
export { FileInfo, deduplicateFiles, scanDir };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { GLOB_SCAN_PATTERN } from "../../constants.mjs";
|
|
2
|
-
import { join, relative } from "pathe";
|
|
3
|
-
import { glob } from "tinyglobby";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/scanning/common.ts
|
|
6
|
-
/**
|
|
7
|
-
* Scan a directory for files matching a glob pattern
|
|
8
|
-
*/
|
|
9
|
-
async function scanDir(nitro, dir, name, globPattern = GLOB_SCAN_PATTERN) {
|
|
10
|
-
return (await glob(join(name, globPattern), {
|
|
11
|
-
cwd: dir,
|
|
12
|
-
dot: true,
|
|
13
|
-
ignore: nitro.options.ignore,
|
|
14
|
-
absolute: true
|
|
15
|
-
}).catch((error) => {
|
|
16
|
-
if (error?.code === "ENOTDIR") {
|
|
17
|
-
nitro.logger.warn(`Ignoring \`${join(dir, name)}\`. It must be a directory.`);
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
throw error;
|
|
21
|
-
})).map((fullPath) => ({
|
|
22
|
-
fullPath,
|
|
23
|
-
path: relative(join(dir, name), fullPath)
|
|
24
|
-
})).sort((a, b) => a.path.localeCompare(b.path));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Deduplicate files by fullPath
|
|
28
|
-
*/
|
|
29
|
-
function deduplicateFiles(files) {
|
|
30
|
-
const seenPaths = /* @__PURE__ */ new Set();
|
|
31
|
-
return files.filter((file) => {
|
|
32
|
-
if (seenPaths.has(file.fullPath)) return false;
|
|
33
|
-
seenPaths.add(file.fullPath);
|
|
34
|
-
return true;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { deduplicateFiles, scanDir };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GenImport } from "../../types/index.mjs";
|
|
2
|
-
import { Nitro } from "nitro/types";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/scanning/directives.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Scan for directive files and parse their exports
|
|
8
|
-
*/
|
|
9
|
-
declare function scanDirectives(nitro: Nitro): Promise<GenImport[]>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { scanDirectives };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { getLayerServerDirectories } from "../layers.mjs";
|
|
2
|
-
import { deduplicateFiles, scanDir } from "./common.mjs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { relative } from "pathe";
|
|
5
|
-
import { hash } from "ohash";
|
|
6
|
-
import { parseSync } from "oxc-parser";
|
|
7
|
-
|
|
8
|
-
//#region src/utils/scanning/directives.ts
|
|
9
|
-
/**
|
|
10
|
-
* Scan for directive files and parse their exports
|
|
11
|
-
*/
|
|
12
|
-
async function scanDirectives(nitro) {
|
|
13
|
-
const serverDirRelative = relative(nitro.options.rootDir, nitro.graphql.serverDir);
|
|
14
|
-
const regularFiles = await scanDir(nitro, nitro.options.rootDir, serverDirRelative, "**/*.directive.{ts,js}");
|
|
15
|
-
const layerServerDirs = getLayerServerDirectories(nitro);
|
|
16
|
-
const layerFiles = await Promise.all(layerServerDirs.map((layerServerDir) => scanDir(nitro, layerServerDir, "graphql", "**/*.directive.{ts,js}"))).then((r) => r.flat());
|
|
17
|
-
const files = deduplicateFiles([...regularFiles, ...layerFiles]);
|
|
18
|
-
const exportName = [];
|
|
19
|
-
for (const file of files) {
|
|
20
|
-
const fileContent = await readFile(file.fullPath, "utf-8");
|
|
21
|
-
const parsed = parseSync(file.fullPath, fileContent);
|
|
22
|
-
const exports = {
|
|
23
|
-
imports: [],
|
|
24
|
-
specifier: file.fullPath
|
|
25
|
-
};
|
|
26
|
-
for (const node of parsed.program.body) if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
27
|
-
for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
|
|
28
|
-
if (decl.init && decl.init.type === "CallExpression") {
|
|
29
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineDirective") exports.imports.push({
|
|
30
|
-
name: decl.id.name,
|
|
31
|
-
type: "directive",
|
|
32
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (exports.imports.length > 0) exportName.push(exports);
|
|
38
|
-
}
|
|
39
|
-
return exportName;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
export { scanDirectives };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/scanning/documents.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Scan for GraphQL client documents (.graphql) in client directory
|
|
7
|
-
* Excludes files from external service directories
|
|
8
|
-
*/
|
|
9
|
-
declare function scanDocuments(nitro: Nitro): Promise<string[]>;
|
|
10
|
-
/**
|
|
11
|
-
* Scan documents for a specific external service
|
|
12
|
-
*/
|
|
13
|
-
declare function scanExternalServiceDocs(nitro: Nitro, serviceName: string, patterns: string[]): Promise<string[]>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { scanDocuments, scanExternalServiceDocs };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { getLayerAppDirectories } from "../layers.mjs";
|
|
2
|
-
import { deduplicateFiles, scanDir } from "./common.mjs";
|
|
3
|
-
import { glob } from "tinyglobby";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/scanning/documents.ts
|
|
6
|
-
/**
|
|
7
|
-
* Scan for GraphQL client documents (.graphql) in client directory
|
|
8
|
-
* Excludes files from external service directories
|
|
9
|
-
*/
|
|
10
|
-
async function scanDocuments(nitro) {
|
|
11
|
-
const files = await scanDir(nitro, nitro.options.rootDir, nitro.graphql.dir.client, "**/*.graphql");
|
|
12
|
-
const layerAppDirs = getLayerAppDirectories(nitro);
|
|
13
|
-
const layerFiles = await Promise.all(layerAppDirs.map((layerAppDir) => scanDir(nitro, layerAppDir, "graphql", "**/*.graphql"))).then((r) => r.flat());
|
|
14
|
-
const allFiles = deduplicateFiles([...files, ...layerFiles]);
|
|
15
|
-
const externalPatterns = (nitro.options.graphql?.externalServices || []).flatMap((service) => service.documents || []);
|
|
16
|
-
return allFiles.filter((f) => !f.path.startsWith("external/")).filter((f) => {
|
|
17
|
-
const relativePath = f.path;
|
|
18
|
-
for (const pattern of externalPatterns) {
|
|
19
|
-
const clientDirPattern = `${nitro.graphql.dir.client}/`;
|
|
20
|
-
if (pattern.replace(/* @__PURE__ */ new RegExp(`^${clientDirPattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`), "").split("/")[0] === relativePath.split("/")[0]) return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}).map((f) => f.fullPath);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Scan documents for a specific external service
|
|
27
|
-
*/
|
|
28
|
-
async function scanExternalServiceDocs(nitro, serviceName, patterns) {
|
|
29
|
-
if (!patterns.length) return [];
|
|
30
|
-
const files = [];
|
|
31
|
-
for (const pattern of patterns) try {
|
|
32
|
-
const serviceFiles = await glob(pattern, {
|
|
33
|
-
cwd: nitro.options.rootDir,
|
|
34
|
-
dot: true,
|
|
35
|
-
ignore: nitro.options.ignore,
|
|
36
|
-
absolute: true
|
|
37
|
-
});
|
|
38
|
-
files.push(...serviceFiles);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
nitro.logger.warn(`[graphql:${serviceName}] Error scanning documents with pattern "${pattern}":`, error);
|
|
41
|
-
}
|
|
42
|
-
return files.filter((file, index, self) => self.indexOf(file) === index);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { scanDocuments, scanExternalServiceDocs };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FileInfo, deduplicateFiles, scanDir } from "./common.mjs";
|
|
2
|
-
import { scanDirectives } from "./directives.mjs";
|
|
3
|
-
import { scanDocuments, scanExternalServiceDocs } from "./documents.mjs";
|
|
4
|
-
import { scanResolvers } from "./resolvers.mjs";
|
|
5
|
-
import { scanGraphql, scanSchemas } from "./schemas.mjs";
|
|
6
|
-
export { type FileInfo, deduplicateFiles, scanDir, scanDirectives, scanDocuments, scanExternalServiceDocs, scanGraphql, scanResolvers, scanSchemas };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { deduplicateFiles, scanDir } from "./common.mjs";
|
|
2
|
-
import { scanDirectives } from "./directives.mjs";
|
|
3
|
-
import { scanDocuments, scanExternalServiceDocs } from "./documents.mjs";
|
|
4
|
-
import { scanResolvers } from "./resolvers.mjs";
|
|
5
|
-
import { scanGraphql, scanSchemas } from "./schemas.mjs";
|
|
6
|
-
|
|
7
|
-
export { deduplicateFiles, scanDir, scanDirectives, scanDocuments, scanExternalServiceDocs, scanGraphql, scanResolvers, scanSchemas };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GenImport } from "../../types/index.mjs";
|
|
2
|
-
import { Nitro } from "nitro/types";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/scanning/resolvers.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Scan for resolver files and parse their exports
|
|
8
|
-
*/
|
|
9
|
-
declare function scanResolvers(nitro: Nitro): Promise<GenImport[]>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { scanResolvers };
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { DEFINE_FUNCTIONS } from "../../constants.mjs";
|
|
2
|
-
import { getLayerServerDirectories } from "../layers.mjs";
|
|
3
|
-
import { deduplicateFiles, scanDir } from "./common.mjs";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
5
|
-
import { basename, relative } from "pathe";
|
|
6
|
-
import { hash } from "ohash";
|
|
7
|
-
import { parseSync } from "oxc-parser";
|
|
8
|
-
|
|
9
|
-
//#region src/utils/scanning/resolvers.ts
|
|
10
|
-
/**
|
|
11
|
-
* Scan for resolver files and parse their exports
|
|
12
|
-
*/
|
|
13
|
-
async function scanResolvers(nitro) {
|
|
14
|
-
const serverDirRelative = relative(nitro.options.rootDir, nitro.graphql.serverDir);
|
|
15
|
-
const regularFiles = await scanDir(nitro, nitro.options.rootDir, serverDirRelative, "**/*.resolver.{ts,js}");
|
|
16
|
-
const layerServerDirs = getLayerServerDirectories(nitro);
|
|
17
|
-
const layerFiles = await Promise.all(layerServerDirs.map((layerServerDir) => scanDir(nitro, layerServerDir, "graphql", "**/*.resolver.{ts,js}"))).then((r) => r.flat());
|
|
18
|
-
const files = deduplicateFiles([...regularFiles, ...layerFiles]);
|
|
19
|
-
const exportName = [];
|
|
20
|
-
for (const file of files) try {
|
|
21
|
-
const fileContent = await readFile(file.fullPath, "utf-8");
|
|
22
|
-
const parsed = parseSync(file.fullPath, fileContent);
|
|
23
|
-
if (parsed.errors && parsed.errors.length > 0) {
|
|
24
|
-
if (nitro.options.dev) {
|
|
25
|
-
const fileName = basename(file.fullPath);
|
|
26
|
-
const firstError = parsed.errors[0];
|
|
27
|
-
const location = firstError?.labels?.[0];
|
|
28
|
-
const lineInfo = location ? `:${location.start}` : "";
|
|
29
|
-
const message = firstError?.message.split(",")[0] || "Syntax error";
|
|
30
|
-
console.error(`✖ ${fileName}${lineInfo} - ${message}`);
|
|
31
|
-
}
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const exports = {
|
|
35
|
-
imports: [],
|
|
36
|
-
specifier: file.fullPath
|
|
37
|
-
};
|
|
38
|
-
let hasDefaultExport = false;
|
|
39
|
-
let hasNamedExport = false;
|
|
40
|
-
const namedExports = [];
|
|
41
|
-
for (const node of parsed.program.body) {
|
|
42
|
-
if (node.type === "ExportDefaultDeclaration") hasDefaultExport = true;
|
|
43
|
-
if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
44
|
-
for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
|
|
45
|
-
hasNamedExport = true;
|
|
46
|
-
namedExports.push(decl.id.name);
|
|
47
|
-
if (decl.init && decl.init.type === "CallExpression") {
|
|
48
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineResolver") exports.imports.push({
|
|
49
|
-
name: decl.id.name,
|
|
50
|
-
type: "resolver",
|
|
51
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
52
|
-
});
|
|
53
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineQuery") exports.imports.push({
|
|
54
|
-
name: decl.id.name,
|
|
55
|
-
type: "query",
|
|
56
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
57
|
-
});
|
|
58
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineMutation") exports.imports.push({
|
|
59
|
-
name: decl.id.name,
|
|
60
|
-
type: "mutation",
|
|
61
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
62
|
-
});
|
|
63
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineField") exports.imports.push({
|
|
64
|
-
name: decl.id.name,
|
|
65
|
-
type: "type",
|
|
66
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
67
|
-
});
|
|
68
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineSubscription") exports.imports.push({
|
|
69
|
-
name: decl.id.name,
|
|
70
|
-
type: "subscription",
|
|
71
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
72
|
-
});
|
|
73
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineDirective") exports.imports.push({
|
|
74
|
-
name: decl.id.name,
|
|
75
|
-
type: "directive",
|
|
76
|
-
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (nitro.options.dev) {
|
|
83
|
-
const relPath = relative(nitro.options.rootDir, file.fullPath);
|
|
84
|
-
if (hasDefaultExport && !hasNamedExport) nitro.logger.warn(`[nitro-graphql] ${relPath}: Using default export instead of named export. Resolvers must use named exports like "export const myResolver = defineQuery(...)". Default exports are not detected.`);
|
|
85
|
-
if (exports.imports.length === 0 && hasNamedExport) {
|
|
86
|
-
const validFunctions = DEFINE_FUNCTIONS.join(", ");
|
|
87
|
-
nitro.logger.warn(`[nitro-graphql] ${relPath}: File has named exports [${namedExports.join(", ")}] but none use the required define functions (${validFunctions}). Exports will not be registered.`);
|
|
88
|
-
}
|
|
89
|
-
if (!hasDefaultExport && !hasNamedExport) nitro.logger.warn(`[nitro-graphql] ${relPath}: No exports found. Resolver files must export resolvers using defineResolver, defineQuery, defineMutation, etc.`);
|
|
90
|
-
}
|
|
91
|
-
if (exports.imports.length > 0) exportName.push(exports);
|
|
92
|
-
} catch (error) {
|
|
93
|
-
const relPath = relative(nitro.options.rootDir, file.fullPath);
|
|
94
|
-
nitro.logger.error(`[nitro-graphql] Failed to parse resolver file ${relPath}:`, error);
|
|
95
|
-
}
|
|
96
|
-
return exportName;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
export { scanResolvers };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/scanning/schemas.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Scan for GraphQL schema files (.graphql) in server directory
|
|
7
|
-
*/
|
|
8
|
-
declare function scanSchemas(nitro: Nitro): Promise<string[]>;
|
|
9
|
-
/**
|
|
10
|
-
* Scan for GraphQL files (.graphql, .gql) in server directory
|
|
11
|
-
* Similar to scanSchemas but includes .gql extension
|
|
12
|
-
*/
|
|
13
|
-
declare function scanGraphql(nitro: Nitro): Promise<string[]>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { scanGraphql, scanSchemas };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getLayerServerDirectories } from "../layers.mjs";
|
|
2
|
-
import { deduplicateFiles, scanDir } from "./common.mjs";
|
|
3
|
-
import { relative } from "pathe";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/scanning/schemas.ts
|
|
6
|
-
/**
|
|
7
|
-
* Scan for GraphQL schema files (.graphql) in server directory
|
|
8
|
-
*/
|
|
9
|
-
async function scanSchemas(nitro) {
|
|
10
|
-
const serverDirRelative = relative(nitro.options.rootDir, nitro.graphql.serverDir);
|
|
11
|
-
const files = await scanDir(nitro, nitro.options.rootDir, serverDirRelative, "**/*.graphql");
|
|
12
|
-
const layerServerDirs = getLayerServerDirectories(nitro);
|
|
13
|
-
const layerFiles = await Promise.all(layerServerDirs.map((layerServerDir) => scanDir(nitro, layerServerDir, "graphql", "**/*.graphql"))).then((r) => r.flat());
|
|
14
|
-
return deduplicateFiles([...files, ...layerFiles]).map((f) => f.fullPath);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Scan for GraphQL files (.graphql, .gql) in server directory
|
|
18
|
-
* Similar to scanSchemas but includes .gql extension
|
|
19
|
-
*/
|
|
20
|
-
async function scanGraphql(nitro) {
|
|
21
|
-
const serverDirRelative = relative(nitro.options.rootDir, nitro.graphql.serverDir);
|
|
22
|
-
const files = await scanDir(nitro, nitro.options.rootDir, serverDirRelative, "**/*.{graphql,gql}");
|
|
23
|
-
const layerServerDirs = getLayerServerDirectories(nitro);
|
|
24
|
-
const layerFiles = await Promise.all(layerServerDirs.map((layerServerDir) => scanDir(nitro, layerServerDir, "graphql", "**/*.{graphql,gql}"))).then((r) => r.flat());
|
|
25
|
-
return deduplicateFiles([...files, ...layerFiles]).map((f) => f.fullPath);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
export { scanGraphql, scanSchemas };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NitroGraphQLOptions } from "../types/index.mjs";
|
|
2
|
-
import { GraphQLSchema } from "graphql";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/server-codegen.d.ts
|
|
5
|
-
declare function generateTypes(selectFremework: string, schema: GraphQLSchema, config?: Partial<NitroGraphQLOptions>, outputPath?: string): Promise<string>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { generateTypes };
|