nitro-graphql 2.0.0-beta.17 → 2.0.0-beta.19

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 (54) hide show
  1. package/dist/ecosystem/{nuxt.js → nuxt.mjs} +1 -1
  2. package/dist/{index.d.ts → index.d.mts} +2 -2
  3. package/dist/{index.js → index.mjs} +1 -1
  4. package/dist/{rollup.js → rollup.mjs} +4 -4
  5. package/dist/routes/apollo-server.d.mts +6 -0
  6. package/dist/routes/{debug.d.ts → debug.d.mts} +2 -2
  7. package/dist/routes/{apollo-server.d.ts → graphql-yoga.d.mts} +2 -2
  8. package/dist/routes/{health.d.ts → health.d.mts} +2 -2
  9. package/dist/routes/{health.js → health.mjs} +1 -0
  10. package/dist/{setup.js → setup.mjs} +28 -9
  11. package/dist/types/{index.d.ts → index.d.mts} +2 -2
  12. package/dist/utils/{apollo.js → apollo.mjs} +2 -2
  13. package/dist/utils/{client-codegen.d.ts → client-codegen.d.mts} +1 -1
  14. package/dist/utils/{file-generator.d.ts → file-generator.d.mts} +1 -1
  15. package/dist/utils/{index.d.ts → index.d.mts} +2 -2
  16. package/dist/utils/{index.js → index.mjs} +1 -1
  17. package/dist/utils/{path-resolver.d.ts → path-resolver.d.mts} +2 -2
  18. package/dist/utils/{server-codegen.d.ts → server-codegen.d.mts} +1 -1
  19. package/dist/utils/{type-generation.js → type-generation.mjs} +4 -4
  20. package/dist/{vite.d.ts → vite.d.mts} +1 -1
  21. package/dist/{vite.js → vite.mjs} +1 -1
  22. package/package.json +17 -15
  23. package/dist/routes/graphql-yoga.d.ts +0 -6
  24. /package/dist/ecosystem/{nuxt.d.ts → nuxt.d.mts} +0 -0
  25. /package/dist/graphql/{index.d.ts → index.d.mts} +0 -0
  26. /package/dist/graphql/{index.js → index.mjs} +0 -0
  27. /package/dist/graphql/{server.d.ts → server.d.mts} +0 -0
  28. /package/dist/graphql/{server.js → server.mjs} +0 -0
  29. /package/dist/routes/{apollo-server.js → apollo-server.mjs} +0 -0
  30. /package/dist/routes/{debug.js → debug.mjs} +0 -0
  31. /package/dist/routes/{graphql-yoga.js → graphql-yoga.mjs} +0 -0
  32. /package/dist/types/{standard-schema.d.ts → standard-schema.d.mts} +0 -0
  33. /package/dist/utils/{apollo.d.ts → apollo.d.mts} +0 -0
  34. /package/dist/utils/{client-codegen.js → client-codegen.mjs} +0 -0
  35. /package/dist/utils/{define.d.ts → define.d.mts} +0 -0
  36. /package/dist/utils/{define.js → define.mjs} +0 -0
  37. /package/dist/utils/{directive-parser.d.ts → directive-parser.d.mts} +0 -0
  38. /package/dist/utils/{directive-parser.js → directive-parser.mjs} +0 -0
  39. /package/dist/utils/{file-generator.js → file-generator.mjs} +0 -0
  40. /package/dist/utils/{path-resolver.js → path-resolver.mjs} +0 -0
  41. /package/dist/utils/{server-codegen.js → server-codegen.mjs} +0 -0
  42. /package/dist/utils/{type-generation.d.ts → type-generation.d.mts} +0 -0
  43. /package/dist/virtual/{debug-info.d.ts → debug-info.d.mts} +0 -0
  44. /package/dist/virtual/{debug-info.js → debug-info.mjs} +0 -0
  45. /package/dist/virtual/{graphql-config.d.ts → graphql-config.d.mts} +0 -0
  46. /package/dist/virtual/{graphql-config.js → graphql-config.mjs} +0 -0
  47. /package/dist/virtual/{module-config.d.ts → module-config.d.mts} +0 -0
  48. /package/dist/virtual/{module-config.js → module-config.mjs} +0 -0
  49. /package/dist/virtual/{server-directives.d.ts → server-directives.d.mts} +0 -0
  50. /package/dist/virtual/{server-directives.js → server-directives.mjs} +0 -0
  51. /package/dist/virtual/{server-resolvers.d.ts → server-resolvers.d.mts} +0 -0
  52. /package/dist/virtual/{server-resolvers.js → server-resolvers.mjs} +0 -0
  53. /package/dist/virtual/{server-schemas.d.ts → server-schemas.d.mts} +0 -0
  54. /package/dist/virtual/{server-schemas.js → server-schemas.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import { getDefaultPaths, getTypesConfig, resolveFilePath } from "../utils/path-resolver.js";
1
+ import { getDefaultPaths, getTypesConfig, resolveFilePath } from "../utils/path-resolver.mjs";
2
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, relative, resolve } from "pathe";
4
4
  import { defineNuxtModule, getLayerDirectories } from "@nuxt/kit";
@@ -1,5 +1,5 @@
1
- import { StandardSchemaV1 } from "./types/standard-schema.js";
2
- import { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "./types/index.js";
1
+ import { StandardSchemaV1 } from "./types/standard-schema.mjs";
2
+ import { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "./types/index.mjs";
3
3
  import * as nitro_types0 from "nitro/types";
4
4
 
5
5
  //#region src/index.d.ts
@@ -1,4 +1,4 @@
1
- import { setupNitroGraphQL } from "./setup.js";
1
+ import { setupNitroGraphQL } from "./setup.mjs";
2
2
 
3
3
  //#region src/index.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { getImportId, scanGraphql } from "./utils/index.js";
2
- import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.js";
1
+ import { getImportId, scanGraphql } from "./utils/index.mjs";
2
+ import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.mjs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { resolve } from "pathe";
5
5
  import { readFile } from "node:fs/promises";
@@ -38,13 +38,13 @@ async function rollupConfig(app) {
38
38
  load: {
39
39
  order: "pre",
40
40
  filter: { id: /^\0virtual:#nitro-graphql\// },
41
- handler(id) {
41
+ async handler(id) {
42
42
  if (id.startsWith("\0virtual:#nitro-graphql/")) {
43
43
  const moduleName = id.slice(9);
44
44
  const generator = app.options.virtual?.[moduleName];
45
45
  if (typeof generator === "function") try {
46
46
  return {
47
- code: generator(),
47
+ code: await generator(),
48
48
  moduleType: "js"
49
49
  };
50
50
  } catch (error) {
@@ -0,0 +1,6 @@
1
+ import * as h35 from "h3";
2
+
3
+ //#region src/routes/apollo-server.d.ts
4
+ declare const _default: h35.EventHandlerWithFetch<h35.EventHandlerRequest, Promise<any>>;
5
+ //#endregion
6
+ export { _default as default };
@@ -1,4 +1,4 @@
1
- import * as h33 from "h3";
1
+ import * as h30 from "h3";
2
2
 
3
3
  //#region src/routes/debug.d.ts
4
4
 
@@ -10,7 +10,7 @@ import * as h33 from "h3";
10
10
  * - /_nitro/graphql/debug - HTML dashboard
11
11
  * - /_nitro/graphql/debug?format=json - JSON API
12
12
  */
13
- declare const _default: h33.EventHandlerWithFetch<h33.EventHandlerRequest, Promise<string | {
13
+ declare const _default: h30.EventHandlerWithFetch<h30.EventHandlerRequest, Promise<string | {
14
14
  timestamp: string;
15
15
  environment: {
16
16
  dev: any;
@@ -1,6 +1,6 @@
1
1
  import * as h31 from "h3";
2
2
 
3
- //#region src/routes/apollo-server.d.ts
4
- declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<any>>;
3
+ //#region src/routes/graphql-yoga.d.ts
4
+ declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<Response>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,7 +1,7 @@
1
- import * as h35 from "h3";
1
+ import * as h33 from "h3";
2
2
 
3
3
  //#region src/routes/health.d.ts
4
- declare const _default: h35.EventHandlerWithFetch<h35.EventHandlerRequest, Promise<{
4
+ declare const _default: h33.EventHandlerWithFetch<h33.EventHandlerRequest, Promise<{
5
5
  status: string;
6
6
  message: string;
7
7
  timestamp: string;
@@ -1,4 +1,5 @@
1
1
  import { defineEventHandler } from "h3";
2
+ import { $fetch } from "nitro/deps/ofetch";
2
3
  import { useRuntimeConfig } from "nitro/runtime";
3
4
 
4
5
  //#region src/routes/health.ts
@@ -1,9 +1,9 @@
1
- import { generateDirectiveSchemas } from "./utils/directive-parser.js";
2
- import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerServerDirectories, relativeWithDot, scanDirectives, scanDocs, scanResolvers, scanSchemas, validateExternalServices } from "./utils/index.js";
3
- import { writeFileIfNotExists } from "./utils/file-generator.js";
4
- import { getScaffoldConfig, getTypesConfig, resolveFilePath, shouldGenerateScaffold } from "./utils/path-resolver.js";
5
- import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.js";
6
- import { rollupConfig } from "./rollup.js";
1
+ import { generateDirectiveSchemas } from "./utils/directive-parser.mjs";
2
+ import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerServerDirectories, relativeWithDot, scanDirectives, scanDocs, scanResolvers, scanSchemas, validateExternalServices } from "./utils/index.mjs";
3
+ import { writeFileIfNotExists } from "./utils/file-generator.mjs";
4
+ import { getScaffoldConfig, getTypesConfig, resolveFilePath, shouldGenerateScaffold } from "./utils/path-resolver.mjs";
5
+ import { clientTypeGeneration, serverTypeGeneration } from "./utils/type-generation.mjs";
6
+ import { rollupConfig } from "./rollup.mjs";
7
7
  import { existsSync, mkdirSync } from "node:fs";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { watch } from "chokidar";
@@ -27,7 +27,7 @@ async function setupNitroGraphQL(nitro) {
27
27
  }
28
28
  consola.info(`Configured ${nitro.options.graphql.externalServices.length} external GraphQL services`);
29
29
  }
30
- const { getDefaultPaths } = await import("./utils/path-resolver.js");
30
+ const { getDefaultPaths } = await import("./utils/path-resolver.mjs");
31
31
  const defaultPaths = getDefaultPaths(nitro);
32
32
  nitro.graphql ||= {
33
33
  buildDir: "",
@@ -217,7 +217,16 @@ async function setupNitroGraphQL(nitro) {
217
217
  const chunkFiles = rollupConfig$1.output?.chunkFileNames;
218
218
  if (!rollupConfig$1.output.inlineDynamicImports) {
219
219
  rollupConfig$1.output.manualChunks = (id, meta) => {
220
- if (id.endsWith(".graphql") || id.endsWith(".gql")) return "schemas";
220
+ if (id.endsWith(".graphql") || id.endsWith(".gql")) {
221
+ let graphqlIndex = id.indexOf("server/graphql/");
222
+ let baseLength = 15;
223
+ if (graphqlIndex === -1) {
224
+ graphqlIndex = id.indexOf("routes/graphql/");
225
+ baseLength = 15;
226
+ }
227
+ if (graphqlIndex !== -1) return id.slice(graphqlIndex + baseLength).replace(/\.(?:graphql|gql)$/, "-schema");
228
+ return "schemas";
229
+ }
221
230
  if (id.endsWith(".resolver.ts")) {
222
231
  let graphqlIndex = id.indexOf("server/graphql/");
223
232
  let baseLength = 15;
@@ -232,7 +241,17 @@ async function setupNitroGraphQL(nitro) {
232
241
  };
233
242
  rollupConfig$1.output.advancedChunks = {
234
243
  groups: [{
235
- name: "schemas",
244
+ name: (moduleId) => {
245
+ if (!moduleId.endsWith(".graphql") && !moduleId.endsWith(".gql")) return;
246
+ let graphqlIndex = moduleId.indexOf("server/graphql/");
247
+ let baseLength = 15;
248
+ if (graphqlIndex === -1) {
249
+ graphqlIndex = moduleId.indexOf("routes/graphql/");
250
+ baseLength = 15;
251
+ }
252
+ if (graphqlIndex !== -1) return moduleId.slice(graphqlIndex + baseLength).replace(/\.(?:graphql|gql)$/, "-schema");
253
+ return "schemas";
254
+ },
236
255
  test: /\.(?:graphql|gql)$/
237
256
  }, {
238
257
  name: (moduleId) => {
@@ -1,4 +1,4 @@
1
- import { StandardSchemaV1 } from "./standard-schema.js";
1
+ import { StandardSchemaV1 } from "./standard-schema.mjs";
2
2
  import { ESMCodeGenOptions } from "knitwork";
3
3
  import { IResolvers } from "@graphql-tools/utils";
4
4
  import { TypeScriptPluginConfig } from "@graphql-codegen/typescript";
@@ -188,7 +188,7 @@ interface PathsConfig {
188
188
  typesDir?: string;
189
189
  }
190
190
  interface NitroGraphQLOptions {
191
- framework: 'graphql-yoga' | 'apollo-server';
191
+ framework?: 'graphql-yoga' | 'apollo-server';
192
192
  endpoint?: {
193
193
  graphql?: string;
194
194
  healthCheck?: string;
@@ -18,11 +18,11 @@ function startServerAndCreateH3Handler(server, options) {
18
18
  });
19
19
  if (body.kind === "chunked") throw new Error("Incremental delivery not implemented");
20
20
  setHeaders(event, Object.fromEntries(headers));
21
- event.res.statusCode = status || 200;
21
+ event.res.status = status || 200;
22
22
  return body.string;
23
23
  } catch (error) {
24
24
  if (error instanceof SyntaxError) {
25
- event.res.statusCode = 400;
25
+ event.res.status = 400;
26
26
  return error.message;
27
27
  } else throw error;
28
28
  }
@@ -1,4 +1,4 @@
1
- import { CodegenClientConfig, ExternalGraphQLService, GenericSdkConfig } from "../types/index.js";
1
+ import { CodegenClientConfig, ExternalGraphQLService, GenericSdkConfig } from "../types/index.mjs";
2
2
  import { GraphQLSchema } from "graphql";
3
3
  import { Source } from "@graphql-tools/utils";
4
4
  import { LoadSchemaOptions, UnnormalizedTypeDefPointer } from "@graphql-tools/load";
@@ -1,4 +1,4 @@
1
- import { Nitro } from "nitropack/types";
1
+ import { Nitro } from "nitro/types";
2
2
 
3
3
  //#region src/utils/file-generator.d.ts
4
4
 
@@ -1,5 +1,5 @@
1
- import { GenImport } from "../types/index.js";
2
- import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.js";
1
+ import { GenImport } from "../types/index.mjs";
2
+ import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
3
3
  import { Nitro } from "nitro/types";
4
4
 
5
5
  //#region src/utils/index.d.ts
@@ -1,4 +1,4 @@
1
- import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.js";
1
+ import { directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./directive-parser.mjs";
2
2
  import { join, relative } from "pathe";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { hash } from "ohash";
@@ -1,5 +1,5 @@
1
- import { ClientUtilsConfig, FileGenerationConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "../types/index.js";
2
- import { Nitro } from "nitropack/types";
1
+ import { ClientUtilsConfig, FileGenerationConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "../types/index.mjs";
2
+ import { Nitro } from "nitro/types";
3
3
 
4
4
  //#region src/utils/path-resolver.d.ts
5
5
 
@@ -1,4 +1,4 @@
1
- import { NitroGraphQLOptions } from "../types/index.js";
1
+ import { NitroGraphQLOptions } from "../types/index.mjs";
2
2
  import { GraphQLSchema } from "graphql";
3
3
 
4
4
  //#region src/utils/server-codegen.d.ts
@@ -1,7 +1,7 @@
1
- import { downloadAndSaveSchema, generateClientTypes, generateExternalClientTypes, loadExternalSchema, loadGraphQLDocuments } from "./client-codegen.js";
2
- import { writeFileIfNotExists } from "./file-generator.js";
3
- import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils, shouldGenerateTypes } from "./path-resolver.js";
4
- import { generateTypes } from "./server-codegen.js";
1
+ import { downloadAndSaveSchema, generateClientTypes, generateExternalClientTypes, loadExternalSchema, loadGraphQLDocuments } from "./client-codegen.mjs";
2
+ import { writeFileIfNotExists } from "./file-generator.mjs";
3
+ import { getClientUtilsConfig, getDefaultPaths, getSdkConfig, getTypesConfig, resolveFilePath, shouldGenerateClientUtils, shouldGenerateTypes } from "./path-resolver.mjs";
4
+ import { generateTypes } from "./server-codegen.mjs";
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import consola from "consola";
7
7
  import { basename, dirname, join, resolve } from "pathe";
@@ -1,4 +1,4 @@
1
- import { NitroGraphQLOptions } from "./types/index.js";
1
+ import { NitroGraphQLOptions } from "./types/index.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
@@ -1,4 +1,4 @@
1
- import { setupNitroGraphQL } from "./setup.js";
1
+ import { setupNitroGraphQL } from "./setup.mjs";
2
2
  import defu from "defu";
3
3
  import { readFile } from "node:fs/promises";
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nitro-graphql",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.17",
4
+ "version": "2.0.0-beta.19",
5
5
  "description": "GraphQL integration for Nitro",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
@@ -106,20 +106,20 @@
106
106
  }
107
107
  },
108
108
  "dependencies": {
109
- "@apollo/subgraph": "^2.11.3",
109
+ "@apollo/subgraph": "^2.11.4",
110
110
  "@graphql-codegen/core": "^5.0.0",
111
111
  "@graphql-codegen/import-types-preset": "^3.0.1",
112
112
  "@graphql-codegen/typescript": "^5.0.2",
113
113
  "@graphql-codegen/typescript-generic-sdk": "^4.0.2",
114
114
  "@graphql-codegen/typescript-operations": "^5.0.2",
115
115
  "@graphql-codegen/typescript-resolvers": "^5.1.0",
116
- "@graphql-tools/graphql-file-loader": "^8.1.3",
117
- "@graphql-tools/load": "^8.1.3",
116
+ "@graphql-tools/graphql-file-loader": "^8.1.4",
117
+ "@graphql-tools/load": "^8.1.4",
118
118
  "@graphql-tools/load-files": "^7.0.1",
119
- "@graphql-tools/merge": "^9.1.2",
120
- "@graphql-tools/schema": "^10.0.26",
121
- "@graphql-tools/url-loader": "^9.0.1",
122
- "@graphql-tools/utils": "^10.10.0",
119
+ "@graphql-tools/merge": "^9.1.3",
120
+ "@graphql-tools/schema": "^10.0.27",
121
+ "@graphql-tools/url-loader": "^9.0.2",
122
+ "@graphql-tools/utils": "^10.10.1",
123
123
  "chokidar": "^4.0.3",
124
124
  "consola": "^3.4.2",
125
125
  "defu": "^6.1.4",
@@ -133,20 +133,21 @@
133
133
  },
134
134
  "devDependencies": {
135
135
  "@antfu/eslint-config": "^6.2.0",
136
- "@nuxt/kit": "^4.2.0",
137
- "@nuxt/schema": "^4.2.0",
136
+ "@nuxt/kit": "^4.2.1",
137
+ "@nuxt/schema": "^4.2.1",
138
138
  "@types/node": "^24.10.0",
139
139
  "bumpp": "^10.3.1",
140
140
  "changelogen": "^0.6.2",
141
141
  "crossws": "0.3.5",
142
- "eslint": "^9.39.0",
142
+ "eslint": "^9.39.1",
143
143
  "graphql": "16.11.0",
144
- "graphql-yoga": "^5.16.0",
144
+ "graphql-yoga": "^5.16.2",
145
145
  "h3": "^2.0.1-rc.5",
146
146
  "nitro": "^3.0.1-alpha.0",
147
- "tsdown": "^0.15.12",
147
+ "tsdown": "^0.16.1",
148
148
  "typescript": "^5.9.3",
149
- "vitepress-plugin-llms": "^1.8.1"
149
+ "vite": "^7.2.2",
150
+ "vitepress-plugin-llms": "^1.9.1"
150
151
  },
151
152
  "resolutions": {
152
153
  "nitro-graphql": "link:."
@@ -163,6 +164,7 @@
163
164
  "docs:build": "cd .docs && pnpm install && pnpm build",
164
165
  "docs:preview": "cd .docs && pnpm preview",
165
166
  "lint": "eslint .",
166
- "lint:fix": "eslint . --fix"
167
+ "lint:fix": "eslint . --fix",
168
+ "test:types": "tsc --noEmit"
167
169
  }
168
170
  }
@@ -1,6 +0,0 @@
1
- import * as h30 from "h3";
2
-
3
- //#region src/routes/graphql-yoga.d.ts
4
- declare const _default: h30.EventHandlerWithFetch<h30.EventHandlerRequest, Promise<Response>>;
5
- //#endregion
6
- export { _default as default };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes