nitro-graphql 2.0.0-beta.14 → 2.0.0-beta.16

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/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { StandardSchemaV1 } from "./types/standard-schema.js";
2
2
  import { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig } from "./types/index.js";
3
- import * as nitropack_types0 from "nitropack/types";
3
+ import * as nitro_types0 from "nitro/types";
4
4
 
5
5
  //#region src/index.d.ts
6
6
  /**
7
7
  * Nitro GraphQL module
8
8
  * Can be used via modules array in nitro.config.ts
9
9
  */
10
- declare const _default: nitropack_types0.NitroModule;
10
+ declare const _default: nitro_types0.NitroModule;
11
11
  //#endregion
12
12
  export { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, StandardSchemaV1, TypesConfig, _default as default };
@@ -1,6 +1,6 @@
1
- import * as h31 from "h3";
1
+ import * as h33 from "h3";
2
2
 
3
3
  //#region src/routes/graphql-yoga.d.ts
4
- declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<Response>>;
4
+ declare const _default: h33.EventHandlerWithFetch<h33.EventHandlerRequest, Promise<Response>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,7 +1,7 @@
1
- import * as h33 from "h3";
1
+ import * as h31 from "h3";
2
2
 
3
3
  //#region src/routes/health.d.ts
4
- declare const _default: h33.EventHandlerWithFetch<h33.EventHandlerRequest, Promise<{
4
+ declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<{
5
5
  status: string;
6
6
  message: string;
7
7
  timestamp: string;
package/dist/setup.js CHANGED
@@ -293,7 +293,7 @@ export default <IGraphQLConfig> {
293
293
  }`, "graphql.config.ts");
294
294
  const serverSchemaPath = resolveFilePath(scaffoldConfig.serverSchema, scaffoldConfig.enabled, true, "{serverGraphql}/schema.ts", placeholders);
295
295
  const serverConfigPath = resolveFilePath(scaffoldConfig.serverConfig, scaffoldConfig.enabled, true, "{serverGraphql}/config.ts", placeholders);
296
- const serverContextPath = resolveFilePath(scaffoldConfig.serverContext, scaffoldConfig.enabled, true, "{serverGraphql}/context.ts", placeholders);
296
+ const serverContextPath = resolveFilePath(scaffoldConfig.serverContext, scaffoldConfig.enabled, true, "{serverGraphql}/context.d.ts", placeholders);
297
297
  if (serverSchemaPath || serverConfigPath || serverContextPath) {
298
298
  if (!existsSync(nitro.graphql.serverDir)) mkdirSync(nitro.graphql.serverDir, { recursive: true });
299
299
  }
@@ -321,7 +321,7 @@ export default defineGraphQLConfig({
321
321
  if (serverContextPath) writeFileIfNotExists(serverContextPath, `// Example context definition - please change it to your needs
322
322
  // import type { Database } from '../utils/useDb'
323
323
 
324
- declare module 'h3' {
324
+ declare module 'nitro/h3' {
325
325
  interface H3EventContext {
326
326
  // Add your custom context properties here
327
327
  // useDatabase: () => Database
@@ -333,10 +333,13 @@ declare module 'h3' {
333
333
  // }
334
334
  // }
335
335
  }
336
- }`, "server context.ts");
337
- if (existsSync(join(nitro.graphql.serverDir, "context.d.ts"))) {
338
- consola.warn("nitro-graphql: Found context.d.ts file. Please rename it to context.ts for the new structure.");
339
- consola.info("The context file should now be context.ts instead of context.d.ts");
336
+ }
337
+
338
+ export {}
339
+ `, "server context.d.ts");
340
+ if (existsSync(join(nitro.graphql.serverDir, "context.ts"))) {
341
+ consola.warn("nitro-graphql: Found context.ts file. Please rename it to context.d.ts for type-only definitions.");
342
+ consola.info("The context file should now be context.d.ts instead of context.ts");
340
343
  }
341
344
  } else consola.info("[nitro-graphql] Scaffold file generation is disabled (library mode)");
342
345
  }
@@ -37,7 +37,7 @@ async function generateTypes(selectFremework, schema, config = {}, outputPath) {
37
37
  },
38
38
  defaultScalarType: "unknown",
39
39
  defaultMapper: `ResolverReturnType<{T}>`,
40
- contextType: "h3#H3Event",
40
+ contextType: "nitro/h3#H3Event",
41
41
  maybeValue: "T | null | undefined",
42
42
  inputMaybeValue: "T | undefined",
43
43
  declarationKind: "interface",
@@ -45,7 +45,7 @@ function generateNuxtOfetchClient(nitro, clientDir, serviceName = "default") {
45
45
  const serviceDir = dirname(ofetchPath);
46
46
  if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
47
47
  if (existsSync(ofetchPath)) return;
48
- writeFileIfNotExists(ofetchPath, `// This file is auto-generated once by nitro-graphql for quick start
48
+ writeFileIfNotExists(ofetchPath, nitro.options.framework?.name === "nuxt" ? `// This file is auto-generated once by nitro-graphql for quick start
49
49
  // You can modify this file according to your needs
50
50
  import type { Requester } from './sdk'
51
51
  import { getSdk } from './sdk'
@@ -67,6 +67,26 @@ export function createGraphQLClient(endpoint: string): Requester {
67
67
  }
68
68
  }
69
69
 
70
+ export const $sdk = getSdk(createGraphQLClient('/api/graphql'))` : `// This file is auto-generated once by nitro-graphql for quick start
71
+ // You can modify this file according to your needs
72
+ import type { Requester } from './sdk'
73
+ import { ofetch } from 'ofetch'
74
+ import { getSdk } from './sdk'
75
+
76
+ export function createGraphQLClient(endpoint: string): Requester {
77
+ return async <R>(doc: string, vars?: any): Promise<R> => {
78
+ const result = await ofetch(endpoint, {
79
+ method: 'POST',
80
+ body: { query: doc, variables: vars },
81
+ headers: {
82
+ 'Content-Type': 'application/json',
83
+ },
84
+ })
85
+
86
+ return result as R
87
+ }
88
+ }
89
+
70
90
  export const $sdk = getSdk(createGraphQLClient('/api/graphql'))`, `${serviceName} ofetch.ts`);
71
91
  }
72
92
  function generateExternalOfetchClient(nitro, service, endpoint) {
@@ -83,7 +103,7 @@ function generateExternalOfetchClient(nitro, service, endpoint) {
83
103
  if (!existsSync(serviceDir)) mkdirSync(serviceDir, { recursive: true });
84
104
  if (!existsSync(ofetchPath)) {
85
105
  const capitalizedServiceName = serviceName.charAt(0).toUpperCase() + serviceName.slice(1);
86
- writeFileIfNotExists(ofetchPath, `// This file is auto-generated once by nitro-graphql for quick start
106
+ writeFileIfNotExists(ofetchPath, nitro.options.framework?.name === "nuxt" ? `// This file is auto-generated once by nitro-graphql for quick start
87
107
  // You can modify this file according to your needs
88
108
  import type { Sdk, Requester } from './sdk'
89
109
  import { getSdk } from './sdk'
@@ -105,6 +125,26 @@ export function create${capitalizedServiceName}GraphQLClient(endpoint: string =
105
125
  }
106
126
  }
107
127
 
128
+ export const $${serviceName}Sdk: Sdk = getSdk(create${capitalizedServiceName}GraphQLClient())` : `// This file is auto-generated once by nitro-graphql for quick start
129
+ // You can modify this file according to your needs
130
+ import type { Sdk, Requester } from './sdk'
131
+ import { ofetch } from 'ofetch'
132
+ import { getSdk } from './sdk'
133
+
134
+ export function create${capitalizedServiceName}GraphQLClient(endpoint: string = '${endpoint}'): Requester {
135
+ return async <R>(doc: string, vars?: any): Promise<R> => {
136
+ const result = await ofetch(endpoint, {
137
+ method: 'POST',
138
+ body: { query: doc, variables: vars },
139
+ headers: {
140
+ 'Content-Type': 'application/json',
141
+ },
142
+ })
143
+
144
+ return result as R
145
+ }
146
+ }
147
+
108
148
  export const $${serviceName}Sdk: Sdk = getSdk(create${capitalizedServiceName}GraphQLClient())`, `${serviceName} external ofetch.ts`);
109
149
  }
110
150
  }
package/dist/vite.js CHANGED
@@ -38,6 +38,8 @@ function graphql(options) {
38
38
  },
39
39
  nitro: { async setup(nitro) {
40
40
  if (options) nitro.options.graphql = defu(nitro.options.graphql || {}, options);
41
+ nitro.options.graphql = nitro.options.graphql || {};
42
+ nitro.options.graphql._vitePlugin = true;
41
43
  await setupNitroGraphQL(nitro);
42
44
  } }
43
45
  };
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "nitro-graphql",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.14",
5
- "packageManager": "pnpm@10.20.0",
4
+ "version": "2.0.0-beta.16",
6
5
  "description": "GraphQL integration for Nitro",
7
6
  "license": "MIT",
8
7
  "sideEffects": false,
@@ -87,21 +86,6 @@
87
86
  "files": [
88
87
  "dist"
89
88
  ],
90
- "scripts": {
91
- "prepack": "pnpm build",
92
- "build": "tsdown",
93
- "dev": "tsdown --watch",
94
- "bumpp": "bumpp package.json",
95
- "release": "pnpm build && pnpm bumpp && pnpm publish --no-git-checks --access public",
96
- "playground:nitro": "cd playgrounds/nitro && pnpm install && pnpm dev",
97
- "playground:nuxt": "cd playgrounds/nuxt && pnpm install && pnpm dev",
98
- "playground:federation": "cd playgrounds/federation && pnpm install && pnpm dev",
99
- "docs:dev": "cd .docs && pnpm install && pnpm dev",
100
- "docs:build": "cd .docs && pnpm install && pnpm build",
101
- "docs:preview": "cd .docs && pnpm preview",
102
- "lint": "eslint .",
103
- "lint:fix": "eslint . --fix"
104
- },
105
89
  "peerDependencies": {
106
90
  "@apollo/server": "^5.0.0",
107
91
  "@apollo/utils.withrequired": "^3.0.0",
@@ -122,49 +106,63 @@
122
106
  }
123
107
  },
124
108
  "dependencies": {
125
- "@apollo/subgraph": "catalog:",
126
- "@graphql-codegen/core": "catalog:",
127
- "@graphql-codegen/import-types-preset": "catalog:",
128
- "@graphql-codegen/typescript": "catalog:",
129
- "@graphql-codegen/typescript-generic-sdk": "catalog:",
130
- "@graphql-codegen/typescript-operations": "catalog:",
131
- "@graphql-codegen/typescript-resolvers": "catalog:",
132
- "@graphql-tools/graphql-file-loader": "catalog:",
133
- "@graphql-tools/load": "catalog:",
134
- "@graphql-tools/load-files": "catalog:",
135
- "@graphql-tools/merge": "catalog:",
136
- "@graphql-tools/schema": "catalog:",
137
- "@graphql-tools/url-loader": "catalog:",
138
- "@graphql-tools/utils": "catalog:",
139
- "chokidar": "catalog:",
140
- "consola": "catalog:",
141
- "defu": "catalog:",
142
- "graphql-config": "catalog:",
143
- "graphql-scalars": "catalog:",
144
- "knitwork": "catalog:",
145
- "ohash": "catalog:",
146
- "oxc-parser": "catalog:",
147
- "pathe": "catalog:",
148
- "tinyglobby": "catalog:"
109
+ "@apollo/subgraph": "^2.11.3",
110
+ "@graphql-codegen/core": "^5.0.0",
111
+ "@graphql-codegen/import-types-preset": "^3.0.1",
112
+ "@graphql-codegen/typescript": "^5.0.2",
113
+ "@graphql-codegen/typescript-generic-sdk": "^4.0.2",
114
+ "@graphql-codegen/typescript-operations": "^5.0.2",
115
+ "@graphql-codegen/typescript-resolvers": "^5.1.0",
116
+ "@graphql-tools/graphql-file-loader": "^8.1.3",
117
+ "@graphql-tools/load": "^8.1.3",
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",
123
+ "chokidar": "^4.0.3",
124
+ "consola": "^3.4.2",
125
+ "defu": "^6.1.4",
126
+ "graphql-config": "^5.1.5",
127
+ "graphql-scalars": "^1.25.0",
128
+ "knitwork": "^1.2.0",
129
+ "ohash": "^2.0.11",
130
+ "oxc-parser": "^0.96.0",
131
+ "pathe": "^2.0.3",
132
+ "tinyglobby": "^0.2.15"
149
133
  },
150
134
  "devDependencies": {
151
- "@antfu/eslint-config": "catalog:",
152
- "@nuxt/kit": "catalog:",
153
- "@nuxt/schema": "catalog:",
154
- "@types/node": "catalog:",
155
- "bumpp": "catalog:",
156
- "changelogen": "catalog:",
157
- "crossws": "catalog:",
158
- "eslint": "catalog:",
159
- "graphql": "catalog:",
160
- "graphql-yoga": "catalog:",
161
- "h3": "catalog:",
162
- "nitro": "catalog:",
163
- "tsdown": "catalog:",
164
- "typescript": "catalog:",
135
+ "@antfu/eslint-config": "^6.2.0",
136
+ "@nuxt/kit": "^4.2.0",
137
+ "@nuxt/schema": "^4.2.0",
138
+ "@types/node": "^24.10.0",
139
+ "bumpp": "^10.3.1",
140
+ "changelogen": "^0.6.2",
141
+ "crossws": "0.3.5",
142
+ "eslint": "^9.39.0",
143
+ "graphql": "16.11.0",
144
+ "graphql-yoga": "^5.16.0",
145
+ "h3": "^2.0.1-rc.5",
146
+ "nitro": "^3.0.1-alpha.0",
147
+ "tsdown": "^0.15.12",
148
+ "typescript": "^5.9.3",
165
149
  "vitepress-plugin-llms": "^1.8.1"
166
150
  },
167
151
  "resolutions": {
168
152
  "nitro-graphql": "link:."
153
+ },
154
+ "scripts": {
155
+ "build": "tsdown",
156
+ "dev": "tsdown --watch",
157
+ "bumpp": "bumpp package.json",
158
+ "release": "pnpm build && pnpm bumpp && pnpm publish --no-git-checks --access public",
159
+ "playground:nitro": "cd playgrounds/nitro && pnpm install && pnpm dev",
160
+ "playground:nuxt": "cd playgrounds/nuxt && pnpm install && pnpm dev",
161
+ "playground:federation": "cd playgrounds/federation && pnpm install && pnpm dev",
162
+ "docs:dev": "cd .docs && pnpm install && pnpm dev",
163
+ "docs:build": "cd .docs && pnpm install && pnpm build",
164
+ "docs:preview": "cd .docs && pnpm preview",
165
+ "lint": "eslint .",
166
+ "lint:fix": "eslint . --fix"
169
167
  }
170
- }
168
+ }