nitro-graphql 2.0.0-beta.70 → 2.0.0-beta.72
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/adapter.mjs +1 -3
- 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 +8 -8
- package/dist/cli/commands/index.mjs +1 -2
- 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.mjs +1 -2
- package/dist/cli/index.mjs +1 -3
- 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 +1 -3
- 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 +1 -3
- package/dist/cli/server/ws-handler.mjs +1 -3
- package/dist/config.mjs +1 -2
- package/dist/core/codegen/client.mjs +1 -3
- package/dist/core/codegen/document-loader.mjs +1 -3
- package/dist/core/codegen/index.mjs +1 -2
- package/dist/core/codegen/plugin.mjs +1 -2
- package/dist/core/codegen/runtime.d.mts +0 -2
- package/dist/core/codegen/runtime.mjs +6 -5
- package/dist/core/codegen/schema-loader.mjs +1 -3
- package/dist/core/codegen/server.mjs +1 -3
- package/dist/core/codegen/validation.mjs +1 -3
- package/dist/core/config.mjs +6 -8
- package/dist/core/constants.mjs +1 -3
- package/dist/core/debug/index.mjs +1 -2
- package/dist/core/debug/template.mjs +5 -4
- package/dist/core/extend/index.mjs +1 -2
- package/dist/core/extend/loader.mjs +1 -3
- package/dist/core/index.d.mts +0 -4
- package/dist/core/index.mjs +1 -2
- package/dist/core/manifest.mjs +1 -3
- package/dist/core/pubsub/index.mjs +1 -3
- package/dist/core/scanning/ast-scanner.mjs +1 -3
- package/dist/core/scanning/common.mjs +1 -3
- package/dist/core/scanning/directives.mjs +3 -4
- package/dist/core/scanning/documents.mjs +3 -4
- package/dist/core/scanning/index.mjs +1 -2
- package/dist/core/scanning/resolvers.mjs +3 -4
- package/dist/core/scanning/schemas.mjs +1 -3
- package/dist/core/schema/builder.mjs +1 -3
- package/dist/core/schema/federation.mjs +1 -3
- package/dist/core/schema/index.mjs +1 -2
- package/dist/core/server/index.mjs +1 -2
- package/dist/core/server/sandbox.mjs +1 -2
- package/dist/core/server/types.mjs +1 -1
- package/dist/core/server/yoga.mjs +1 -3
- package/dist/core/types/adapter.d.mts +0 -2
- package/dist/core/types/adapter.mjs +1 -1
- package/dist/core/types/codegen.mjs +1 -1
- package/dist/core/types/config.mjs +1 -1
- package/dist/core/types/define.mjs +1 -1
- package/dist/core/types/index.mjs +1 -1
- package/dist/core/types/scanning.mjs +1 -1
- package/dist/core/utils/directive-parser.mjs +1 -2
- package/dist/core/utils/errors.mjs +1 -3
- package/dist/core/utils/file-io.mjs +1 -3
- package/dist/core/utils/imports.mjs +3 -4
- package/dist/core/utils/index.mjs +1 -2
- package/dist/core/utils/logger.mjs +1 -3
- package/dist/core/utils/ofetch-templates.mjs +1 -2
- package/dist/core/utils/runtime.mjs +1 -3
- 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/index.mjs +4 -5
- package/dist/define.mjs +1 -3
- package/dist/index.mjs +2 -3
- package/dist/nitro/adapter.d.mts +0 -1
- package/dist/nitro/adapter.mjs +1 -4
- package/dist/nitro/apollo.mjs +1 -3
- package/dist/nitro/codegen.mjs +1 -3
- package/dist/nitro/config.mjs +1 -3
- package/dist/nitro/index.mjs +3 -5
- package/dist/nitro/paths.mjs +9 -4
- package/dist/nitro/rollup.mjs +4 -5
- 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.mjs +3 -6
- package/dist/nitro/routes/apollo-server.d.mts +2 -2
- package/dist/nitro/routes/apollo-server.mjs +1 -3
- package/dist/nitro/routes/debug.d.mts +2 -2
- package/dist/nitro/routes/debug.mjs +3 -7
- package/dist/nitro/routes/graphql-yoga-ws.d.mts +2 -2
- package/dist/nitro/routes/graphql-yoga-ws.mjs +3 -6
- package/dist/nitro/routes/graphql-yoga.d.mts +2 -2
- package/dist/nitro/routes/graphql-yoga.mjs +1 -3
- package/dist/nitro/routes/health.d.mts +2 -2
- package/dist/nitro/routes/health.mjs +1 -3
- package/dist/nitro/setup/extend-loader.mjs +1 -3
- package/dist/nitro/setup/file-watcher.mjs +3 -4
- package/dist/nitro/setup/logging.mjs +1 -3
- package/dist/nitro/setup/rollup-integration.mjs +4 -3
- package/dist/nitro/setup/routes.mjs +1 -3
- package/dist/nitro/setup/scanner.mjs +1 -3
- package/dist/nitro/setup/ts-config.mjs +1 -3
- package/dist/nitro/setup.mjs +4 -6
- package/dist/nitro/types.mjs +1 -1
- package/dist/nitro/virtual/generators.mjs +1 -3
- package/dist/nitro/virtual/stubs.mjs +1 -2
- 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 +35 -35
package/dist/cli/adapter.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LOG_TAG } from "../core/constants.mjs";
|
|
2
2
|
import { createCoreConfig, createCoreContext, createScanContext } from "../core/config.mjs";
|
|
3
3
|
import consola from "consola";
|
|
4
|
-
|
|
5
4
|
//#region src/cli/adapter.ts
|
|
6
5
|
/**
|
|
7
6
|
* Create a CoreLogger from consola for CLI usage
|
|
@@ -64,6 +63,5 @@ const CLIAdapter = {
|
|
|
64
63
|
return createCLILogger();
|
|
65
64
|
}
|
|
66
65
|
};
|
|
67
|
-
|
|
68
66
|
//#endregion
|
|
69
|
-
export { CLIAdapter };
|
|
67
|
+
export { CLIAdapter };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as citty from "citty";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/commands/build.d.ts
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import * as citty0 from "citty";
|
|
|
6
6
|
*
|
|
7
7
|
* Builds GraphQL types and validates schemas for production.
|
|
8
8
|
*/
|
|
9
|
-
declare const buildCommand:
|
|
9
|
+
declare const buildCommand: citty.CommandDef<{
|
|
10
10
|
readonly cwd: {
|
|
11
11
|
readonly type: "string";
|
|
12
12
|
readonly description: "Working directory";
|
|
@@ -3,7 +3,6 @@ import { generateAll } from "./generate.mjs";
|
|
|
3
3
|
import { validate } from "./validate.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/build.ts
|
|
8
7
|
/**
|
|
9
8
|
* CLI Build Command
|
|
@@ -47,6 +46,5 @@ const buildCommand = defineCommand({
|
|
|
47
46
|
logger.info(`Output: ${ctx.config.buildDir}`);
|
|
48
47
|
}
|
|
49
48
|
});
|
|
50
|
-
|
|
51
49
|
//#endregion
|
|
52
|
-
export { buildCommand };
|
|
50
|
+
export { buildCommand };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as citty from "citty";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/commands/dev.d.ts
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import * as citty0 from "citty";
|
|
|
7
7
|
* Starts the GraphQL development server with hot reload.
|
|
8
8
|
* Runtime-agnostic: works on Node.js, Bun, and Deno.
|
|
9
9
|
*/
|
|
10
|
-
declare const devCommand:
|
|
10
|
+
declare const devCommand: citty.CommandDef<{
|
|
11
11
|
readonly cwd: {
|
|
12
12
|
readonly type: "string";
|
|
13
13
|
readonly description: "Working directory";
|
|
@@ -4,7 +4,6 @@ import { startDevServer } from "../server/dev-server.mjs";
|
|
|
4
4
|
import { createDevWatcher } from "../server/watcher.mjs";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
|
-
|
|
8
7
|
//#region src/cli/commands/dev.ts
|
|
9
8
|
/**
|
|
10
9
|
* Dev Command
|
|
@@ -71,6 +70,5 @@ const devCommand = defineCommand({
|
|
|
71
70
|
onSignal("SIGTERM", shutdown);
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
|
-
|
|
75
73
|
//#endregion
|
|
76
|
-
export { devCommand };
|
|
74
|
+
export { devCommand };
|
|
@@ -9,10 +9,11 @@ import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
|
9
9
|
import { buildGraphQLSchema } from "../../core/schema/builder.mjs";
|
|
10
10
|
import { existsSync_, mkdirSync_, onSignal, readFileSync_, writeFileSync_ } from "../../core/utils/runtime.mjs";
|
|
11
11
|
import consola from "consola";
|
|
12
|
-
import { dirname, join, relative, resolve
|
|
13
|
-
|
|
12
|
+
import { dirname, join, relative, resolve } from "pathe";
|
|
14
13
|
//#region src/cli/commands/generate.ts
|
|
15
14
|
const logger = consola.withTag(LOG_TAG);
|
|
15
|
+
const NODE_MODULES_RE = /node_modules/;
|
|
16
|
+
const DOT_GIT_RE = /\.git/;
|
|
16
17
|
/**
|
|
17
18
|
* Create ScanContext from CLI context
|
|
18
19
|
*/
|
|
@@ -67,7 +68,7 @@ async function generateServer(ctx, options = {}) {
|
|
|
67
68
|
writeFileSync_(schemaPath, result.schemaString);
|
|
68
69
|
const typesConfig = ctx.config.types;
|
|
69
70
|
let typesPath;
|
|
70
|
-
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.server === "string") typesPath = resolve
|
|
71
|
+
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.server === "string") typesPath = resolve(ctx.config.rootDir, typesConfig.server);
|
|
71
72
|
else typesPath = join(ctx.config.typesDir, "nitro-graphql-server.d.ts");
|
|
72
73
|
mkdirSync_(dirname(typesPath));
|
|
73
74
|
writeFileSync_(typesPath, result.types);
|
|
@@ -104,7 +105,7 @@ async function generateClient(ctx, options = {}) {
|
|
|
104
105
|
}
|
|
105
106
|
const typesConfig = ctx.config.types;
|
|
106
107
|
let typesPath;
|
|
107
|
-
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.client === "string") typesPath = resolve
|
|
108
|
+
if (typesConfig && typeof typesConfig === "object" && typeof typesConfig.client === "string") typesPath = resolve(ctx.config.rootDir, typesConfig.client);
|
|
108
109
|
else typesPath = join(ctx.config.typesDir, "nitro-graphql-client.d.ts");
|
|
109
110
|
mkdirSync_(dirname(typesPath));
|
|
110
111
|
writeFileSync_(typesPath, result.types);
|
|
@@ -158,8 +159,8 @@ async function watchAndRegenerate(ctx, options = {}) {
|
|
|
158
159
|
ignoreInitial: true,
|
|
159
160
|
ignored: [
|
|
160
161
|
...ctx.config.ignore || [],
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
NODE_MODULES_RE,
|
|
163
|
+
DOT_GIT_RE
|
|
163
164
|
],
|
|
164
165
|
persistent: true
|
|
165
166
|
});
|
|
@@ -193,6 +194,5 @@ async function watchAndRegenerate(ctx, options = {}) {
|
|
|
193
194
|
});
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
|
-
|
|
197
197
|
//#endregion
|
|
198
|
-
export { generateAll, generateClient, generateServer };
|
|
198
|
+
export { generateAll, generateClient, generateServer };
|
|
@@ -2,5 +2,4 @@ import { init } from "./init.mjs";
|
|
|
2
2
|
import { generateAll, generateClient, generateServer } from "./generate.mjs";
|
|
3
3
|
import { validate } from "./validate.mjs";
|
|
4
4
|
import { buildCommand } from "./build.mjs";
|
|
5
|
-
|
|
6
|
-
export { buildCommand, generateAll, generateClient, generateServer, init, validate };
|
|
5
|
+
export { buildCommand, generateAll, generateClient, generateServer, init, validate };
|
|
@@ -3,9 +3,10 @@ import consola from "consola";
|
|
|
3
3
|
import { basename, join, relative, resolve } from "pathe";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { downloadTemplate } from "giget";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/init.ts
|
|
8
7
|
const logger = consola.withTag(LOG_TAG);
|
|
8
|
+
const NON_ALPHANUMERIC_HYPHEN_RE = /[^a-z0-9-]/gi;
|
|
9
|
+
const LEADING_TRAILING_HYPHENS_RE = /^-+|-+$/g;
|
|
9
10
|
/**
|
|
10
11
|
* Available templates from the examples directory
|
|
11
12
|
*/
|
|
@@ -83,7 +84,7 @@ async function initFromTemplate(projectName, templateName, options = {}) {
|
|
|
83
84
|
const packageJsonPath = join(targetDir, "package.json");
|
|
84
85
|
if (existsSync(packageJsonPath)) try {
|
|
85
86
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
86
|
-
packageJson.name = basename(projectName).replace(
|
|
87
|
+
packageJson.name = basename(projectName).replace(NON_ALPHANUMERIC_HYPHEN_RE, "-").replace(LEADING_TRAILING_HYPHENS_RE, "").toLowerCase() || "my-graphql-app";
|
|
87
88
|
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
88
89
|
logger.debug(`Updated package.json name to: ${packageJson.name}`);
|
|
89
90
|
} catch {
|
|
@@ -190,6 +191,5 @@ export const helloQueries = defineQuery({
|
|
|
190
191
|
logger.info(" 2. Add more schemas to your server directory");
|
|
191
192
|
logger.info(" 3. Add more queries/mutations to your client directory");
|
|
192
193
|
}
|
|
193
|
-
|
|
194
194
|
//#endregion
|
|
195
|
-
export { AVAILABLE_TEMPLATES, init, initFromTemplate, listTemplates };
|
|
195
|
+
export { AVAILABLE_TEMPLATES, init, initFromTemplate, listTemplates };
|
|
@@ -3,7 +3,6 @@ import { validateNoDuplicateTypes } from "../../core/codegen/validation.mjs";
|
|
|
3
3
|
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
|
|
7
6
|
//#region src/cli/commands/validate.ts
|
|
8
7
|
const logger = consola.withTag(LOG_TAG);
|
|
9
8
|
/**
|
|
@@ -62,6 +61,5 @@ async function validate(ctx) {
|
|
|
62
61
|
return false;
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
//#endregion
|
|
67
|
-
export { validate };
|
|
65
|
+
export { validate };
|
package/dist/cli/completions.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AVAILABLE_TEMPLATES } from "./commands/init.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/cli/completions.ts
|
|
4
3
|
async function initCompletions(command) {
|
|
5
4
|
const { default: tab } = await import("@bomb.sh/tab/citty");
|
|
@@ -29,6 +28,5 @@ async function initCompletions(command) {
|
|
|
29
28
|
} } }
|
|
30
29
|
} });
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
//#endregion
|
|
34
|
-
export { initCompletions };
|
|
32
|
+
export { initCompletions };
|
package/dist/cli/config.mjs
CHANGED
package/dist/cli/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { existsSync_, exit, getCwd } from "../core/utils/runtime.mjs";
|
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { resolve } from "pathe";
|
|
7
7
|
import { defineCommand, runMain } from "citty";
|
|
8
|
-
|
|
9
8
|
//#region src/cli/index.ts
|
|
10
9
|
const logger = consola.withTag(LOG_TAG);
|
|
11
10
|
/**
|
|
@@ -312,6 +311,5 @@ async function run() {
|
|
|
312
311
|
return runMain(main);
|
|
313
312
|
}
|
|
314
313
|
run();
|
|
315
|
-
|
|
316
314
|
//#endregion
|
|
317
|
-
export { createCLIContext, defineConfig, loadConfig };
|
|
315
|
+
export { createCLIContext, defineConfig, loadConfig };
|
|
@@ -4,7 +4,6 @@ import { scanResolversCore } from "../../core/scanning/resolvers.mjs";
|
|
|
4
4
|
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
5
5
|
import { CLIAdapter } from "../adapter.mjs";
|
|
6
6
|
import { generateDebugHtml } from "../../core/debug/template.mjs";
|
|
7
|
-
|
|
8
7
|
//#region src/cli/server/debug-handler.ts
|
|
9
8
|
/**
|
|
10
9
|
* Create a debug handler for the CLI dev server
|
|
@@ -28,9 +27,8 @@ async function collectDebugInfo(ctx) {
|
|
|
28
27
|
scanDocumentsCore(scanCtx, { externalServices: ctx.config.externalServices })
|
|
29
28
|
]);
|
|
30
29
|
const resolverFiles = resolversResult.items.map((r) => {
|
|
31
|
-
const parts = r.specifier.split("/");
|
|
32
30
|
return {
|
|
33
|
-
file:
|
|
31
|
+
file: r.specifier.split("/").at(-1) || r.specifier,
|
|
34
32
|
exports: r.imports.map((i) => ({
|
|
35
33
|
name: i.name,
|
|
36
34
|
type: i.type
|
|
@@ -66,6 +64,5 @@ async function collectDebugInfo(ctx) {
|
|
|
66
64
|
virtualModules: { "cli-config": JSON.stringify(ctx.config, null, 2) }
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
|
-
|
|
70
67
|
//#endregion
|
|
71
|
-
export { createDebugHandler };
|
|
68
|
+
export { createDebugHandler };
|
|
@@ -6,7 +6,6 @@ import { createWebSocketPlugin } from "./ws-handler.mjs";
|
|
|
6
6
|
import consola from "consola";
|
|
7
7
|
import { plugin } from "crossws/server";
|
|
8
8
|
import { serve } from "srvx";
|
|
9
|
-
|
|
10
9
|
//#region src/cli/server/dev-server.ts
|
|
11
10
|
const logger = consola.withTag("nitro-graphql");
|
|
12
11
|
/**
|
|
@@ -59,6 +58,5 @@ async function startDevServer(ctx, options = {}) {
|
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
|
-
|
|
63
61
|
//#endregion
|
|
64
|
-
export { startDevServer };
|
|
62
|
+
export { startDevServer };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BASE_SCHEMA, createYogaServer } from "../../core/server/yoga.mjs";
|
|
2
2
|
import { loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions } from "./loader.mjs";
|
|
3
3
|
import consola from "consola";
|
|
4
|
-
|
|
5
4
|
//#region src/cli/server/graphql-handler.ts
|
|
6
5
|
const logger = consola.withTag("nitro-graphql");
|
|
7
6
|
let serverInstance = null;
|
|
@@ -40,6 +39,5 @@ async function reloadGraphQLHandler(ctx) {
|
|
|
40
39
|
function getServerInstance() {
|
|
41
40
|
return serverInstance;
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
|
-
export { createGraphQLHandler, getServerInstance, reloadGraphQLHandler };
|
|
43
|
+
export { createGraphQLHandler, getServerInstance, reloadGraphQLHandler };
|
|
@@ -5,7 +5,6 @@ import { pathToFileURL, readFileSync_ } from "../../core/utils/runtime.mjs";
|
|
|
5
5
|
import { scanAllExtendSources } from "../../core/extend/loader.mjs";
|
|
6
6
|
import { CLIAdapter } from "../adapter.mjs";
|
|
7
7
|
import consola from "consola";
|
|
8
|
-
|
|
9
8
|
//#region src/cli/server/loader.ts
|
|
10
9
|
const logger = consola.withTag("nitro-graphql");
|
|
11
10
|
let cachedExtendResult = null;
|
|
@@ -141,6 +140,5 @@ async function loadAllComponents(ctx) {
|
|
|
141
140
|
directives
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
|
-
|
|
145
143
|
//#endregion
|
|
146
|
-
export { clearExtendCache, loadAllComponents, loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions };
|
|
144
|
+
export { clearExtendCache, loadAllComponents, loadDirectiveDefinitions, loadResolverDefinitions, loadSchemaDefinitions };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSandboxResponse } from "../../core/server/sandbox.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/cli/server/sandbox-handler.ts
|
|
4
3
|
/**
|
|
5
4
|
* CLI Sandbox Script Handler
|
|
@@ -14,6 +13,5 @@ function createSandboxHandler() {
|
|
|
14
13
|
return createSandboxResponse();
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
|
-
export { createSandboxHandler };
|
|
17
|
+
export { createSandboxHandler };
|
|
@@ -2,7 +2,6 @@ import { LOG_TAG } from "../../core/constants.mjs";
|
|
|
2
2
|
import { closeWatcher, createCoreWatcher } from "../../core/watcher/index.mjs";
|
|
3
3
|
import { generateAll } from "../commands/generate.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
|
-
|
|
6
5
|
//#region src/cli/server/watcher.ts
|
|
7
6
|
const logger = consola.withTag(LOG_TAG);
|
|
8
7
|
/**
|
|
@@ -61,6 +60,5 @@ function createDevWatcher(ctx, onReload) {
|
|
|
61
60
|
logger.debug("File watcher closed");
|
|
62
61
|
} };
|
|
63
62
|
}
|
|
64
|
-
|
|
65
63
|
//#endregion
|
|
66
|
-
export { createDevWatcher };
|
|
64
|
+
export { createDevWatcher };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { handleProtocols } from "graphql-ws";
|
|
2
2
|
import { makeHooks } from "graphql-ws/use/crossws";
|
|
3
|
-
|
|
4
3
|
//#region src/cli/server/ws-handler.ts
|
|
5
4
|
/**
|
|
6
5
|
* Create WebSocket hooks for GraphQL subscriptions
|
|
@@ -45,6 +44,5 @@ function createGraphQLWebSocketHooks(getSchema, context) {
|
|
|
45
44
|
function createWebSocketPlugin(getSchema, context) {
|
|
46
45
|
return createGraphQLWebSocketHooks(getSchema, context);
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
//#endregion
|
|
50
|
-
export { createGraphQLWebSocketHooks, createWebSocketPlugin };
|
|
48
|
+
export { createGraphQLWebSocketHooks, createWebSocketPlugin };
|
package/dist/config.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import { plugin as plugin$2 } from "@graphql-codegen/typescript-generic-sdk";
|
|
|
12
12
|
import { plugin as plugin$3 } from "@graphql-codegen/typescript-operations";
|
|
13
13
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
14
14
|
import { Kind, parse } from "graphql";
|
|
15
|
-
|
|
16
15
|
//#region src/core/codegen/client.ts
|
|
17
16
|
/**
|
|
18
17
|
* Default client codegen configuration
|
|
@@ -548,6 +547,5 @@ export function use${sub.typeName}(
|
|
|
548
547
|
}
|
|
549
548
|
return output;
|
|
550
549
|
}
|
|
551
|
-
|
|
552
550
|
//#endregion
|
|
553
|
-
export { DEFAULT_CLIENT_CODEGEN_CONFIG, downloadAndSaveSchema, extractSubscriptions, generateClientTypesCore, generateExternalClientTypesCore, generateSubscriptionBuilder, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments };
|
|
551
|
+
export { DEFAULT_CLIENT_CODEGEN_CONFIG, downloadAndSaveSchema, extractSubscriptions, generateClientTypesCore, generateExternalClientTypesCore, generateSubscriptionBuilder, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
2
2
|
import { loadDocuments } from "@graphql-tools/load";
|
|
3
|
-
|
|
4
3
|
//#region src/core/codegen/document-loader.ts
|
|
5
4
|
/**
|
|
6
5
|
* Load GraphQL documents from files
|
|
@@ -13,6 +12,5 @@ async function loadGraphQLDocuments(patterns) {
|
|
|
13
12
|
throw e;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
//#endregion
|
|
18
|
-
export { loadGraphQLDocuments };
|
|
16
|
+
export { loadGraphQLDocuments };
|
|
@@ -5,5 +5,4 @@ import { DEFAULT_CLIENT_CODEGEN_CONFIG, extractSubscriptions, generateClientType
|
|
|
5
5
|
import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./runtime.mjs";
|
|
6
6
|
import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes } from "./server.mjs";
|
|
7
7
|
import { validateNoDuplicateTypes, validateSchemaFiles } from "./validation.mjs";
|
|
8
|
-
|
|
9
|
-
export { DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_SERVER_CODEGEN_CONFIG, GENERATED_FILE_HEADER, downloadAndSaveSchema, extractSubscriptions, generateClientTypesCore, generateExternalClientTypesCore, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, generateTypes, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments, pluginContent, validateNoDuplicateTypes, validateSchemaFiles };
|
|
8
|
+
export { DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_SERVER_CODEGEN_CONFIG, GENERATED_FILE_HEADER, downloadAndSaveSchema, extractSubscriptions, generateClientTypesCore, generateExternalClientTypesCore, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, generateTypes, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments, pluginContent, validateNoDuplicateTypes, validateSchemaFiles };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { relative } from "pathe";
|
|
2
|
-
|
|
3
2
|
//#region src/core/codegen/runtime.ts
|
|
3
|
+
const TS_EXTENSION_RE = /\.ts$/;
|
|
4
|
+
const BACKTICK_RE = /`/g;
|
|
5
|
+
const DOLLAR_SIGN_RE = /\$/g;
|
|
4
6
|
/**
|
|
5
7
|
* Generate resolver module code
|
|
6
8
|
* Outputs Nitro-compatible format with { resolver: ... } wrapper
|
|
@@ -13,7 +15,7 @@ export const resolvers = []
|
|
|
13
15
|
const resolverEntries = [];
|
|
14
16
|
const reexports = [];
|
|
15
17
|
for (const resolver of resolvers) {
|
|
16
|
-
const relativePath = relative(baseDir, resolver.specifier).replace(
|
|
18
|
+
const relativePath = relative(baseDir, resolver.specifier).replace(TS_EXTENSION_RE, "");
|
|
17
19
|
const exportNames = resolver.imports.map((i) => i.name);
|
|
18
20
|
if (exportNames.length > 0) {
|
|
19
21
|
imports.push(`import { ${exportNames.join(", ")} } from '${relativePath}'`);
|
|
@@ -38,7 +40,7 @@ ${reexports.join("\n")}
|
|
|
38
40
|
function generateSchemaModule(schemaString) {
|
|
39
41
|
return `// Auto-generated by nitro-graphql - do not edit
|
|
40
42
|
export const schemaString = \`
|
|
41
|
-
${schemaString.replace(
|
|
43
|
+
${schemaString.replace(BACKTICK_RE, "\\`").replace(DOLLAR_SIGN_RE, "\\$")}
|
|
42
44
|
\`
|
|
43
45
|
|
|
44
46
|
// Pre-parsed for convenience
|
|
@@ -55,6 +57,5 @@ export { resolvers } from './resolvers'
|
|
|
55
57
|
export { schemaString, typeDefs } from './schema'
|
|
56
58
|
`;
|
|
57
59
|
}
|
|
58
|
-
|
|
59
60
|
//#endregion
|
|
60
|
-
export { generateResolverModule, generateRuntimeIndex, generateSchemaModule };
|
|
61
|
+
export { generateResolverModule, generateRuntimeIndex, generateSchemaModule };
|
|
@@ -6,7 +6,6 @@ import { loadSchemaSync } from "@graphql-tools/load";
|
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
8
8
|
import { UrlLoader } from "@graphql-tools/url-loader";
|
|
9
|
-
|
|
10
9
|
//#region src/core/codegen/schema-loader.ts
|
|
11
10
|
/**
|
|
12
11
|
* Check if a path is a URL
|
|
@@ -123,6 +122,5 @@ async function downloadAndSaveSchema(service, buildDir) {
|
|
|
123
122
|
return;
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
|
|
127
125
|
//#endregion
|
|
128
|
-
export { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema };
|
|
126
|
+
export { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema };
|
|
@@ -6,7 +6,6 @@ import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
|
6
6
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
7
7
|
import { parse } from "graphql";
|
|
8
8
|
import * as typescriptResolversPlugin from "@graphql-codegen/typescript-resolvers";
|
|
9
|
-
|
|
10
9
|
//#region src/core/codegen/server.ts
|
|
11
10
|
/**
|
|
12
11
|
* Default server codegen configuration
|
|
@@ -139,6 +138,5 @@ async function generateTypes(framework, schema, config = {}, outputPath) {
|
|
|
139
138
|
outputPath
|
|
140
139
|
})).types;
|
|
141
140
|
}
|
|
142
|
-
|
|
143
141
|
//#endregion
|
|
144
|
-
export { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes };
|
|
142
|
+
export { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import consola from "consola";
|
|
2
2
|
import { validateSchemaStringWithPaths, validateSchemas } from "nitro-graphql/native";
|
|
3
|
-
|
|
4
3
|
//#region src/core/codegen/validation.ts
|
|
5
4
|
/**
|
|
6
5
|
* GraphQL schema validation utilities
|
|
@@ -30,6 +29,5 @@ function validateSchemaFiles(filePaths) {
|
|
|
30
29
|
}
|
|
31
30
|
return true;
|
|
32
31
|
}
|
|
33
|
-
|
|
34
32
|
//#endregion
|
|
35
|
-
export { validateNoDuplicateTypes, validateSchemaFiles };
|
|
33
|
+
export { validateNoDuplicateTypes, validateSchemaFiles };
|
package/dist/core/config.mjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./constants.mjs";
|
|
2
2
|
import { createLogger } from "./utils/logger.mjs";
|
|
3
3
|
import { relative, resolve } from "pathe";
|
|
4
|
-
|
|
5
4
|
//#region src/core/config.ts
|
|
6
5
|
/**
|
|
7
6
|
* Create a CoreConfig with sensible defaults
|
|
8
7
|
*/
|
|
9
8
|
function createCoreConfig(options) {
|
|
10
9
|
const { rootDir, isNuxt = false, isDev = process.env.NODE_ENV !== "production", graphqlOptions = {}, logger = createLogger(), ignorePatterns = [] } = options;
|
|
11
|
-
const framework = graphqlOptions.framework ||
|
|
12
|
-
const buildDir = options.buildDir || resolve(rootDir, isNuxt ? ".nuxt" :
|
|
10
|
+
const framework = graphqlOptions.framework || "graphql-yoga";
|
|
11
|
+
const buildDir = options.buildDir || resolve(rootDir, isNuxt ? ".nuxt" : ".nitro");
|
|
13
12
|
return {
|
|
14
13
|
rootDir,
|
|
15
14
|
buildDir,
|
|
16
|
-
serverDir: options.serverDir || resolve(rootDir,
|
|
17
|
-
clientDir: options.clientDir || resolve(rootDir, isNuxt ?
|
|
15
|
+
serverDir: options.serverDir || resolve(rootDir, "server/graphql"),
|
|
16
|
+
clientDir: options.clientDir || resolve(rootDir, isNuxt ? "app/graphql" : "graphql"),
|
|
18
17
|
typesDir: resolve(buildDir, "types"),
|
|
19
18
|
framework,
|
|
20
19
|
isNuxt,
|
|
@@ -73,6 +72,5 @@ function mergeGraphQLOptions(options, defaults = {}) {
|
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
|
-
|
|
77
75
|
//#endregion
|
|
78
|
-
export { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions };
|
|
76
|
+
export { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions };
|
package/dist/core/constants.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CurrencyResolver, DateTimeISOResolver, DateTimeResolver, JSONObjectResolver, JSONResolver, NonEmptyStringResolver, UUIDResolver } from "graphql-scalars";
|
|
2
|
-
|
|
3
2
|
//#region src/core/constants.ts
|
|
4
3
|
/**
|
|
5
4
|
* Constants and magic strings used throughout nitro-graphql core
|
|
@@ -205,6 +204,5 @@ const HTTP_STATUS_INTERNAL_ERROR = 500;
|
|
|
205
204
|
* Default service directory name for main service
|
|
206
205
|
*/
|
|
207
206
|
const SERVICE_DEFAULT = "default";
|
|
208
|
-
|
|
209
207
|
//#endregion
|
|
210
|
-
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, 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, 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 };
|
|
208
|
+
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, 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, 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 };
|
|
@@ -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 { escapeHtml, generateDebugHtml };
|
|
384
|
+
export { escapeHtml, 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 };
|
|
@@ -6,7 +6,6 @@ import { parseResolverCall } from "../scanning/resolvers.mjs";
|
|
|
6
6
|
import { existsSync_ } from "../utils/runtime.mjs";
|
|
7
7
|
import { dirname, resolve } from "pathe";
|
|
8
8
|
import { glob } from "tinyglobby";
|
|
9
|
-
|
|
10
9
|
//#region src/core/extend/loader.ts
|
|
11
10
|
/**
|
|
12
11
|
* Check if source is a LocalDirExtendSource
|
|
@@ -193,6 +192,5 @@ async function scanExplicitPaths(source, rootDir) {
|
|
|
193
192
|
}
|
|
194
193
|
return result;
|
|
195
194
|
}
|
|
196
|
-
|
|
197
195
|
//#endregion
|
|
198
|
-
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|
|
196
|
+
export { isLocalDirSource, resolveExtendDirs, scanAllExtendSources, scanExtendSource };
|