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.
Files changed (112) hide show
  1. package/dist/cli/adapter.mjs +1 -3
  2. package/dist/cli/commands/build.d.mts +2 -2
  3. package/dist/cli/commands/build.mjs +1 -3
  4. package/dist/cli/commands/dev.d.mts +2 -2
  5. package/dist/cli/commands/dev.mjs +1 -3
  6. package/dist/cli/commands/generate.mjs +8 -8
  7. package/dist/cli/commands/index.mjs +1 -2
  8. package/dist/cli/commands/init.mjs +4 -4
  9. package/dist/cli/commands/validate.mjs +1 -3
  10. package/dist/cli/completions.mjs +1 -3
  11. package/dist/cli/config.mjs +1 -2
  12. package/dist/cli/index.mjs +1 -3
  13. package/dist/cli/server/debug-handler.mjs +2 -5
  14. package/dist/cli/server/dev-server.mjs +1 -3
  15. package/dist/cli/server/graphql-handler.mjs +1 -3
  16. package/dist/cli/server/health-handler.mjs +1 -2
  17. package/dist/cli/server/loader.mjs +1 -3
  18. package/dist/cli/server/sandbox-handler.mjs +1 -3
  19. package/dist/cli/server/watcher.mjs +1 -3
  20. package/dist/cli/server/ws-handler.mjs +1 -3
  21. package/dist/config.mjs +1 -2
  22. package/dist/core/codegen/client.mjs +1 -3
  23. package/dist/core/codegen/document-loader.mjs +1 -3
  24. package/dist/core/codegen/index.mjs +1 -2
  25. package/dist/core/codegen/plugin.mjs +1 -2
  26. package/dist/core/codegen/runtime.d.mts +0 -2
  27. package/dist/core/codegen/runtime.mjs +6 -5
  28. package/dist/core/codegen/schema-loader.mjs +1 -3
  29. package/dist/core/codegen/server.mjs +1 -3
  30. package/dist/core/codegen/validation.mjs +1 -3
  31. package/dist/core/config.mjs +6 -8
  32. package/dist/core/constants.mjs +1 -3
  33. package/dist/core/debug/index.mjs +1 -2
  34. package/dist/core/debug/template.mjs +5 -4
  35. package/dist/core/extend/index.mjs +1 -2
  36. package/dist/core/extend/loader.mjs +1 -3
  37. package/dist/core/index.d.mts +0 -4
  38. package/dist/core/index.mjs +1 -2
  39. package/dist/core/manifest.mjs +1 -3
  40. package/dist/core/pubsub/index.mjs +1 -3
  41. package/dist/core/scanning/ast-scanner.mjs +1 -3
  42. package/dist/core/scanning/common.mjs +1 -3
  43. package/dist/core/scanning/directives.mjs +3 -4
  44. package/dist/core/scanning/documents.mjs +3 -4
  45. package/dist/core/scanning/index.mjs +1 -2
  46. package/dist/core/scanning/resolvers.mjs +3 -4
  47. package/dist/core/scanning/schemas.mjs +1 -3
  48. package/dist/core/schema/builder.mjs +1 -3
  49. package/dist/core/schema/federation.mjs +1 -3
  50. package/dist/core/schema/index.mjs +1 -2
  51. package/dist/core/server/index.mjs +1 -2
  52. package/dist/core/server/sandbox.mjs +1 -2
  53. package/dist/core/server/types.mjs +1 -1
  54. package/dist/core/server/yoga.mjs +1 -3
  55. package/dist/core/types/adapter.d.mts +0 -2
  56. package/dist/core/types/adapter.mjs +1 -1
  57. package/dist/core/types/codegen.mjs +1 -1
  58. package/dist/core/types/config.mjs +1 -1
  59. package/dist/core/types/define.mjs +1 -1
  60. package/dist/core/types/index.mjs +1 -1
  61. package/dist/core/types/scanning.mjs +1 -1
  62. package/dist/core/utils/directive-parser.mjs +1 -2
  63. package/dist/core/utils/errors.mjs +1 -3
  64. package/dist/core/utils/file-io.mjs +1 -3
  65. package/dist/core/utils/imports.mjs +3 -4
  66. package/dist/core/utils/index.mjs +1 -2
  67. package/dist/core/utils/logger.mjs +1 -3
  68. package/dist/core/utils/ofetch-templates.mjs +1 -2
  69. package/dist/core/utils/runtime.mjs +1 -3
  70. package/dist/core/utils/subscribe-templates.mjs +1 -2
  71. package/dist/core/validation/external-services.mjs +3 -3
  72. package/dist/core/validation/index.mjs +1 -2
  73. package/dist/core/watcher/index.mjs +4 -5
  74. package/dist/define.mjs +1 -3
  75. package/dist/index.mjs +2 -3
  76. package/dist/nitro/adapter.d.mts +0 -1
  77. package/dist/nitro/adapter.mjs +1 -4
  78. package/dist/nitro/apollo.mjs +1 -3
  79. package/dist/nitro/codegen.mjs +1 -3
  80. package/dist/nitro/config.mjs +1 -3
  81. package/dist/nitro/index.mjs +3 -5
  82. package/dist/nitro/paths.mjs +9 -4
  83. package/dist/nitro/rollup.mjs +4 -5
  84. package/dist/nitro/routes/apollo-sandbox-script.d.mts +2 -2
  85. package/dist/nitro/routes/apollo-sandbox-script.mjs +1 -3
  86. package/dist/nitro/routes/apollo-server-ws.mjs +3 -6
  87. package/dist/nitro/routes/apollo-server.d.mts +2 -2
  88. package/dist/nitro/routes/apollo-server.mjs +1 -3
  89. package/dist/nitro/routes/debug.d.mts +2 -2
  90. package/dist/nitro/routes/debug.mjs +3 -7
  91. package/dist/nitro/routes/graphql-yoga-ws.d.mts +2 -2
  92. package/dist/nitro/routes/graphql-yoga-ws.mjs +3 -6
  93. package/dist/nitro/routes/graphql-yoga.d.mts +2 -2
  94. package/dist/nitro/routes/graphql-yoga.mjs +1 -3
  95. package/dist/nitro/routes/health.d.mts +2 -2
  96. package/dist/nitro/routes/health.mjs +1 -3
  97. package/dist/nitro/setup/extend-loader.mjs +1 -3
  98. package/dist/nitro/setup/file-watcher.mjs +3 -4
  99. package/dist/nitro/setup/logging.mjs +1 -3
  100. package/dist/nitro/setup/rollup-integration.mjs +4 -3
  101. package/dist/nitro/setup/routes.mjs +1 -3
  102. package/dist/nitro/setup/scanner.mjs +1 -3
  103. package/dist/nitro/setup/ts-config.mjs +1 -3
  104. package/dist/nitro/setup.mjs +4 -6
  105. package/dist/nitro/types.mjs +1 -1
  106. package/dist/nitro/virtual/generators.mjs +1 -3
  107. package/dist/nitro/virtual/stubs.mjs +1 -2
  108. package/dist/nuxt.mjs +4 -5
  109. package/dist/stubs/index.mjs +1 -1
  110. package/dist/subscribe/index.mjs +3 -4
  111. package/native/index.js +52 -52
  112. package/package.json +35 -35
@@ -3,8 +3,8 @@ import { resolveSecurityConfig } from "./setup/logging.mjs";
3
3
  import { setupNitroGraphQL } from "./setup.mjs";
4
4
  import { readFile } from "node:fs/promises";
5
5
  import defu from "defu";
6
-
7
6
  //#region src/nitro/index.ts
7
+ const GRAPHQL_FILE_RE = /\.(?:graphql|gql)$/i;
8
8
  /**
9
9
  * Vite plugin to load GraphQL files as strings AND auto-register Nitro module
10
10
  * This prevents Vite from trying to parse .graphql/.gql files as JavaScript
@@ -42,7 +42,7 @@ function graphqlModule(options) {
42
42
  name: "nitro-graphql",
43
43
  enforce: "pre",
44
44
  async load(id) {
45
- if (!/\.(?:graphql|gql)$/i.test(id)) return null;
45
+ if (!GRAPHQL_FILE_RE.test(id)) return null;
46
46
  try {
47
47
  const content = await readFile(id, "utf-8");
48
48
  return `export default ${JSON.stringify(content)}`;
@@ -59,7 +59,5 @@ function graphqlModule(options) {
59
59
  } }
60
60
  };
61
61
  }
62
- var nitro_default = graphqlModule;
63
-
64
62
  //#endregion
65
- export { NitroAdapter, nitro_default as default, resolveSecurityConfig, setupNitroGraphQL };
63
+ export { NitroAdapter, graphqlModule as default, resolveSecurityConfig, setupNitroGraphQL };
@@ -1,12 +1,18 @@
1
1
  import { isAbsolute, resolve } from "pathe";
2
-
3
2
  //#region src/nitro/paths.ts
3
+ const SERVICE_NAME_RE = /\{serviceName\}/g;
4
+ const BUILD_DIR_RE = /\{buildDir\}/g;
5
+ const ROOT_DIR_RE = /\{rootDir\}/g;
6
+ const FRAMEWORK_RE = /\{framework\}/g;
7
+ const TYPES_DIR_RE = /\{typesDir\}/g;
8
+ const SERVER_DIR_RE = /\{serverDir\}/g;
9
+ const CLIENT_DIR_RE = /\{clientDir\}/g;
4
10
  /**
5
11
  * Replace placeholders in a path string
6
12
  * Supports: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {serverDir}, {clientDir}
7
13
  */
8
14
  function replacePlaceholders(path, placeholders) {
9
- return path.replace(/\{serviceName\}/g, placeholders.serviceName || "default").replace(/\{buildDir\}/g, placeholders.buildDir).replace(/\{rootDir\}/g, placeholders.rootDir).replace(/\{framework\}/g, placeholders.framework).replace(/\{typesDir\}/g, placeholders.typesDir).replace(/\{serverDir\}/g, placeholders.serverDir).replace(/\{clientDir\}/g, placeholders.clientDir);
15
+ return path.replace(SERVICE_NAME_RE, placeholders.serviceName || "default").replace(BUILD_DIR_RE, placeholders.buildDir).replace(ROOT_DIR_RE, placeholders.rootDir).replace(FRAMEWORK_RE, placeholders.framework).replace(TYPES_DIR_RE, placeholders.typesDir).replace(SERVER_DIR_RE, placeholders.serverDir).replace(CLIENT_DIR_RE, placeholders.clientDir);
10
16
  }
11
17
  /**
12
18
  * Get default paths based on framework and user configuration
@@ -87,6 +93,5 @@ function getTypesConfig(nitro) {
87
93
  if (typesConfig === false) return { enabled: false };
88
94
  return typesConfig || {};
89
95
  }
90
-
91
96
  //#endregion
92
- export { getDefaultPaths, getSdkConfig, getTypesConfig, replacePlaceholders, resolveFilePath, shouldGenerateFile, shouldGenerateSdk, shouldGenerateTypes };
97
+ export { getDefaultPaths, getSdkConfig, getTypesConfig, replacePlaceholders, resolveFilePath, shouldGenerateFile, shouldGenerateSdk, shouldGenerateTypes };
@@ -2,20 +2,20 @@ import { NitroAdapter } from "./adapter.mjs";
2
2
  import { registerAllVirtualModules } from "./virtual/generators.mjs";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { parse } from "graphql";
5
-
6
5
  //#region src/nitro/rollup.ts
6
+ const GRAPHQL_FILE_RE = /\.(?:graphql|gql)$/i;
7
7
  async function rollupConfig(nitro) {
8
8
  registerAllVirtualModules(nitro);
9
9
  nitro.hooks.hook("rollup:before", (_, rollupConfig) => {
10
10
  rollupConfig.plugins = rollupConfig.plugins || [];
11
- const { include = /\.(?:graphql|gql)$/i, exclude, validate = false } = nitro.options.graphql?.loader || {};
11
+ const { include = GRAPHQL_FILE_RE, exclude, validate = false } = nitro.options.graphql?.loader || {};
12
12
  if (Array.isArray(rollupConfig.plugins)) {
13
13
  rollupConfig.plugins.push({
14
14
  name: "nitro-graphql",
15
15
  resolveId: {
16
16
  order: "pre",
17
17
  handler(id) {
18
- if (/\.(?:graphql|gql)$/i.test(id)) return null;
18
+ if (GRAPHQL_FILE_RE.test(id)) return null;
19
19
  }
20
20
  },
21
21
  load: {
@@ -48,6 +48,5 @@ async function rollupConfig(nitro) {
48
48
  }
49
49
  });
50
50
  }
51
-
52
51
  //#endregion
53
- export { rollupConfig };
52
+ export { rollupConfig };
@@ -1,6 +1,6 @@
1
- import * as nitro_h311 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/apollo-sandbox-script.d.ts
4
- declare const _default: nitro_h311.EventHandlerWithFetch<nitro_h311.EventHandlerRequest, Promise<Response>>;
4
+ declare const _default: nitro_h30.EventHandlerWithFetch<nitro_h30.EventHandlerRequest, Promise<Response>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,6 +1,5 @@
1
1
  import { createSandboxResponse } from "../../core/server/sandbox.mjs";
2
2
  import { defineEventHandler } from "nitro/h3";
3
-
4
3
  //#region src/nitro/routes/apollo-sandbox-script.ts
5
4
  /**
6
5
  * Proxy route for Apollo Sandbox script with long cache headers
@@ -9,6 +8,5 @@ import { defineEventHandler } from "nitro/h3";
9
8
  var apollo_sandbox_script_default = defineEventHandler(async () => {
10
9
  return createSandboxResponse();
11
10
  });
12
-
13
11
  //#endregion
14
- export { apollo_sandbox_script_default as default };
12
+ export { apollo_sandbox_script_default as default };
@@ -7,7 +7,6 @@ import { moduleConfig } from "#nitro-graphql/module-config";
7
7
  import { directives } from "#nitro-graphql/server-directives";
8
8
  import { resolvers } from "#nitro-graphql/server-resolvers";
9
9
  import { schemas } from "#nitro-graphql/server-schemas";
10
-
11
10
  //#region src/nitro/routes/apollo-server-ws.ts
12
11
  let schema = null;
13
12
  /**
@@ -22,7 +21,7 @@ async function getSchema() {
22
21
  });
23
22
  return schema;
24
23
  }
25
- const hooks = {
24
+ var apollo_server_ws_default = defineWebSocketHandler({
26
25
  upgrade(request) {
27
26
  const selected = handleProtocols(request.headers.get("sec-websocket-protocol") || "");
28
27
  if (selected) return { headers: { "Sec-WebSocket-Protocol": selected } };
@@ -46,8 +45,6 @@ const hooks = {
46
45
  return baseContext;
47
46
  }
48
47
  })
49
- };
50
- var apollo_server_ws_default = defineWebSocketHandler(hooks);
51
-
48
+ });
52
49
  //#endregion
53
- export { apollo_server_ws_default as default };
50
+ export { apollo_server_ws_default as default };
@@ -1,6 +1,6 @@
1
- import * as nitro_h31 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/apollo-server.d.ts
4
- declare const _default: nitro_h31.EventHandlerWithFetch<nitro_h31.EventHandlerRequest, Promise<any>>;
4
+ declare const _default: nitro_h30.EventHandlerWithFetch<nitro_h30.EventHandlerRequest, Promise<any>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -10,7 +10,6 @@ import { schemas } from "#nitro-graphql/server-schemas";
10
10
  import { ApolloServerPluginLandingPageDisabled } from "@apollo/server/plugin/disabled";
11
11
  import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
12
12
  import { startServerAndCreateH3Handler } from "nitro-graphql/apollo";
13
-
14
13
  //#region src/nitro/routes/apollo-server.ts
15
14
  let apolloServer = null;
16
15
  let serverStarted = false;
@@ -66,6 +65,5 @@ var apollo_server_default = defineEventHandler(async (event) => {
66
65
  serverAlreadyStarted: true
67
66
  })(event);
68
67
  });
69
-
70
68
  //#endregion
71
- export { apollo_server_default as default };
69
+ export { apollo_server_default as default };
@@ -1,4 +1,4 @@
1
- import * as nitro_h33 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/debug.d.ts
4
4
  /**
@@ -9,7 +9,7 @@ import * as nitro_h33 from "nitro/h3";
9
9
  * - /_nitro/graphql/debug - HTML dashboard
10
10
  * - /_nitro/graphql/debug?format=json - JSON API
11
11
  */
12
- declare const _default: nitro_h33.EventHandlerWithFetch<nitro_h33.EventHandlerRequest, Promise<string | {
12
+ declare const _default: nitro_h30.EventHandlerWithFetch<nitro_h30.EventHandlerRequest, Promise<string | {
13
13
  timestamp: string;
14
14
  environment: {
15
15
  dev: any;
@@ -5,7 +5,6 @@ import { directives } from "#nitro-graphql/server-directives";
5
5
  import { resolvers } from "#nitro-graphql/server-resolvers";
6
6
  import { schemas } from "#nitro-graphql/server-schemas";
7
7
  import { debugInfo } from "#nitro-graphql/debug-info";
8
-
9
8
  //#region src/nitro/routes/debug.ts
10
9
  /**
11
10
  * Debug endpoint for inspecting virtual modules and GraphQL setup
@@ -18,9 +17,8 @@ import { debugInfo } from "#nitro-graphql/debug-info";
18
17
  var debug_default = defineEventHandler(async (event) => {
19
18
  const format = getQuery(event).format || "html";
20
19
  const processedResolverFiles = debugInfo.scanned.resolverFiles.map((r) => {
21
- const parts = r.specifier.split("/");
22
20
  return {
23
- file: parts[parts.length - 1],
21
+ file: r.specifier.split("/").at(-1),
24
22
  fullPath: r.specifier,
25
23
  exports: r.imports.map((i) => ({
26
24
  name: i.name,
@@ -30,9 +28,8 @@ var debug_default = defineEventHandler(async (event) => {
30
28
  };
31
29
  });
32
30
  const processedDirectiveFiles = debugInfo.scanned.directiveFiles.map((d) => {
33
- const parts = d.specifier.split("/");
34
31
  return {
35
- file: parts[parts.length - 1],
32
+ file: d.specifier.split("/").at(-1),
36
33
  fullPath: d.specifier,
37
34
  exports: d.imports.map((i) => ({
38
35
  name: i.name,
@@ -97,6 +94,5 @@ var debug_default = defineEventHandler(async (event) => {
97
94
  event.res.headers.set("Content-Type", "text/html");
98
95
  return generateDebugHtml(fullDebugInfo);
99
96
  });
100
-
101
97
  //#endregion
102
- export { debug_default as default };
98
+ export { debug_default as default };
@@ -1,4 +1,4 @@
1
- import * as nitro_h35 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/graphql-yoga-ws.d.ts
4
4
  /**
@@ -7,6 +7,6 @@ import * as nitro_h35 from "nitro/h3";
7
7
  *
8
8
  * @see https://github.com/enisdenjo/graphql-ws
9
9
  */
10
- declare const _default: nitro_h35.EventHandler<nitro_h35.EventHandlerRequest, unknown>;
10
+ declare const _default: nitro_h30.EventHandler<nitro_h30.EventHandlerRequest, unknown>;
11
11
  //#endregion
12
12
  export { _default as default };
@@ -7,7 +7,6 @@ import { moduleConfig } from "#nitro-graphql/module-config";
7
7
  import { directives } from "#nitro-graphql/server-directives";
8
8
  import { resolvers } from "#nitro-graphql/server-resolvers";
9
9
  import { schemas } from "#nitro-graphql/server-schemas";
10
-
11
10
  //#region src/nitro/routes/graphql-yoga-ws.ts
12
11
  let schema = null;
13
12
  /**
@@ -22,7 +21,7 @@ async function getSchema() {
22
21
  });
23
22
  return schema;
24
23
  }
25
- const hooks = {
24
+ var graphql_yoga_ws_default = defineWebSocketHandler({
26
25
  upgrade(request) {
27
26
  const selected = handleProtocols(request.headers.get("sec-websocket-protocol") || "");
28
27
  if (selected) return { headers: { "Sec-WebSocket-Protocol": selected } };
@@ -46,8 +45,6 @@ const hooks = {
46
45
  return baseContext;
47
46
  }
48
47
  })
49
- };
50
- var graphql_yoga_ws_default = defineWebSocketHandler(hooks);
51
-
48
+ });
52
49
  //#endregion
53
- export { graphql_yoga_ws_default as default };
50
+ export { graphql_yoga_ws_default as default };
@@ -1,4 +1,4 @@
1
- import * as nitro_h37 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/graphql-yoga.d.ts
4
4
  /**
@@ -7,6 +7,6 @@ import * as nitro_h37 from "nitro/h3";
7
7
  * Nitro/H3 wrapper around the core GraphQL Yoga server.
8
8
  * Uses virtual modules to load schemas, resolvers, and directives.
9
9
  */
10
- declare const _default: nitro_h37.EventHandlerWithFetch<nitro_h37.EventHandlerRequest, Promise<Response>>;
10
+ declare const _default: nitro_h30.EventHandlerWithFetch<nitro_h30.EventHandlerRequest, Promise<Response>>;
11
11
  //#endregion
12
12
  export { _default as default };
@@ -5,7 +5,6 @@ import { moduleConfig } from "#nitro-graphql/module-config";
5
5
  import { directives } from "#nitro-graphql/server-directives";
6
6
  import { resolvers } from "#nitro-graphql/server-resolvers";
7
7
  import { schemas } from "#nitro-graphql/server-schemas";
8
-
9
8
  //#region src/nitro/routes/graphql-yoga.ts
10
9
  const PLAYGROUND_CACHE_HEADER = "public, max-age=2592000, stale-while-revalidate=86400";
11
10
  let server = null;
@@ -36,6 +35,5 @@ var graphql_yoga_default = defineEventHandler(async (event) => {
36
35
  }
37
36
  return new Response(response.body, response);
38
37
  });
39
-
40
38
  //#endregion
41
- export { graphql_yoga_default as default };
39
+ export { graphql_yoga_default as default };
@@ -1,7 +1,7 @@
1
- import * as nitro_h39 from "nitro/h3";
1
+ import * as nitro_h30 from "nitro/h3";
2
2
 
3
3
  //#region src/nitro/routes/health.d.ts
4
- declare const _default: nitro_h39.EventHandlerWithFetch<nitro_h39.EventHandlerRequest, Promise<{
4
+ declare const _default: nitro_h30.EventHandlerWithFetch<nitro_h30.EventHandlerRequest, Promise<{
5
5
  status: string;
6
6
  message: string;
7
7
  timestamp: string;
@@ -1,7 +1,6 @@
1
1
  import { defineEventHandler } from "nitro/h3";
2
2
  import { useRuntimeConfig } from "nitro/runtime-config";
3
3
  import { $fetch } from "ofetch";
4
-
5
4
  //#region src/nitro/routes/health.ts
6
5
  var health_default = defineEventHandler(async (event) => {
7
6
  const runtime = useRuntimeConfig();
@@ -42,6 +41,5 @@ var health_default = defineEventHandler(async (event) => {
42
41
  };
43
42
  }
44
43
  });
45
-
46
44
  //#endregion
47
- export { health_default as default };
45
+ export { health_default as default };
@@ -2,7 +2,6 @@ import { LOG_TAG } from "../../core/constants.mjs";
2
2
  import { generateDirectiveSchemas } from "../../core/utils/directive-parser.mjs";
3
3
  import { resolveExtendDirs as resolveExtendDirs$1, scanAllExtendSources } from "../../core/extend/loader.mjs";
4
4
  import consola from "consola";
5
-
6
5
  //#region src/nitro/setup/extend-loader.ts
7
6
  const logger = consola.withTag(LOG_TAG);
8
7
  /**
@@ -77,6 +76,5 @@ function applyExtendResult(nitro, result) {
77
76
  programmaticSchemas: programmaticSchemasAdded
78
77
  };
79
78
  }
80
-
81
79
  //#endregion
82
- export { resolveExtendConfig, resolveExtendDirs };
80
+ export { resolveExtendConfig, resolveExtendDirs };
@@ -4,8 +4,8 @@ import { createCoreWatcher } from "../../core/watcher/index.mjs";
4
4
  import { performGraphQLScan, shouldScanLocalFiles } from "./scanner.mjs";
5
5
  import consola from "consola";
6
6
  import { join } from "pathe";
7
-
8
7
  //#region src/nitro/setup/file-watcher.ts
8
+ const TRAILING_SLASH_RE = /\/$/;
9
9
  const logger = consola.withTag(LOG_TAG);
10
10
  /**
11
11
  * Setup file watcher for GraphQL files (schemas, resolvers, directives, documents)
@@ -51,13 +51,12 @@ function getWatchDirectories(nitro, extendDirs = []) {
51
51
  if (nitro.options.graphql?.externalServices?.length) {
52
52
  for (const service of nitro.options.graphql.externalServices) if (service.documents?.length) for (const pattern of service.documents) {
53
53
  if (!pattern) continue;
54
- const baseDir = pattern.split("**")[0]?.replace(/\/$/, "") || ".";
54
+ const baseDir = pattern.split("**")[0]?.replace(TRAILING_SLASH_RE, "") || ".";
55
55
  const resolvedDir = join(nitro.options.rootDir, baseDir);
56
56
  if (!watchDirs.includes(resolvedDir)) watchDirs.push(resolvedDir);
57
57
  }
58
58
  }
59
59
  return watchDirs;
60
60
  }
61
-
62
61
  //#endregion
63
- export { getWatchDirectories, setupFileWatcher };
62
+ export { getWatchDirectories, setupFileWatcher };
@@ -1,5 +1,4 @@
1
1
  import consola from "consola";
2
-
3
2
  //#region src/nitro/setup/logging.ts
4
3
  /**
5
4
  * Resolves security configuration with environment-aware defaults
@@ -61,6 +60,5 @@ function logStartupInfo(nitro, serverEnabled) {
61
60
  }
62
61
  });
63
62
  }
64
-
65
63
  //#endregion
66
- export { logStartupInfo, resolveSecurityConfig };
64
+ export { logStartupInfo, resolveSecurityConfig };
@@ -1,11 +1,13 @@
1
1
  //#region src/nitro/setup/rollup-integration.ts
2
+ const NITRO_GRAPHQL_ROUTES_RE = /nitro-graphql[/\\]dist[/\\]nitro[/\\]routes/;
3
+ const NITRO_GRAPHQL_SCHEMA_RE = /nitro-graphql[/\\]dist[/\\]core[/\\]schema/;
2
4
  /**
3
5
  * Configure noExternals to ensure nitro-graphql route handlers are bundled
4
6
  * This is critical for Nuxt integration where node_modules are externalized by default.
5
7
  * Without this, the #nitro-graphql/* virtual imports in handlers would fail at runtime.
6
8
  */
7
9
  function setupNoExternals(nitro) {
8
- const routePatterns = [/nitro-graphql[/\\]dist[/\\]nitro[/\\]routes/, /nitro-graphql[/\\]dist[/\\]core[/\\]schema/];
10
+ const routePatterns = [NITRO_GRAPHQL_ROUTES_RE, NITRO_GRAPHQL_SCHEMA_RE];
9
11
  if (nitro.options.noExternals === true) return;
10
12
  if (!Array.isArray(nitro.options.noExternals)) nitro.options.noExternals = [];
11
13
  nitro.options.noExternals.push(...routePatterns);
@@ -58,6 +60,5 @@ function setupRollupExternals(nitro) {
58
60
  }
59
61
  });
60
62
  }
61
-
62
63
  //#endregion
63
- export { setupNoExternals, setupRollupChunking, setupRollupExternals };
64
+ export { setupNoExternals, setupRollupChunking, setupRollupExternals };
@@ -1,6 +1,5 @@
1
1
  import { ENDPOINT_DEBUG, GRAPHQL_HTTP_METHODS } from "../../core/constants.mjs";
2
2
  import { fileURLToPath } from "node:url";
3
-
4
3
  //#region src/nitro/setup/routes.ts
5
4
  /**
6
5
  * Resolve a module specifier to an absolute filesystem path.
@@ -66,6 +65,5 @@ function registerRouteHandlers(nitro) {
66
65
  method: "GET"
67
66
  });
68
67
  }
69
-
70
68
  //#endregion
71
- export { registerRouteHandlers };
69
+ export { registerRouteHandlers };
@@ -3,7 +3,6 @@ import { generateDirectiveSchemas } from "../../core/utils/directive-parser.mjs"
3
3
  import { NitroAdapter } from "../adapter.mjs";
4
4
  import { resolveExtendConfig } from "./extend-loader.mjs";
5
5
  import consola from "consola";
6
-
7
6
  //#region src/nitro/setup/scanner.ts
8
7
  const logger = consola.withTag(LOG_TAG);
9
8
  /**
@@ -115,6 +114,5 @@ function logResolverDiagnostics(nitro) {
115
114
  if (breakdown.length > 0) logger.success(`${totalExports} resolver export(s): ${breakdown.join(", ")}`);
116
115
  } else logger.warn("No resolvers found. Check /_nitro/graphql/debug for details.");
117
116
  }
118
-
119
117
  //#endregion
120
- export { getExtendSources, initializeEmptyScanResults, isServerEnabled, logResolverDiagnostics, performGraphQLScan, scanDocumentsOnly, scanLocalFiles, shouldScanLocalFiles };
118
+ export { getExtendSources, initializeEmptyScanResults, isServerEnabled, logResolverDiagnostics, performGraphQLScan, scanDocumentsOnly, scanLocalFiles, shouldScanLocalFiles };
@@ -1,7 +1,6 @@
1
1
  import { relativeWithDot } from "../../core/utils/imports.mjs";
2
2
  import { getDefaultPaths, getTypesConfig, resolveFilePath } from "../paths.mjs";
3
3
  import { dirname, join, resolve } from "pathe";
4
-
5
4
  //#region src/nitro/setup/ts-config.ts
6
5
  /**
7
6
  * Setup TypeScript path aliases for GraphQL types
@@ -64,6 +63,5 @@ function setupExternalServicePaths(nitro, types, tsconfigDir, placeholders, type
64
63
  }
65
64
  }
66
65
  }
67
-
68
66
  //#endregion
69
- export { setupTypeScriptPaths };
67
+ export { setupTypeScriptPaths };
@@ -2,7 +2,7 @@ import { FRAMEWORK_NITRO, FRAMEWORK_NUXT, LOG_TAG } from "../core/constants.mjs"
2
2
  import { validateExternalServices } from "../core/validation/external-services.mjs";
3
3
  import { getDefaultPaths } from "./paths.mjs";
4
4
  import { generateClientTypes, generateServerTypes } from "./codegen.mjs";
5
- import { DEFAULT_RUNTIME_CONFIG, DEFAULT_TYPESCRIPT_STRICT, DEFAULT_TYPES_CONFIG } from "./config.mjs";
5
+ import { DEFAULT_RUNTIME_CONFIG, DEFAULT_TYPES_CONFIG } from "./config.mjs";
6
6
  import { rollupConfig } from "./rollup.mjs";
7
7
  import { resolveExtendDirs } from "./setup/extend-loader.mjs";
8
8
  import { isServerEnabled, logResolverDiagnostics, performGraphQLScan } from "./setup/scanner.mjs";
@@ -14,7 +14,6 @@ import { setupTypeScriptPaths } from "./setup/ts-config.mjs";
14
14
  import defu from "defu";
15
15
  import consola from "consola";
16
16
  import { relative, resolve } from "pathe";
17
-
18
17
  //#region src/nitro/setup.ts
19
18
  const logger = consola.withTag(LOG_TAG);
20
19
  /**
@@ -172,7 +171,7 @@ function setupCloseHooks(nitro, serverEnabled) {
172
171
  * Setup TypeScript configuration and path aliases
173
172
  */
174
173
  function setupTypeScriptConfiguration(nitro) {
175
- nitro.options.typescript.strict = DEFAULT_TYPESCRIPT_STRICT;
174
+ nitro.options.typescript.strict = true;
176
175
  nitro.hooks.hook("types:extend", (types) => {
177
176
  setupTypeScriptPaths(nitro, types);
178
177
  });
@@ -181,11 +180,10 @@ function setupTypeScriptConfiguration(nitro) {
181
180
  * Setup Nuxt-specific integration
182
181
  */
183
182
  function setupNuxtIntegration(nitro) {
184
- if (nitro.options.framework?.name === FRAMEWORK_NUXT && nitro.options.graphql?.externalServices?.length) nitro.hooks.hook("build:before", () => {
183
+ if (nitro.options.framework?.name === "nuxt" && nitro.options.graphql?.externalServices?.length) nitro.hooks.hook("build:before", () => {
185
184
  const nuxtOptions = nitro._nuxt?.options;
186
185
  if (nuxtOptions) nuxtOptions.nitroGraphqlExternalServices = nitro.options.graphql?.externalServices || [];
187
186
  });
188
187
  }
189
-
190
188
  //#endregion
191
- export { resolveSecurityConfig, setupNitroGraphQL };
189
+ export { resolveSecurityConfig, setupNitroGraphQL };
@@ -1 +1 @@
1
- export { };
1
+ export {};
@@ -1,7 +1,6 @@
1
1
  import { resolve } from "pathe";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { genImport } from "knitwork";
4
-
5
4
  //#region src/nitro/virtual/generators.ts
6
5
  function generateImportModule(items, exportName, wrapperKey) {
7
6
  if (!items.length) return `export const ${exportName} = []`;
@@ -187,6 +186,5 @@ function registerAllVirtualModules(nitro) {
187
186
  nitro.options.virtual ??= {};
188
187
  for (const mod of allModules) nitro.options.virtual[mod.id] = () => mod.getCode(nitro);
189
188
  }
190
-
191
189
  //#endregion
192
- export { debugInfo, graphqlConfig, moduleConfig, pubsub, registerAllVirtualModules, serverDirectives, serverResolvers, serverSchemas, validationSchemas };
190
+ export { debugInfo, graphqlConfig, moduleConfig, pubsub, registerAllVirtualModules, serverDirectives, serverResolvers, serverSchemas, validationSchemas };
@@ -27,6 +27,5 @@ const debugInfo = {
27
27
  virtualModules: {}
28
28
  };
29
29
  const pubsub = null;
30
-
31
30
  //#endregion
32
- export { debugInfo, directives, importedConfig, moduleConfig, pubsub, resolvers, schemas };
31
+ export { debugInfo, directives, importedConfig, moduleConfig, pubsub, resolvers, schemas };
package/dist/nuxt.mjs CHANGED
@@ -2,8 +2,8 @@ import { getDefaultPaths, getTypesConfig, resolveFilePath } from "./nitro/paths.
2
2
  import { dirname, join, relative, resolve } from "pathe";
3
3
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
4
4
  import { defineNuxtModule, getLayerDirectories } from "@nuxt/kit";
5
-
6
5
  //#region src/nuxt.ts
6
+ const TRAILING_SLASH_RE = /\/$/;
7
7
  var nuxt_default = defineNuxtModule({
8
8
  meta: {
9
9
  name: "nitro-graphql-nuxt",
@@ -78,8 +78,8 @@ var nuxt_default = defineNuxtModule({
78
78
  nuxt.hook("nitro:config", async (nitroConfig) => {
79
79
  const clientDir = join(nuxt.options.buildDir, "graphql");
80
80
  const layerExtends = (await getLayerDirectories(nuxt)).filter((layer) => layer.root !== `${nuxt.options.rootDir}/`).map((layer) => {
81
- const serverDir = layer.server?.replace(/\/$/, "");
82
- const appDir = layer.app?.replace(/\/$/, "");
81
+ const serverDir = layer.server?.replace(TRAILING_SLASH_RE, "");
82
+ const appDir = layer.app?.replace(TRAILING_SLASH_RE, "");
83
83
  if (!serverDir && !appDir) return null;
84
84
  return {
85
85
  serverDir: serverDir ? join(serverDir, "graphql") : void 0,
@@ -107,6 +107,5 @@ var nuxt_default = defineNuxtModule({
107
107
  });
108
108
  }
109
109
  });
110
-
111
110
  //#endregion
112
- export { nuxt_default as default };
111
+ export { nuxt_default as default };
@@ -1 +1 @@
1
- export { };
1
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { createClient } from "graphql-sse";
2
2
  import { createClient as createClient$1 } from "graphql-ws";
3
-
4
3
  //#region src/subscribe/index.ts
4
+ const HTTP_PROTOCOL_RE = /^http/;
5
5
  function toWebSocketUrl(httpUrl) {
6
6
  if (httpUrl.startsWith("/")) return `${typeof window !== "undefined" && window.location.protocol === "https:" ? "wss:" : "ws:"}//${typeof window !== "undefined" ? window.location.host : "localhost"}${httpUrl}`;
7
- return httpUrl.replace(/^http/, "ws");
7
+ return httpUrl.replace(HTTP_PROTOCOL_RE, "ws");
8
8
  }
9
9
  function toHttpUrl(url) {
10
10
  if (url.startsWith("/")) return `${typeof window !== "undefined" ? window.location.protocol : "http:"}//${typeof window !== "undefined" ? window.location.host : "localhost"}${url}`;
@@ -201,6 +201,5 @@ function createSubscriptionClient(config = {}) {
201
201
  }
202
202
  };
203
203
  }
204
-
205
204
  //#endregion
206
- export { createSubscriptionClient };
205
+ export { createSubscriptionClient };