nitro-graphql 2.0.0-beta.37 → 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 -44
- package/dist/index.mjs +5 -62
- package/dist/nitro/adapter.d.mts +30 -0
- package/dist/nitro/adapter.mjs +97 -0
- package/dist/{utils → nitro}/apollo.d.mts +1 -1
- package/dist/{utils → nitro}/apollo.mjs +1 -1
- package/dist/nitro/codegen.d.mts +19 -0
- package/dist/nitro/codegen.mjs +141 -0
- package/dist/nitro/config.d.mts +52 -0
- package/dist/nitro/config.mjs +58 -0
- package/dist/nitro/index.d.mts +46 -0
- package/dist/nitro/index.mjs +65 -0
- package/dist/{utils/path-resolver.d.mts → nitro/paths.d.mts} +3 -19
- package/dist/{utils/path-resolver.mjs → nitro/paths.mjs} +2 -36
- package/dist/{rollup.d.mts → nitro/rollup.d.mts} +1 -1
- package/dist/{rollup.mjs → nitro/rollup.mjs} +11 -23
- package/dist/{routes → nitro/routes}/apollo-server.d.mts +1 -1
- package/dist/{routes → nitro/routes}/apollo-server.mjs +5 -5
- package/dist/{routes → nitro/routes}/debug-template.d.mts +1 -1
- package/dist/{routes → nitro/routes}/debug-template.mjs +1 -1
- package/dist/{routes → nitro/routes}/debug.d.mts +10 -16
- package/dist/{routes → nitro/routes}/debug.mjs +2 -2
- package/dist/{routes → nitro/routes}/graphql-yoga.d.mts +1 -1
- package/dist/{routes → nitro/routes}/graphql-yoga.mjs +3 -3
- package/dist/{routes → nitro/routes}/health.d.mts +1 -1
- package/dist/{routes → nitro/routes}/health.mjs +1 -1
- package/dist/nitro/setup/file-watcher.d.mts +16 -0
- package/dist/{setup → nitro/setup}/file-watcher.mjs +14 -18
- package/dist/{setup.d.mts → nitro/setup/logging.d.mts} +5 -6
- package/dist/nitro/setup/logging.mjs +66 -0
- package/dist/nitro/setup/rollup-integration.d.mts +16 -0
- package/dist/{setup → nitro/setup}/rollup-integration.mjs +2 -2
- package/dist/nitro/setup/routes.d.mts +10 -0
- package/dist/nitro/setup/routes.mjs +35 -0
- package/dist/nitro/setup/ts-config.d.mts +11 -0
- package/dist/{setup → nitro/setup}/ts-config.mjs +3 -3
- package/dist/nitro/setup.d.mts +12 -0
- package/dist/{setup.mjs → nitro/setup.mjs} +33 -100
- package/dist/{types/index.d.mts → nitro/types.d.mts} +125 -43
- package/dist/nitro/types.mjs +1 -0
- package/dist/nitro/virtual/generators.d.mts +31 -0
- package/dist/nitro/virtual/generators.mjs +193 -0
- package/dist/nitro/virtual/stubs.d.mts +20 -0
- package/dist/nitro/virtual/stubs.mjs +31 -0
- package/dist/{ecosystem/nuxt.d.mts → nuxt.d.mts} +1 -1
- package/dist/{ecosystem/nuxt.mjs → nuxt.mjs} +2 -2
- package/dist/{graphql/server.d.mts → stubs/index.d.mts} +5 -1
- package/dist/stubs/index.mjs +1 -0
- package/package.json +43 -42
- package/dist/codegen/client-types.d.mts +0 -13
- package/dist/codegen/client-types.mjs +0 -131
- package/dist/codegen/external-types.d.mts +0 -12
- package/dist/codegen/external-types.mjs +0 -88
- package/dist/codegen/index.d.mts +0 -18
- package/dist/codegen/index.mjs +0 -24
- package/dist/codegen/server-types.d.mts +0 -13
- package/dist/codegen/server-types.mjs +0 -64
- package/dist/config/defaults.mjs +0 -36
- package/dist/constants/scalars.mjs +0 -27
- package/dist/constants.mjs +0 -106
- package/dist/graphql/index.d.mts +0 -5
- package/dist/setup/graphql-scanner.mjs +0 -25
- package/dist/setup/scaffold-generator.mjs +0 -109
- package/dist/types/standard-schema.d.mts +0 -59
- package/dist/utils/client-codegen.d.mts +0 -41
- package/dist/utils/client-codegen.mjs +0 -277
- package/dist/utils/file-generator.d.mts +0 -37
- package/dist/utils/file-generator.mjs +0 -72
- package/dist/utils/file-writer.d.mts +0 -35
- package/dist/utils/file-writer.mjs +0 -32
- package/dist/utils/index.d.mts +0 -13
- package/dist/utils/index.mjs +0 -13
- package/dist/utils/layers.d.mts +0 -22
- package/dist/utils/layers.mjs +0 -28
- package/dist/utils/scanning/common.d.mts +0 -23
- package/dist/utils/scanning/common.mjs +0 -39
- package/dist/utils/scanning/directives.d.mts +0 -11
- package/dist/utils/scanning/directives.mjs +0 -43
- package/dist/utils/scanning/documents.d.mts +0 -15
- package/dist/utils/scanning/documents.mjs +0 -46
- package/dist/utils/scanning/index.d.mts +0 -6
- package/dist/utils/scanning/index.mjs +0 -7
- package/dist/utils/scanning/resolvers.d.mts +0 -11
- package/dist/utils/scanning/resolvers.mjs +0 -100
- package/dist/utils/scanning/schemas.d.mts +0 -15
- package/dist/utils/scanning/schemas.mjs +0 -29
- package/dist/utils/server-codegen.d.mts +0 -7
- package/dist/utils/server-codegen.mjs +0 -113
- package/dist/utils/type-generation.d.mts +0 -6
- package/dist/utils/type-generation.mjs +0 -7
- package/dist/utils/validation.d.mts +0 -11
- package/dist/virtual/debug-info.d.mts +0 -9
- package/dist/virtual/debug-info.mjs +0 -26
- package/dist/virtual/generators/config.d.mts +0 -22
- package/dist/virtual/generators/config.mjs +0 -36
- package/dist/virtual/generators/debug.d.mts +0 -14
- package/dist/virtual/generators/debug.mjs +0 -53
- package/dist/virtual/generators/directives.d.mts +0 -14
- package/dist/virtual/generators/directives.mjs +0 -52
- package/dist/virtual/generators/index.d.mts +0 -6
- package/dist/virtual/generators/index.mjs +0 -7
- package/dist/virtual/generators/resolvers.d.mts +0 -14
- package/dist/virtual/generators/resolvers.mjs +0 -55
- package/dist/virtual/generators/schemas.d.mts +0 -14
- package/dist/virtual/generators/schemas.mjs +0 -43
- package/dist/virtual/graphql-config.d.mts +0 -9
- package/dist/virtual/graphql-config.mjs +0 -10
- package/dist/virtual/module-config.d.mts +0 -9
- package/dist/virtual/module-config.mjs +0 -10
- package/dist/virtual/server-directives.d.mts +0 -11
- package/dist/virtual/server-directives.mjs +0 -10
- package/dist/virtual/server-resolvers.d.mts +0 -11
- package/dist/virtual/server-resolvers.mjs +0 -10
- package/dist/virtual/server-schemas.d.mts +0 -11
- package/dist/virtual/server-schemas.mjs +0 -10
- /package/dist/{graphql/index.mjs → core/types/adapter.mjs} +0 -0
- /package/dist/{graphql/server.mjs → core/types/codegen.mjs} +0 -0
- /package/dist/{types/define.mjs → core/types/config.mjs} +0 -0
- /package/dist/{types/index.mjs → core/types/define.mjs} +0 -0
- /package/dist/{types/standard-schema.mjs → core/types/index.mjs} +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { writeFile } from "../utils/file-io.mjs";
|
|
2
|
+
import { resolve } from "pathe";
|
|
3
|
+
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
4
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
5
|
+
import { loadSchemaSync } from "@graphql-tools/load";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
8
|
+
import { UrlLoader } from "@graphql-tools/url-loader";
|
|
9
|
+
|
|
10
|
+
//#region src/core/codegen/schema-loader.ts
|
|
11
|
+
/**
|
|
12
|
+
* Check if a path is a URL
|
|
13
|
+
*/
|
|
14
|
+
function isUrl(path) {
|
|
15
|
+
return path.startsWith("http://") || path.startsWith("https://");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load GraphQL schema synchronously
|
|
19
|
+
*/
|
|
20
|
+
function graphQLLoadSchemaSync(schemaPointers, data = {}) {
|
|
21
|
+
const filteredPointers = [...Array.isArray(schemaPointers) ? schemaPointers : [schemaPointers], "!**/vfs/**"];
|
|
22
|
+
try {
|
|
23
|
+
return loadSchemaSync(filteredPointers, {
|
|
24
|
+
...data,
|
|
25
|
+
loaders: [
|
|
26
|
+
new GraphQLFileLoader(),
|
|
27
|
+
new UrlLoader(),
|
|
28
|
+
...data.loaders || []
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
} catch (e) {
|
|
32
|
+
if ((e.message || "").includes("Unable to find any GraphQL type definitions for the following pointers:")) return;
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Load schema from external GraphQL service
|
|
38
|
+
*/
|
|
39
|
+
async function loadExternalSchema(service, buildDir) {
|
|
40
|
+
try {
|
|
41
|
+
const headers = typeof service.headers === "function" ? service.headers() : service.headers || {};
|
|
42
|
+
const schemaSource = service.schema ?? service.endpoint;
|
|
43
|
+
const schemas = Array.isArray(schemaSource) ? schemaSource : [schemaSource];
|
|
44
|
+
if (service.downloadSchema && buildDir) {
|
|
45
|
+
const defaultPath = resolve(buildDir, "graphql", "schemas", `${service.name}.graphql`);
|
|
46
|
+
const schemaFilePath = service.downloadPath ? resolve(service.downloadPath) : defaultPath;
|
|
47
|
+
if (existsSync(schemaFilePath)) try {
|
|
48
|
+
return loadSchemaSync([schemaFilePath], { loaders: [new GraphQLFileLoader()] });
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
const hasUrls = schemas.some((schema) => isUrl(schema));
|
|
52
|
+
const hasLocalFiles = schemas.some((schema) => !isUrl(schema));
|
|
53
|
+
const loaders = [];
|
|
54
|
+
if (hasLocalFiles) loaders.push(new GraphQLFileLoader());
|
|
55
|
+
if (hasUrls) loaders.push(new UrlLoader());
|
|
56
|
+
if (loaders.length === 0) throw new Error("No appropriate loaders found for schema sources");
|
|
57
|
+
return loadSchemaSync(schemas, {
|
|
58
|
+
loaders,
|
|
59
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
60
|
+
});
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Download and save schema from external service
|
|
67
|
+
*/
|
|
68
|
+
async function downloadAndSaveSchema(service, buildDir) {
|
|
69
|
+
const downloadMode = service.downloadSchema;
|
|
70
|
+
if (!downloadMode || downloadMode === "manual") return;
|
|
71
|
+
const defaultPath = resolve(buildDir, "graphql", "schemas", `${service.name}.graphql`);
|
|
72
|
+
const schemaFilePath = service.downloadPath ? resolve(service.downloadPath) : defaultPath;
|
|
73
|
+
try {
|
|
74
|
+
const headers = typeof service.headers === "function" ? service.headers() : service.headers || {};
|
|
75
|
+
const schemaSource = service.schema ?? service.endpoint;
|
|
76
|
+
const schemas = Array.isArray(schemaSource) ? schemaSource : [schemaSource];
|
|
77
|
+
const hasUrlSchemas = schemas.some((schema) => isUrl(schema));
|
|
78
|
+
const hasLocalSchemas = schemas.some((schema) => !isUrl(schema));
|
|
79
|
+
let shouldDownload = false;
|
|
80
|
+
const fileExists = existsSync(schemaFilePath);
|
|
81
|
+
if (downloadMode === "always") {
|
|
82
|
+
shouldDownload = true;
|
|
83
|
+
if (fileExists && hasUrlSchemas) try {
|
|
84
|
+
const remoteSchemaString = printSchemaWithDirectives(loadSchemaSync(schemas.filter(isUrl), {
|
|
85
|
+
loaders: [new UrlLoader()],
|
|
86
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
87
|
+
}));
|
|
88
|
+
const remoteHash = createHash("md5").update(remoteSchemaString).digest("hex");
|
|
89
|
+
const localSchemaString = readFileSync(schemaFilePath, "utf-8");
|
|
90
|
+
if (remoteHash === createHash("md5").update(localSchemaString).digest("hex")) shouldDownload = false;
|
|
91
|
+
} catch {
|
|
92
|
+
shouldDownload = true;
|
|
93
|
+
}
|
|
94
|
+
else if (fileExists && hasLocalSchemas) {
|
|
95
|
+
const localFiles = schemas.filter((schema) => !isUrl(schema));
|
|
96
|
+
let sourceIsNewer = false;
|
|
97
|
+
for (const localFile of localFiles) if (existsSync(localFile)) {
|
|
98
|
+
const sourceStats = statSync(localFile);
|
|
99
|
+
const cachedStats = statSync(schemaFilePath);
|
|
100
|
+
if (sourceStats.mtime > cachedStats.mtime) {
|
|
101
|
+
sourceIsNewer = true;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!sourceIsNewer) shouldDownload = false;
|
|
106
|
+
}
|
|
107
|
+
} else if (downloadMode === true || downloadMode === "once") shouldDownload = !fileExists;
|
|
108
|
+
if (shouldDownload) {
|
|
109
|
+
let schema;
|
|
110
|
+
if (hasUrlSchemas && hasLocalSchemas) schema = loadSchemaSync(schemas, {
|
|
111
|
+
loaders: [new GraphQLFileLoader(), new UrlLoader()],
|
|
112
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
113
|
+
});
|
|
114
|
+
else if (hasUrlSchemas) schema = loadSchemaSync(schemas, {
|
|
115
|
+
loaders: [new UrlLoader()],
|
|
116
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
117
|
+
});
|
|
118
|
+
else schema = loadSchemaSync(schemas, { loaders: [new GraphQLFileLoader()] });
|
|
119
|
+
writeFile(schemaFilePath, printSchemaWithDirectives(schema));
|
|
120
|
+
}
|
|
121
|
+
return schemaFilePath;
|
|
122
|
+
} catch {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "../types/codegen.mjs";
|
|
2
|
+
import { GraphQLSchema } from "graphql";
|
|
3
|
+
|
|
4
|
+
//#region src/core/codegen/server.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default server codegen configuration
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_SERVER_CODEGEN_CONFIG: ServerCodegenConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Generate server-side GraphQL types
|
|
12
|
+
* Pure function that generates TypeScript types from a GraphQL schema
|
|
13
|
+
*/
|
|
14
|
+
declare function generateServerTypesCore(input: ServerCodegenInput): Promise<ServerCodegenResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate types from schema (simplified version for direct use)
|
|
17
|
+
* @deprecated Use generateServerTypesCore instead
|
|
18
|
+
*/
|
|
19
|
+
declare function generateTypes(framework: string, schema: GraphQLSchema, config?: {
|
|
20
|
+
codegen?: {
|
|
21
|
+
server?: ServerCodegenConfig;
|
|
22
|
+
};
|
|
23
|
+
federation?: {
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
};
|
|
26
|
+
}, outputPath?: string): Promise<string>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DEFAULT_GRAPHQL_SCALARS } from "../constants.mjs";
|
|
2
|
+
import { pluginContent } from "./plugin.mjs";
|
|
3
|
+
import { defu as defu$1 } from "defu";
|
|
4
|
+
import { codegen } from "@graphql-codegen/core";
|
|
5
|
+
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
6
|
+
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
7
|
+
import { parse } from "graphql";
|
|
8
|
+
import * as typescriptResolversPlugin from "@graphql-codegen/typescript-resolvers";
|
|
9
|
+
|
|
10
|
+
//#region src/core/codegen/server.ts
|
|
11
|
+
/**
|
|
12
|
+
* Default server codegen configuration
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_SERVER_CODEGEN_CONFIG = {
|
|
15
|
+
scalars: DEFAULT_GRAPHQL_SCALARS,
|
|
16
|
+
defaultScalarType: "unknown",
|
|
17
|
+
defaultMapper: `ResolverReturnType<{T}>`,
|
|
18
|
+
contextType: "nitro/h3#H3Event",
|
|
19
|
+
maybeValue: "T | null | undefined",
|
|
20
|
+
inputMaybeValue: "T | undefined",
|
|
21
|
+
declarationKind: "interface",
|
|
22
|
+
enumsAsTypes: true
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Generate server-side GraphQL types
|
|
26
|
+
* Pure function that generates TypeScript types from a GraphQL schema
|
|
27
|
+
*/
|
|
28
|
+
async function generateServerTypesCore(input) {
|
|
29
|
+
const { framework, schema, config = {}, federationEnabled = false, outputPath } = input;
|
|
30
|
+
const mergedConfig = defu$1({
|
|
31
|
+
...DEFAULT_SERVER_CODEGEN_CONFIG,
|
|
32
|
+
...federationEnabled && { federation: true }
|
|
33
|
+
}, config);
|
|
34
|
+
const schemaString = printSchemaWithDirectives(schema);
|
|
35
|
+
return {
|
|
36
|
+
types: await codegen({
|
|
37
|
+
filename: outputPath || "types.generated.ts",
|
|
38
|
+
schema: parse(schemaString),
|
|
39
|
+
documents: [],
|
|
40
|
+
config: mergedConfig,
|
|
41
|
+
plugins: [
|
|
42
|
+
{ imports: {} },
|
|
43
|
+
{ pluginContent: {} },
|
|
44
|
+
{ typescript: {} },
|
|
45
|
+
{ typescriptResolvers: {} }
|
|
46
|
+
],
|
|
47
|
+
pluginMap: {
|
|
48
|
+
pluginContent: { plugin: pluginContent },
|
|
49
|
+
imports: { plugin: () => {
|
|
50
|
+
return {
|
|
51
|
+
prepend: [
|
|
52
|
+
`import schemas from '#graphql/schema'`,
|
|
53
|
+
`import type { StandardSchemaV1 } from 'nitro-graphql/types'`,
|
|
54
|
+
generateServerTypeHelpers(framework),
|
|
55
|
+
""
|
|
56
|
+
],
|
|
57
|
+
content: ""
|
|
58
|
+
};
|
|
59
|
+
} },
|
|
60
|
+
typescript: typescriptPlugin,
|
|
61
|
+
typescriptResolvers: typescriptResolversPlugin
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
schemaString
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate server type helper code
|
|
69
|
+
*/
|
|
70
|
+
function generateServerTypeHelpers(framework) {
|
|
71
|
+
return `
|
|
72
|
+
export interface NPMConfig {
|
|
73
|
+
framework: '${framework || "graphql-yoga"}';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type SchemaType = Partial<Record<Partial<keyof ResolversTypes>, StandardSchemaV1>>
|
|
77
|
+
|
|
78
|
+
// Check if schemas is empty object, return never if so
|
|
79
|
+
type SafeSchemaKeys<T> = T extends Record<PropertyKey, never>
|
|
80
|
+
? never
|
|
81
|
+
: keyof T extends string | number | symbol
|
|
82
|
+
? keyof T extends never
|
|
83
|
+
? never
|
|
84
|
+
: keyof T
|
|
85
|
+
: never;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
type SchemaKeys = SafeSchemaKeys<typeof schemas>;
|
|
89
|
+
|
|
90
|
+
type InferInput<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferInput<T> : unknown;
|
|
91
|
+
type InferOutput<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : unknown;
|
|
92
|
+
|
|
93
|
+
type InferInputFromSchema<T extends SchemaKeys> = InferInput<(typeof schemas)[T]>;
|
|
94
|
+
type InferOutputFromSchema<T extends SchemaKeys> = InferOutput<(typeof schemas)[T]>;
|
|
95
|
+
|
|
96
|
+
type Primitive =
|
|
97
|
+
| null
|
|
98
|
+
| undefined
|
|
99
|
+
| string
|
|
100
|
+
| number
|
|
101
|
+
| boolean
|
|
102
|
+
| symbol
|
|
103
|
+
| bigint;
|
|
104
|
+
|
|
105
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
type ResolverReturnType<T> = T extends BuiltIns
|
|
109
|
+
? T
|
|
110
|
+
: T extends (...args: any[]) => unknown
|
|
111
|
+
? T | undefined
|
|
112
|
+
: T extends object
|
|
113
|
+
? T extends Array<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
114
|
+
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
115
|
+
? Array<ResolverReturnType<ItemType>>
|
|
116
|
+
: ResolverReturnTypeObject<T> // Tuples behave properly
|
|
117
|
+
: ResolverReturnTypeObject<T>
|
|
118
|
+
: unknown;
|
|
119
|
+
|
|
120
|
+
type ResolverReturnTypeObject<T extends object> =
|
|
121
|
+
T extends { __typename?: infer TTypename }
|
|
122
|
+
? TTypename extends SchemaKeys
|
|
123
|
+
? InferOutputFromSchema<TTypename>
|
|
124
|
+
: { [K in keyof T]: ResolverReturnType<T[K]> }
|
|
125
|
+
: { [K in keyof T]: ResolverReturnType<T[K]> };
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generate types from schema (simplified version for direct use)
|
|
130
|
+
* @deprecated Use generateServerTypesCore instead
|
|
131
|
+
*/
|
|
132
|
+
async function generateTypes(framework, schema, config = {}, outputPath) {
|
|
133
|
+
return (await generateServerTypesCore({
|
|
134
|
+
framework,
|
|
135
|
+
schema,
|
|
136
|
+
config: config.codegen?.server,
|
|
137
|
+
federationEnabled: config.federation?.enabled,
|
|
138
|
+
outputPath
|
|
139
|
+
})).types;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes };
|
|
@@ -4,7 +4,7 @@ import { basename } from "pathe";
|
|
|
4
4
|
import { parse } from "graphql";
|
|
5
5
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
6
6
|
|
|
7
|
-
//#region src/codegen/validation.ts
|
|
7
|
+
//#region src/core/codegen/validation.ts
|
|
8
8
|
/**
|
|
9
9
|
* GraphQL schema validation utilities
|
|
10
10
|
* Validates schemas for duplicate type definitions and conflicts
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CoreConfig, CoreContext, CoreGraphQLOptions, CoreLogger } from "./types/config.mjs";
|
|
2
|
+
import { ScanContext } from "./types/scanning.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/config.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a CoreConfig
|
|
8
|
+
*/
|
|
9
|
+
interface CreateCoreConfigOptions {
|
|
10
|
+
/** Root directory of the project */
|
|
11
|
+
rootDir: string;
|
|
12
|
+
/** Build directory (optional, defaults based on framework) */
|
|
13
|
+
buildDir?: string;
|
|
14
|
+
/** Server GraphQL directory (optional) */
|
|
15
|
+
serverDir?: string;
|
|
16
|
+
/** Client GraphQL directory (optional) */
|
|
17
|
+
clientDir?: string;
|
|
18
|
+
/** Whether running in Nuxt context */
|
|
19
|
+
isNuxt?: boolean;
|
|
20
|
+
/** Whether running in development mode */
|
|
21
|
+
isDev?: boolean;
|
|
22
|
+
/** GraphQL options */
|
|
23
|
+
graphqlOptions?: CoreGraphQLOptions;
|
|
24
|
+
/** Custom logger */
|
|
25
|
+
logger?: CoreLogger;
|
|
26
|
+
/** Patterns to ignore */
|
|
27
|
+
ignorePatterns?: string[];
|
|
28
|
+
/** Layer server directories */
|
|
29
|
+
layerServerDirs?: string[];
|
|
30
|
+
/** Layer app directories */
|
|
31
|
+
layerAppDirs?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a CoreConfig with sensible defaults
|
|
35
|
+
*/
|
|
36
|
+
declare function createCoreConfig(options: CreateCoreConfigOptions): CoreConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Create a CoreContext from CoreConfig
|
|
39
|
+
*/
|
|
40
|
+
declare function createCoreContext(config: CoreConfig): CoreContext;
|
|
41
|
+
/**
|
|
42
|
+
* Create a ScanContext from CoreConfig
|
|
43
|
+
*/
|
|
44
|
+
declare function createScanContext(config: CoreConfig): ScanContext;
|
|
45
|
+
/**
|
|
46
|
+
* Merge GraphQL options with defaults
|
|
47
|
+
*/
|
|
48
|
+
declare function mergeGraphQLOptions(options: Partial<CoreGraphQLOptions>, defaults?: Partial<CoreGraphQLOptions>): CoreGraphQLOptions;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CreateCoreConfigOptions, createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_CLIENT_GRAPHQL, DIR_SERVER_GRAPHQL, GRAPHQL_FRAMEWORK_YOGA } from "./constants.mjs";
|
|
2
|
+
import { createLogger } from "./utils/logger.mjs";
|
|
3
|
+
import { relative, resolve } from "pathe";
|
|
4
|
+
|
|
5
|
+
//#region src/core/config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Create a CoreConfig with sensible defaults
|
|
8
|
+
*/
|
|
9
|
+
function createCoreConfig(options) {
|
|
10
|
+
const { rootDir, isNuxt = false, isDev = process.env.NODE_ENV !== "production", graphqlOptions = {}, logger = createLogger(), ignorePatterns = [], layerServerDirs = [], layerAppDirs = [] } = options;
|
|
11
|
+
const framework = graphqlOptions.framework || GRAPHQL_FRAMEWORK_YOGA;
|
|
12
|
+
const buildDir = options.buildDir || resolve(rootDir, isNuxt ? ".nuxt" : DIR_BUILD_NITRO);
|
|
13
|
+
return {
|
|
14
|
+
rootDir,
|
|
15
|
+
buildDir,
|
|
16
|
+
serverDir: options.serverDir || resolve(rootDir, DIR_SERVER_GRAPHQL),
|
|
17
|
+
clientDir: options.clientDir || resolve(rootDir, isNuxt ? DIR_APP_GRAPHQL : DIR_CLIENT_GRAPHQL),
|
|
18
|
+
typesDir: resolve(buildDir, "types"),
|
|
19
|
+
framework,
|
|
20
|
+
isNuxt,
|
|
21
|
+
isDev,
|
|
22
|
+
graphqlOptions,
|
|
23
|
+
logger,
|
|
24
|
+
ignorePatterns,
|
|
25
|
+
layerServerDirs,
|
|
26
|
+
layerAppDirs
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a CoreContext from CoreConfig
|
|
31
|
+
*/
|
|
32
|
+
function createCoreContext(config) {
|
|
33
|
+
return {
|
|
34
|
+
config,
|
|
35
|
+
graphqlBuildDir: resolve(config.buildDir, "graphql"),
|
|
36
|
+
watchDirs: [],
|
|
37
|
+
dir: {
|
|
38
|
+
build: relative(config.rootDir, config.buildDir),
|
|
39
|
+
client: relative(config.rootDir, config.clientDir),
|
|
40
|
+
server: relative(config.rootDir, config.serverDir)
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a ScanContext from CoreConfig
|
|
46
|
+
*/
|
|
47
|
+
function createScanContext(config) {
|
|
48
|
+
return {
|
|
49
|
+
rootDir: config.rootDir,
|
|
50
|
+
serverDir: config.serverDir,
|
|
51
|
+
clientDir: config.clientDir,
|
|
52
|
+
ignorePatterns: config.ignorePatterns,
|
|
53
|
+
isDev: config.isDev,
|
|
54
|
+
logger: config.logger,
|
|
55
|
+
layerServerDirs: config.layerServerDirs,
|
|
56
|
+
layerAppDirs: config.layerAppDirs
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Merge GraphQL options with defaults
|
|
61
|
+
*/
|
|
62
|
+
function mergeGraphQLOptions(options, defaults = {}) {
|
|
63
|
+
return {
|
|
64
|
+
...defaults,
|
|
65
|
+
...options,
|
|
66
|
+
codegen: {
|
|
67
|
+
...defaults.codegen,
|
|
68
|
+
...options.codegen
|
|
69
|
+
},
|
|
70
|
+
security: {
|
|
71
|
+
...defaults.security,
|
|
72
|
+
...options.security
|
|
73
|
+
},
|
|
74
|
+
paths: {
|
|
75
|
+
...defaults.paths,
|
|
76
|
+
...options.paths
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//#region src/core/constants.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Constants and magic strings used throughout nitro-graphql core
|
|
4
|
+
* Centralizing these values prevents typos and makes refactoring easier
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default scalar type mappings for GraphQL codegen
|
|
8
|
+
* These scalars are commonly used and have proper TypeScript type mappings
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_GRAPHQL_SCALARS: {
|
|
11
|
+
readonly DateTime: string;
|
|
12
|
+
readonly DateTimeISO: string;
|
|
13
|
+
readonly UUID: string;
|
|
14
|
+
readonly JSON: string;
|
|
15
|
+
readonly JSONObject: string;
|
|
16
|
+
readonly NonEmptyString: string;
|
|
17
|
+
readonly Currency: string;
|
|
18
|
+
readonly File: {
|
|
19
|
+
readonly input: "File";
|
|
20
|
+
readonly output: "File";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* GraphQL schema file extensions
|
|
25
|
+
*/
|
|
26
|
+
declare const GRAPHQL_EXTENSIONS: readonly [".graphql", ".gql"];
|
|
27
|
+
/**
|
|
28
|
+
* Resolver file extensions
|
|
29
|
+
*/
|
|
30
|
+
declare const RESOLVER_EXTENSIONS: readonly [".resolver.ts", ".resolver.js"];
|
|
31
|
+
/**
|
|
32
|
+
* Directive file extensions
|
|
33
|
+
*/
|
|
34
|
+
declare const DIRECTIVE_EXTENSIONS: readonly [".directive.ts", ".directive.js"];
|
|
35
|
+
/**
|
|
36
|
+
* Combined pattern for glob scanning
|
|
37
|
+
*/
|
|
38
|
+
declare const GLOB_SCAN_PATTERN: "**/*.{graphql,gql,js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
39
|
+
/**
|
|
40
|
+
* GraphQL file pattern for glob
|
|
41
|
+
*/
|
|
42
|
+
declare const GRAPHQL_GLOB_PATTERN: "**/*.graphql";
|
|
43
|
+
/**
|
|
44
|
+
* Resolver file pattern for glob
|
|
45
|
+
*/
|
|
46
|
+
declare const RESOLVER_GLOB_PATTERN: "**/*.resolver.{ts,js}";
|
|
47
|
+
/**
|
|
48
|
+
* Directive file pattern for glob
|
|
49
|
+
*/
|
|
50
|
+
declare const DIRECTIVE_GLOB_PATTERN: "**/*.directive.{ts,js}";
|
|
51
|
+
/**
|
|
52
|
+
* Framework names
|
|
53
|
+
*/
|
|
54
|
+
declare const FRAMEWORK_NUXT: "nuxt";
|
|
55
|
+
declare const FRAMEWORK_NITRO: "nitro";
|
|
56
|
+
declare const FRAMEWORK_STANDALONE: "standalone";
|
|
57
|
+
/**
|
|
58
|
+
* GraphQL server framework identifiers
|
|
59
|
+
*/
|
|
60
|
+
declare const GRAPHQL_FRAMEWORK_YOGA: "graphql-yoga";
|
|
61
|
+
declare const GRAPHQL_FRAMEWORK_APOLLO: "apollo-server";
|
|
62
|
+
type Framework = typeof FRAMEWORK_NUXT | typeof FRAMEWORK_NITRO | typeof FRAMEWORK_STANDALONE;
|
|
63
|
+
type GraphQLFramework = typeof GRAPHQL_FRAMEWORK_YOGA | typeof GRAPHQL_FRAMEWORK_APOLLO;
|
|
64
|
+
/**
|
|
65
|
+
* Default directory names for GraphQL files
|
|
66
|
+
*/
|
|
67
|
+
declare const DIR_SERVER_GRAPHQL: "server/graphql";
|
|
68
|
+
declare const DIR_ROUTES_GRAPHQL: "routes/graphql";
|
|
69
|
+
declare const DIR_APP_GRAPHQL: "app/graphql";
|
|
70
|
+
declare const DIR_CLIENT_GRAPHQL: "graphql";
|
|
71
|
+
declare const DIR_EXTERNAL: "external";
|
|
72
|
+
/**
|
|
73
|
+
* Windows-compatible server GraphQL directory
|
|
74
|
+
*/
|
|
75
|
+
declare const DIR_SERVER_GRAPHQL_WIN: "server\\graphql";
|
|
76
|
+
/**
|
|
77
|
+
* Build directory names
|
|
78
|
+
*/
|
|
79
|
+
declare const DIR_BUILD_NITRO: ".nitro";
|
|
80
|
+
declare const DIR_BUILD_NUXT: ".nuxt";
|
|
81
|
+
/**
|
|
82
|
+
* Default GraphQL endpoint paths
|
|
83
|
+
*/
|
|
84
|
+
declare const ENDPOINT_GRAPHQL: "/api/graphql";
|
|
85
|
+
declare const ENDPOINT_HEALTH: "/api/graphql/health";
|
|
86
|
+
declare const ENDPOINT_DEBUG: "/_nitro/graphql/debug";
|
|
87
|
+
/**
|
|
88
|
+
* Configuration and scaffold file names
|
|
89
|
+
*/
|
|
90
|
+
declare const FILE_GRAPHQL_CONFIG: "graphql.config.ts";
|
|
91
|
+
declare const FILE_SCHEMA_GRAPHQL: "schema.graphql";
|
|
92
|
+
declare const FILE_SCHEMA_TS: "schema.ts";
|
|
93
|
+
declare const FILE_CONFIG_TS: "config.ts";
|
|
94
|
+
declare const FILE_CONTEXT_DTS: "context.d.ts";
|
|
95
|
+
declare const FILE_CONTEXT_TS: "context.ts";
|
|
96
|
+
declare const FILE_INDEX_TS: "index.ts";
|
|
97
|
+
declare const FILE_OFETCH_TS: "ofetch.ts";
|
|
98
|
+
declare const FILE_SDK_TS: "sdk.ts";
|
|
99
|
+
declare const FILE_DIRECTIVES_GRAPHQL: "_directives.graphql";
|
|
100
|
+
/**
|
|
101
|
+
* Generated type definition file names
|
|
102
|
+
*/
|
|
103
|
+
declare const FILE_SERVER_TYPES: "nitro-graphql-server.d.ts";
|
|
104
|
+
declare const FILE_CLIENT_TYPES: "nitro-graphql-client.d.ts";
|
|
105
|
+
declare const FILE_GRAPHQL_DTS: "graphql.d.ts";
|
|
106
|
+
/**
|
|
107
|
+
* Generated type file name patterns with placeholders
|
|
108
|
+
*/
|
|
109
|
+
declare const PATTERN_CLIENT_EXTERNAL_TYPES: "nitro-graphql-client-{serviceName}.d.ts";
|
|
110
|
+
/**
|
|
111
|
+
* Rollup/Rolldown chunk output paths
|
|
112
|
+
*/
|
|
113
|
+
declare const CHUNK_PATH_GRAPHQL: "chunks/graphql/[name].mjs";
|
|
114
|
+
declare const CHUNK_PATH_UNKNOWN: "chunks/_/[name].mjs";
|
|
115
|
+
/**
|
|
116
|
+
* Default chunk names
|
|
117
|
+
*/
|
|
118
|
+
declare const CHUNK_NAME_SCHEMAS: "schemas";
|
|
119
|
+
declare const CHUNK_NAME_RESOLVERS: "resolvers";
|
|
120
|
+
/**
|
|
121
|
+
* Valid define function names for resolver exports
|
|
122
|
+
*/
|
|
123
|
+
declare const DEFINE_FUNCTIONS: readonly ["defineResolver", "defineQuery", "defineMutation", "defineField", "defineSubscription", "defineDirective"];
|
|
124
|
+
declare const DEFINE_RESOLVER: "defineResolver";
|
|
125
|
+
declare const DEFINE_QUERY: "defineQuery";
|
|
126
|
+
declare const DEFINE_MUTATION: "defineMutation";
|
|
127
|
+
declare const DEFINE_FIELD: "defineField";
|
|
128
|
+
declare const DEFINE_SUBSCRIPTION: "defineSubscription";
|
|
129
|
+
declare const DEFINE_DIRECTIVE: "defineDirective";
|
|
130
|
+
declare const DEFINE_GRAPHQL_CONFIG: "defineGraphQLConfig";
|
|
131
|
+
declare const DEFINE_SCHEMA: "defineSchema";
|
|
132
|
+
type DefineFunction = typeof DEFINE_FUNCTIONS[number];
|
|
133
|
+
/**
|
|
134
|
+
* Built-in GraphQL scalar types (should not be flagged as duplicates)
|
|
135
|
+
*/
|
|
136
|
+
declare const BUILTIN_SCALARS: readonly ["String", "Int", "Float", "Boolean", "ID", "DateTime", "JSON"];
|
|
137
|
+
/**
|
|
138
|
+
* Codegen parser dependencies (always external)
|
|
139
|
+
*/
|
|
140
|
+
declare const CODEGEN_EXTERNALS: readonly ["oxc-parser", "@oxc-parser"];
|
|
141
|
+
/**
|
|
142
|
+
* Apollo Federation dependencies (external when federation disabled)
|
|
143
|
+
*/
|
|
144
|
+
declare const FEDERATION_EXTERNALS: readonly ["@apollo/subgraph", "@apollo/federation-internals", "@apollo/cache-control-types"];
|
|
145
|
+
/**
|
|
146
|
+
* Supported HTTP methods for GraphQL endpoints
|
|
147
|
+
*/
|
|
148
|
+
declare const GRAPHQL_HTTP_METHODS: readonly ["GET", "POST", "OPTIONS"];
|
|
149
|
+
/**
|
|
150
|
+
* Default paths for type generation (relative to buildDir)
|
|
151
|
+
*/
|
|
152
|
+
declare const DEFAULT_SERVER_TYPES_PATH: ".graphql/nitro-graphql-server.d.ts";
|
|
153
|
+
declare const DEFAULT_CLIENT_TYPES_PATH: ".graphql/nitro-graphql-client.d.ts";
|
|
154
|
+
/**
|
|
155
|
+
* Valid resolver export types detected from AST parsing
|
|
156
|
+
*/
|
|
157
|
+
declare const RESOLVER_TYPE_QUERY: "query";
|
|
158
|
+
declare const RESOLVER_TYPE_MUTATION: "mutation";
|
|
159
|
+
declare const RESOLVER_TYPE_RESOLVER: "resolver";
|
|
160
|
+
declare const RESOLVER_TYPE_TYPE: "type";
|
|
161
|
+
declare const RESOLVER_TYPE_SUBSCRIPTION: "subscription";
|
|
162
|
+
declare const RESOLVER_TYPE_DIRECTIVE: "directive";
|
|
163
|
+
type ResolverType = typeof RESOLVER_TYPE_QUERY | typeof RESOLVER_TYPE_MUTATION | typeof RESOLVER_TYPE_RESOLVER | typeof RESOLVER_TYPE_TYPE | typeof RESOLVER_TYPE_SUBSCRIPTION | typeof RESOLVER_TYPE_DIRECTIVE;
|
|
164
|
+
/**
|
|
165
|
+
* Placeholder strings used in path resolution
|
|
166
|
+
*/
|
|
167
|
+
declare const PLACEHOLDER_SERVICE_NAME: "{serviceName}";
|
|
168
|
+
declare const PLACEHOLDER_BUILD_DIR: "{buildDir}";
|
|
169
|
+
declare const PLACEHOLDER_ROOT_DIR: "{rootDir}";
|
|
170
|
+
declare const PLACEHOLDER_FRAMEWORK: "{framework}";
|
|
171
|
+
declare const PLACEHOLDER_TYPES_DIR: "{typesDir}";
|
|
172
|
+
declare const PLACEHOLDER_SERVER_GRAPHQL: "{serverGraphql}";
|
|
173
|
+
declare const PLACEHOLDER_CLIENT_GRAPHQL: "{clientGraphql}";
|
|
174
|
+
/**
|
|
175
|
+
* Logger tag for nitro-graphql module
|
|
176
|
+
*/
|
|
177
|
+
declare const LOG_TAG: "nitro-graphql";
|
|
178
|
+
/**
|
|
179
|
+
* HTTP status codes for error handling
|
|
180
|
+
*/
|
|
181
|
+
declare const HTTP_STATUS_BAD_REQUEST: 400;
|
|
182
|
+
declare const HTTP_STATUS_INTERNAL_ERROR: 500;
|
|
183
|
+
/**
|
|
184
|
+
* Default service directory name for main service
|
|
185
|
+
*/
|
|
186
|
+
declare const SERVICE_DEFAULT: "default";
|
|
187
|
+
//#endregion
|
|
188
|
+
export { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DefineFunction, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, Framework, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_GRAPHQL, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_GRAPHQL, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, ResolverType, SERVICE_DEFAULT };
|