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,2 +1,2 @@
|
|
|
1
|
-
import { DebugInfo,
|
|
2
|
-
export { DebugInfo,
|
|
1
|
+
import { DebugInfo, generateDebugHtml } from "./template.mjs";
|
|
2
|
+
export { DebugInfo, generateDebugHtml };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { escapeHtml, generateDebugHtml };
|
|
1
|
+
import { generateDebugHtml } from "./template.mjs";
|
|
2
|
+
export { generateDebugHtml };
|
|
@@ -38,10 +38,6 @@ interface DebugInfo {
|
|
|
38
38
|
};
|
|
39
39
|
virtualModules: Record<string, string>;
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Escape HTML special characters
|
|
43
|
-
*/
|
|
44
|
-
declare function escapeHtml(text: string): string;
|
|
45
41
|
/**
|
|
46
42
|
* Generate the HTML dashboard for the debug endpoint
|
|
47
43
|
*
|
|
@@ -49,4 +45,4 @@ declare function escapeHtml(text: string): string;
|
|
|
49
45
|
*/
|
|
50
46
|
declare function generateDebugHtml(debugInfo: DebugInfo): string;
|
|
51
47
|
//#endregion
|
|
52
|
-
export { DebugInfo,
|
|
48
|
+
export { DebugInfo, generateDebugHtml };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
//#region src/core/debug/template.ts
|
|
2
|
+
const HTML_SPECIAL_CHARS_RE = /[&<>"']/g;
|
|
3
|
+
const DOUBLE_QUOTE_RE = /"/g;
|
|
2
4
|
/**
|
|
3
5
|
* Escape HTML special characters
|
|
4
6
|
*/
|
|
@@ -10,7 +12,7 @@ function escapeHtml(text) {
|
|
|
10
12
|
"\"": """,
|
|
11
13
|
"'": "'"
|
|
12
14
|
};
|
|
13
|
-
return text.replace(
|
|
15
|
+
return text.replace(HTML_SPECIAL_CHARS_RE, (m) => map[m] || m);
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Type color configuration for resolver exports display
|
|
@@ -160,7 +162,7 @@ function renderVirtualModules(virtualModules) {
|
|
|
160
162
|
</div>
|
|
161
163
|
<button
|
|
162
164
|
onclick="event.stopPropagation(); navigator.clipboard.writeText(this.getAttribute('data-code')); this.textContent = '✓ Copied!'; setTimeout(() => this.textContent = 'Copy', 1000)"
|
|
163
|
-
data-code="${escapeHtml(code).replace(
|
|
165
|
+
data-code="${escapeHtml(code).replace(DOUBLE_QUOTE_RE, """)}"
|
|
164
166
|
class="text-xs px-3 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded border border-slate-600/50 transition-colors"
|
|
165
167
|
>
|
|
166
168
|
Copy
|
|
@@ -378,6 +380,5 @@ function generateDebugHtml(debugInfo) {
|
|
|
378
380
|
</body>
|
|
379
381
|
</html>`;
|
|
380
382
|
}
|
|
381
|
-
|
|
382
383
|
//#endregion
|
|
383
|
-
export {
|
|
384
|
+
export { generateDebugHtml };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource } from "./loader.mjs";
|
|
2
|
-
|
|
3
|
-
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|
|
2
|
+
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|
|
@@ -25,7 +25,6 @@ interface ExtendScanResult {
|
|
|
25
25
|
declare function isLocalDirSource(source: unknown): source is LocalDirExtendSource;
|
|
26
26
|
/**
|
|
27
27
|
* Resolve extend directories for file watching
|
|
28
|
-
* Returns directories that should be watched for changes
|
|
29
28
|
*/
|
|
30
29
|
declare function resolveExtendDirs(extend: Array<string | object> | undefined, rootDir: string): Promise<string[]>;
|
|
31
30
|
/**
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { GRAPHQL_GLOB_PATTERN, RESOLVER_GLOB_PATTERN } from "../constants.mjs";
|
|
1
|
+
import { DEFAULT_IGNORE_PATTERNS, GRAPHQL_GLOB_PATTERN, RESOLVER_GLOB_PATTERN } from "../constants.mjs";
|
|
2
2
|
import { isLocalPath, loadPackageConfig, resolvePackageFiles } from "../manifest.mjs";
|
|
3
3
|
import { parseSingleFile } from "../scanning/ast-scanner.mjs";
|
|
4
4
|
import { parseDirectiveCall } from "../scanning/directives.mjs";
|
|
5
5
|
import { parseResolverCall } from "../scanning/resolvers.mjs";
|
|
6
6
|
import { existsSync_ } from "../utils/runtime.mjs";
|
|
7
|
+
import consola from "consola";
|
|
7
8
|
import { dirname, resolve } from "pathe";
|
|
8
9
|
import { glob } from "tinyglobby";
|
|
9
|
-
|
|
10
10
|
//#region src/core/extend/loader.ts
|
|
11
|
+
function emptyResult() {
|
|
12
|
+
return {
|
|
13
|
+
schemas: [],
|
|
14
|
+
resolvers: [],
|
|
15
|
+
directives: [],
|
|
16
|
+
documents: []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
11
19
|
/**
|
|
12
20
|
* Check if source is a LocalDirExtendSource
|
|
13
21
|
*/
|
|
@@ -16,7 +24,6 @@ function isLocalDirSource(source) {
|
|
|
16
24
|
}
|
|
17
25
|
/**
|
|
18
26
|
* Resolve extend directories for file watching
|
|
19
|
-
* Returns directories that should be watched for changes
|
|
20
27
|
*/
|
|
21
28
|
async function resolveExtendDirs(extend, rootDir) {
|
|
22
29
|
if (!extend || !Array.isArray(extend) || extend.length === 0) return [];
|
|
@@ -57,29 +64,14 @@ async function scanExtendSource(source, rootDir) {
|
|
|
57
64
|
if (typeof source === "string") return scanPackageSource(source, rootDir);
|
|
58
65
|
if (isLocalDirSource(source)) return scanLocalDirSource(source);
|
|
59
66
|
if (source && typeof source === "object") return scanExplicitPaths(source, rootDir);
|
|
60
|
-
return
|
|
61
|
-
schemas: [],
|
|
62
|
-
resolvers: [],
|
|
63
|
-
directives: [],
|
|
64
|
-
documents: []
|
|
65
|
-
};
|
|
67
|
+
return emptyResult();
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* Scan all extend sources and merge results
|
|
69
71
|
*/
|
|
70
72
|
async function scanAllExtendSources(extend, rootDir) {
|
|
71
|
-
if (!extend || !Array.isArray(extend) || extend.length === 0) return
|
|
72
|
-
|
|
73
|
-
resolvers: [],
|
|
74
|
-
directives: [],
|
|
75
|
-
documents: []
|
|
76
|
-
};
|
|
77
|
-
const merged = {
|
|
78
|
-
schemas: [],
|
|
79
|
-
resolvers: [],
|
|
80
|
-
directives: [],
|
|
81
|
-
documents: []
|
|
82
|
-
};
|
|
73
|
+
if (!extend || !Array.isArray(extend) || extend.length === 0) return emptyResult();
|
|
74
|
+
const merged = emptyResult();
|
|
83
75
|
for (const source of extend) {
|
|
84
76
|
const result = await scanExtendSource(source, rootDir);
|
|
85
77
|
merged.schemas.push(...result.schemas);
|
|
@@ -91,74 +83,62 @@ async function scanAllExtendSources(extend, rootDir) {
|
|
|
91
83
|
}
|
|
92
84
|
return merged;
|
|
93
85
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
async function parseResolverFiles(paths) {
|
|
87
|
+
const results = [];
|
|
88
|
+
for (const filePath of paths) {
|
|
89
|
+
const parsed = await parseSingleFile(filePath, parseResolverCall);
|
|
90
|
+
if (parsed?.imports.length) results.push(parsed);
|
|
91
|
+
}
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
async function parseDirectiveFiles(paths) {
|
|
95
|
+
const results = [];
|
|
96
|
+
for (const filePath of paths) {
|
|
97
|
+
const parsed = await parseSingleFile(filePath, parseDirectiveCall);
|
|
98
|
+
if (parsed?.imports.length) results.push(parsed);
|
|
99
|
+
}
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
97
102
|
async function scanPackageSource(packageName, rootDir) {
|
|
98
103
|
const pkg = await loadPackageConfig(packageName, rootDir);
|
|
99
|
-
if (!pkg)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const directives = [];
|
|
103
|
-
for (const resolverPath of files.resolvers) {
|
|
104
|
-
const parsed = await parseSingleFile(resolverPath, parseResolverCall);
|
|
105
|
-
if (parsed?.imports.length) resolvers.push(parsed);
|
|
106
|
-
}
|
|
107
|
-
for (const directivePath of files.directives) {
|
|
108
|
-
const parsed = await parseSingleFile(directivePath, parseDirectiveCall);
|
|
109
|
-
if (parsed?.imports.length) directives.push(parsed);
|
|
104
|
+
if (!pkg) {
|
|
105
|
+
consola.warn(`[nitro-graphql] Config not found for "${packageName}". Skipping. Create a nitro-graphql.config.ts file in the package root.`);
|
|
106
|
+
return emptyResult();
|
|
110
107
|
}
|
|
108
|
+
const files = await resolvePackageFiles(pkg);
|
|
111
109
|
return {
|
|
112
110
|
schemas: files.schemas,
|
|
113
|
-
resolvers,
|
|
114
|
-
directives,
|
|
111
|
+
resolvers: await parseResolverFiles(files.resolvers),
|
|
112
|
+
directives: await parseDirectiveFiles(files.directives),
|
|
115
113
|
documents: files.documents,
|
|
116
114
|
configPath: files.configPath,
|
|
117
115
|
schemaPath: files.schemaPath
|
|
118
116
|
};
|
|
119
117
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Scan a local directory for GraphQL files
|
|
122
|
-
*/
|
|
123
118
|
async function scanLocalDirSource(source) {
|
|
124
|
-
const result =
|
|
125
|
-
|
|
126
|
-
resolvers: [],
|
|
127
|
-
directives: [],
|
|
128
|
-
documents: []
|
|
129
|
-
};
|
|
130
|
-
const ignorePatterns = [
|
|
131
|
-
"**/node_modules/**",
|
|
132
|
-
"**/.git/**",
|
|
133
|
-
"**/.output/**",
|
|
134
|
-
"**/.nitro/**",
|
|
135
|
-
"**/.nuxt/**"
|
|
136
|
-
];
|
|
119
|
+
const result = emptyResult();
|
|
120
|
+
const ignorePatterns = [...DEFAULT_IGNORE_PATTERNS];
|
|
137
121
|
if (source.serverDir && existsSync_(source.serverDir)) {
|
|
138
|
-
const schemaFiles = await
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
122
|
+
const [schemaFiles, resolverFiles, directiveFiles] = await Promise.all([
|
|
123
|
+
glob(GRAPHQL_GLOB_PATTERN, {
|
|
124
|
+
cwd: source.serverDir,
|
|
125
|
+
absolute: true,
|
|
126
|
+
ignore: ignorePatterns
|
|
127
|
+
}),
|
|
128
|
+
glob(RESOLVER_GLOB_PATTERN, {
|
|
129
|
+
cwd: source.serverDir,
|
|
130
|
+
absolute: true,
|
|
131
|
+
ignore: ignorePatterns
|
|
132
|
+
}),
|
|
133
|
+
glob("**/*.directive.ts", {
|
|
134
|
+
cwd: source.serverDir,
|
|
135
|
+
absolute: true,
|
|
136
|
+
ignore: ignorePatterns
|
|
137
|
+
})
|
|
138
|
+
]);
|
|
143
139
|
result.schemas.push(...schemaFiles);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
absolute: true,
|
|
147
|
-
ignore: ignorePatterns
|
|
148
|
-
});
|
|
149
|
-
for (const resolverPath of resolverFiles) {
|
|
150
|
-
const parsed = await parseSingleFile(resolverPath, parseResolverCall);
|
|
151
|
-
if (parsed?.imports.length) result.resolvers.push(parsed);
|
|
152
|
-
}
|
|
153
|
-
const directiveFiles = await glob("**/*.directive.ts", {
|
|
154
|
-
cwd: source.serverDir,
|
|
155
|
-
absolute: true,
|
|
156
|
-
ignore: ignorePatterns
|
|
157
|
-
});
|
|
158
|
-
for (const directivePath of directiveFiles) {
|
|
159
|
-
const parsed = await parseSingleFile(directivePath, parseDirectiveCall);
|
|
160
|
-
if (parsed?.imports.length) result.directives.push(parsed);
|
|
161
|
-
}
|
|
140
|
+
result.resolvers.push(...await parseResolverFiles(resolverFiles));
|
|
141
|
+
result.directives.push(...await parseDirectiveFiles(directiveFiles));
|
|
162
142
|
}
|
|
163
143
|
if (source.clientDir && existsSync_(source.clientDir)) {
|
|
164
144
|
const documentFiles = await glob(GRAPHQL_GLOB_PATTERN, {
|
|
@@ -170,29 +150,17 @@ async function scanLocalDirSource(source) {
|
|
|
170
150
|
}
|
|
171
151
|
return result;
|
|
172
152
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Scan explicit paths (legacy format)
|
|
175
|
-
*/
|
|
176
153
|
async function scanExplicitPaths(source, rootDir) {
|
|
177
|
-
const result =
|
|
178
|
-
schemas: [],
|
|
179
|
-
resolvers: [],
|
|
180
|
-
directives: [],
|
|
181
|
-
documents: []
|
|
182
|
-
};
|
|
154
|
+
const result = emptyResult();
|
|
183
155
|
if (source.schemas) {
|
|
184
156
|
const schemas = Array.isArray(source.schemas) ? source.schemas : [source.schemas];
|
|
185
|
-
|
|
157
|
+
result.schemas.push(...schemas.map((s) => resolve(rootDir, s)));
|
|
186
158
|
}
|
|
187
159
|
if (source.resolvers) {
|
|
188
160
|
const resolvers = Array.isArray(source.resolvers) ? source.resolvers : [source.resolvers];
|
|
189
|
-
|
|
190
|
-
const parsed = await parseSingleFile(resolve(rootDir, resolverPath), parseResolverCall);
|
|
191
|
-
if (parsed?.imports.length) result.resolvers.push(parsed);
|
|
192
|
-
}
|
|
161
|
+
result.resolvers.push(...await parseResolverFiles(resolvers.map((r) => resolve(rootDir, r))));
|
|
193
162
|
}
|
|
194
163
|
return result;
|
|
195
164
|
}
|
|
196
|
-
|
|
197
165
|
//#endregion
|
|
198
|
-
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|
|
166
|
+
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./types/define.mjs";
|
|
1
|
+
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_IGNORE_PATTERNS, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_CLIENT_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLFramework, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN } from "./constants.mjs";
|
|
2
|
+
import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./types/codegen.mjs";
|
|
3
|
+
import { CoreCodegenConfig, CoreConfig, CoreExternalService, CoreFederationConfig, CoreLogger, CoreSecurityConfig } from "./types/config.mjs";
|
|
5
4
|
import { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver } from "./types/scanning.mjs";
|
|
6
|
-
import "./types/
|
|
7
|
-
import {
|
|
5
|
+
import { DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveLocationName, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./types/define.mjs";
|
|
6
|
+
import { StandardSchemaV1 } from "./types/standard-schema.mjs";
|
|
7
|
+
import { BASE_SCHEMA, BASE_SCHEMA_DEF, CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
|
|
8
8
|
import { CoreServerInstance, CoreServerOptions, ServerFactory } from "./server/types.mjs";
|
|
9
|
+
import { DEFAULT_CLIENT_CODEGEN_CONFIG, generateClientTypesCore, generateExternalClientTypesCore } from "./codegen/client.mjs";
|
|
9
10
|
import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
|
|
11
|
+
import { GENERATED_FILE_HEADER } from "./codegen/file-header.mjs";
|
|
12
|
+
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime-generator.mjs";
|
|
10
13
|
import { GraphQLLoadSchemaOptions, GraphQLTypeDefPointer, downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./codegen/schema-loader.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime.mjs";
|
|
14
|
-
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes } from "./codegen/server.mjs";
|
|
14
|
+
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore } from "./codegen/server.mjs";
|
|
15
|
+
import { SubscriptionInfo, extractSubscriptions } from "./codegen/subscription-extractor.mjs";
|
|
15
16
|
import { validateNoDuplicateTypes, validateSchemaFiles } from "./codegen/validation.mjs";
|
|
16
|
-
import "./codegen/
|
|
17
|
-
import { CreateCoreConfigOptions, createCoreConfig,
|
|
17
|
+
import { generateSubscriptionBuilder } from "./codegen/vue-subscription-builder.mjs";
|
|
18
|
+
import { CreateCoreConfigOptions, createCoreConfig, createScanContext } from "./create-config.mjs";
|
|
18
19
|
import { PackageConfig, ResolvedExtend, ResolvedPackage, isLocalPath, loadPackageConfig, resolvePackageFiles } from "./manifest.mjs";
|
|
19
20
|
import { ASTScanConfig, parseSingleFile, scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
20
|
-
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
|
|
21
21
|
import { parseDirectiveCall, scanDirectivesCore } from "./scanning/directives.mjs";
|
|
22
22
|
import { ScanDocumentsOptions, scanDocumentsCore } from "./scanning/documents.mjs";
|
|
23
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/file-scanner.mjs";
|
|
23
24
|
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
24
|
-
import {
|
|
25
|
+
import { scanSchemasCore } from "./scanning/schemas.mjs";
|
|
25
26
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
26
|
-
import "./
|
|
27
|
+
import { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance } from "./server/apollo.mjs";
|
|
27
28
|
import { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript } from "./server/sandbox.mjs";
|
|
28
|
-
import {
|
|
29
|
-
import "./
|
|
30
|
-
import { DirectiveFileRef, DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
|
|
29
|
+
import { apolloSandboxHtml, createYogaServer } from "./server/yoga.mjs";
|
|
30
|
+
import { DirectiveFileRef, ParsedDirective, generateDirectiveSchema, generateDirectiveSchemas, parseDirectivesFromFile } from "./utils/directive-parser.mjs";
|
|
31
31
|
import { MaskErrorOptions, createDefaultMaskError } from "./utils/errors.mjs";
|
|
32
|
-
import { ensureDir,
|
|
32
|
+
import { ensureDir, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
|
|
33
33
|
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
34
|
-
import { createLogger
|
|
34
|
+
import { createLogger } from "./utils/logger.mjs";
|
|
35
35
|
import { OfetchTemplateOptions, generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
36
|
+
import { capitalize } from "./utils/string.mjs";
|
|
36
37
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
37
|
-
export { APOLLO_SANDBOX_CDN, ASTScanConfig, BASE_SCHEMA, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN,
|
|
38
|
+
export { APOLLO_SANDBOX_CDN, APOLLO_USER_FACING_ERROR_CODES, ASTScanConfig, BASE_SCHEMA, BASE_SCHEMA_DEF, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreCodegenConfig, CoreConfig, CoreExternalService, CoreFederationConfig, CoreLogger, CoreSecurityConfig, CoreServerInstance, CoreServerOptions, CreateCoreConfigOptions, CreateMergedSchemaOptions, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_IGNORE_PATTERNS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_CLIENT_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DefineDirectiveConfig, DirectiveArg, DirectiveArgument, DirectiveDefinition, DirectiveFileRef, DirectiveLocationName, DirectiveWrapper, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, ExternalServiceCodegenConfig, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, Flatten, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, GraphQLArgumentType, GraphQLBaseType, GraphQLFramework, GraphQLLoadSchemaOptions, GraphQLScalarType, GraphQLTypeDefPointer, LOG_TAG, MaskErrorOptions, ModuleConfig, OfetchTemplateOptions, PATTERN_CLIENT_EXTERNAL_TYPES, PackageConfig, ParsedDirective, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, ResolvedExtend, ResolvedPackage, ResolverDefinition, ResolverImport, ScanContext, ScanDocumentsOptions, ScanResult, ScannedFile, ScannedResolver, SchemaDefinition, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult, ServerFactory, StandardSchemaV1, SubscriptionInfo, apolloSandboxHtml, buildGraphQLSchema, capitalize, createApolloServerInstance, createCoreConfig, createDefaultMaskError, createLogger, createMergedSchema, createSandboxResponse, createScanContext, createYogaServer, deduplicateFiles, downloadAndSaveSchema, ensureDir, extractPaths, extractSubscriptions, fetchSandboxScript, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, parse, parseDirectiveCall, parseDirectivesFromFile, parseResolverCall, parseSingleFile, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN,
|
|
2
|
-
import { GENERATED_FILE_HEADER
|
|
1
|
+
import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_IGNORE_PATTERNS, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_CLIENT_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN } from "./constants.mjs";
|
|
2
|
+
import { GENERATED_FILE_HEADER } from "./codegen/file-header.mjs";
|
|
3
|
+
import { DEFAULT_CLIENT_CODEGEN_CONFIG, generateClientTypesCore, generateExternalClientTypesCore } from "./codegen/client.mjs";
|
|
3
4
|
import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime-generator.mjs";
|
|
6
|
+
import { ensureDir, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
|
|
5
7
|
import { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./codegen/schema-loader.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore } from "./codegen/server.mjs";
|
|
9
|
+
import { capitalize } from "./utils/string.mjs";
|
|
10
|
+
import { extractSubscriptions } from "./codegen/subscription-extractor.mjs";
|
|
9
11
|
import { validateNoDuplicateTypes, validateSchemaFiles } from "./codegen/validation.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { generateSubscriptionBuilder } from "./codegen/vue-subscription-builder.mjs";
|
|
13
|
+
import { createLogger } from "./utils/logger.mjs";
|
|
14
|
+
import { createCoreConfig, createScanContext } from "./create-config.mjs";
|
|
12
15
|
import { isLocalPath, loadPackageConfig, resolvePackageFiles } from "./manifest.mjs";
|
|
13
|
-
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/
|
|
16
|
+
import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/file-scanner.mjs";
|
|
14
17
|
import { parseSingleFile, scanWithAST } from "./scanning/ast-scanner.mjs";
|
|
18
|
+
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
15
19
|
import { parseDirectiveCall, scanDirectivesCore } from "./scanning/directives.mjs";
|
|
16
20
|
import { scanDocumentsCore } from "./scanning/documents.mjs";
|
|
17
21
|
import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
|
|
18
|
-
import {
|
|
22
|
+
import { scanSchemasCore } from "./scanning/schemas.mjs";
|
|
19
23
|
import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
|
|
20
|
-
import { BASE_SCHEMA, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
|
|
24
|
+
import { BASE_SCHEMA, BASE_SCHEMA_DEF, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
|
|
25
|
+
import { APOLLO_USER_FACING_ERROR_CODES, createApolloServerInstance } from "./server/apollo.mjs";
|
|
21
26
|
import { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript } from "./server/sandbox.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
27
|
+
import { apolloSandboxHtml, createYogaServer } from "./server/yoga.mjs";
|
|
28
|
+
import { generateDirectiveSchema, generateDirectiveSchemas, parseDirectivesFromFile } from "./utils/directive-parser.mjs";
|
|
24
29
|
import { createDefaultMaskError } from "./utils/errors.mjs";
|
|
25
|
-
import { getImportId, relativeWithDot } from "./utils/imports.mjs";
|
|
26
30
|
import { generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
|
|
27
31
|
import { validateExternalServices } from "./validation/external-services.mjs";
|
|
28
|
-
|
|
29
|
-
export { APOLLO_SANDBOX_CDN, BASE_SCHEMA, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, 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, DirectiveParser, 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, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, 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, SERVICE_DEFAULT, BASE_SCHEMA$1 as YOGA_BASE_SCHEMA, apolloSandboxHtml, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createSandboxResponse, createScanContext, createSilentLogger, createYogaServer, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, extractSubscriptions, fetchSandboxScript, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parse, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
|
32
|
+
export { APOLLO_SANDBOX_CDN, APOLLO_USER_FACING_ERROR_CODES, BASE_SCHEMA, BASE_SCHEMA_DEF, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_IGNORE_PATTERNS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_CLIENT_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, apolloSandboxHtml, buildGraphQLSchema, capitalize, createApolloServerInstance, createCoreConfig, createDefaultMaskError, createLogger, createMergedSchema, createSandboxResponse, createScanContext, createYogaServer, deduplicateFiles, downloadAndSaveSchema, ensureDir, extractPaths, extractSubscriptions, fetchSandboxScript, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, parse, parseDirectiveCall, parseDirectivesFromFile, parseResolverCall, parseSingleFile, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
|
package/dist/core/manifest.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DIRECTIVE_EXTENSIONS, GRAPHQL_EXTENSIONS, RESOLVER_EXTENSIONS } from "./constants.mjs";
|
|
2
|
+
import consola from "consola";
|
|
2
3
|
import { dirname, isAbsolute, resolve } from "pathe";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import { loadConfig } from "c12";
|
|
5
6
|
import { resolvePath } from "mlly";
|
|
6
7
|
import { glob } from "tinyglobby";
|
|
7
|
-
|
|
8
8
|
//#region src/core/manifest.ts
|
|
9
9
|
/**
|
|
10
10
|
* Package Config Loader
|
|
@@ -48,7 +48,8 @@ async function loadPackageConfig(source, rootDir) {
|
|
|
48
48
|
config: resolvedConfig,
|
|
49
49
|
baseDir: pkgDir
|
|
50
50
|
};
|
|
51
|
-
} catch {
|
|
51
|
+
} catch (error) {
|
|
52
|
+
consola.debug(`[nitro-graphql] Failed to load config for "${source}":`, error);
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -97,6 +98,5 @@ async function resolvePackageFiles(pkg) {
|
|
|
97
98
|
schemaPath: existsSync(schemaPath) ? schemaPath : void 0
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
|
|
101
101
|
//#endregion
|
|
102
|
-
export { isLocalPath, loadPackageConfig, resolvePackageFiles };
|
|
102
|
+
export { isLocalPath, loadPackageConfig, resolvePackageFiles };
|
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Built-in PubSub implementation for GraphQL Subscriptions
|
|
4
|
-
* Simple EventEmitter-based implementation for single-instance deployments
|
|
5
|
-
*
|
|
6
|
-
* For multi-instance deployments, use external PubSub solutions like:
|
|
7
|
-
* - Redis (with ioredis)
|
|
8
|
-
* - Kafka
|
|
9
|
-
* - RabbitMQ
|
|
10
|
-
* - Cloud Pub/Sub services
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Generic PubSub engine interface
|
|
14
|
-
* Compatible with various PubSub implementations
|
|
15
|
-
*/
|
|
16
|
-
interface PubSubEngine<Topics extends Record<string, unknown> = Record<string, unknown>> {
|
|
17
|
-
/**
|
|
18
|
-
* Publish an event to a topic
|
|
19
|
-
* @param topic - Topic name to publish to
|
|
20
|
-
* @param payload - Event payload
|
|
21
|
-
*/
|
|
22
|
-
publish: <K extends keyof Topics>(topic: K, payload: Topics[K]) => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Subscribe to a topic
|
|
25
|
-
* @param topic - Topic name to subscribe to
|
|
26
|
-
* @returns AsyncIterable that yields events
|
|
27
|
-
*/
|
|
28
|
-
subscribe: <K extends keyof Topics>(topic: K) => AsyncIterable<Topics[K]>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Type alias for typed PubSub instances
|
|
32
|
-
*/
|
|
33
|
-
type TypedPubSub<Topics extends Record<string, unknown>> = PubSubEngine<Topics>;
|
|
34
|
-
/**
|
|
35
|
-
* Create a simple in-memory PubSub instance
|
|
36
|
-
*
|
|
37
|
-
* This implementation uses EventEmitter for lightweight pub/sub functionality.
|
|
38
|
-
* Suitable for:
|
|
39
|
-
* - Development environments
|
|
40
|
-
* - Single-instance production deployments
|
|
41
|
-
* - Testing
|
|
42
|
-
*
|
|
43
|
-
* NOT suitable for:
|
|
44
|
-
* - Multi-instance/clustered deployments (events won't propagate across instances)
|
|
45
|
-
* - High-throughput scenarios (consider Redis-based PubSub)
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* // Define your topic types
|
|
50
|
-
* interface MyTopics {
|
|
51
|
-
* 'user:created': { id: string; name: string }
|
|
52
|
-
* 'message:sent': { channelId: string; content: string }
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* // Create typed PubSub instance
|
|
56
|
-
* const pubsub = createPubSub<MyTopics>()
|
|
57
|
-
*
|
|
58
|
-
* // Publish events
|
|
59
|
-
* await pubsub.publish('user:created', { id: '123', name: 'John' })
|
|
60
|
-
*
|
|
61
|
-
* // Subscribe to events (in a resolver)
|
|
62
|
-
* export const userSubscriptions = defineSubscription({
|
|
63
|
-
* userCreated: {
|
|
64
|
-
* subscribe: async function* () {
|
|
65
|
-
* yield* pubsub.subscribe('user:created')
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
* })
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function createPubSub<Topics extends Record<string, unknown> = Record<string, unknown>>(): PubSubEngine<Topics>;
|
|
72
|
-
/**
|
|
73
|
-
* Filter subscription events based on a predicate
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* export const chatSubscriptions = defineSubscription({
|
|
78
|
-
* messageAdded: {
|
|
79
|
-
* subscribe: async function* (_, { channelId }) {
|
|
80
|
-
* yield* withFilter(
|
|
81
|
-
* pubsub.subscribe('message:added'),
|
|
82
|
-
* (message) => message.channelId === channelId
|
|
83
|
-
* )
|
|
84
|
-
* }
|
|
85
|
-
* }
|
|
86
|
-
* })
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
declare function withFilter<T>(asyncIterable: AsyncIterable<T>, filter: (value: T) => boolean | Promise<boolean>): AsyncIterable<T>;
|
|
90
|
-
/**
|
|
91
|
-
* Map subscription events to a different shape
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* export const chatSubscriptions = defineSubscription({
|
|
96
|
-
* messageAdded: {
|
|
97
|
-
* subscribe: async function* () {
|
|
98
|
-
* yield* mapAsyncIterator(
|
|
99
|
-
* pubsub.subscribe('message:added'),
|
|
100
|
-
* (event) => ({ messageAdded: event.message })
|
|
101
|
-
* )
|
|
102
|
-
* }
|
|
103
|
-
* }
|
|
104
|
-
* })
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
declare function mapAsyncIterator<T, U>(asyncIterable: AsyncIterable<T>, mapper: (value: T) => U | Promise<U>): AsyncIterable<U>;
|
|
108
|
-
//#endregion
|
|
109
|
-
export { PubSubEngine, TypedPubSub, createPubSub, mapAsyncIterator, withFilter };
|
|
1
|
+
import { PubSubEngine, TypedPubSub, createPubSub, mapAsyncIterator, withFilter } from "./memory-pubsub.mjs";
|
|
2
|
+
export { type PubSubEngine, type TypedPubSub, createPubSub, mapAsyncIterator, withFilter };
|