nitro-graphql 2.0.0-beta.30 → 2.0.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/define.d.mts +3 -3
- package/dist/define.mjs +3 -3
- package/dist/routes/apollo-server.d.mts +2 -2
- package/dist/routes/graphql-yoga.d.mts +2 -2
- package/dist/routes/health.d.mts +2 -2
- package/dist/setup.mjs +0 -16
- package/dist/utils/index.mjs +10 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -620,7 +620,7 @@ export default defineNitroConfig({
|
|
|
620
620
|
> **⚠️ Breaking Change**: Utilities are **NOT auto-imported**. You must explicitly import them from `nitro-graphql/define`:
|
|
621
621
|
|
|
622
622
|
```typescript
|
|
623
|
-
import { defineResolver, defineQuery, defineMutation,
|
|
623
|
+
import { defineResolver, defineQuery, defineMutation, defineField, defineDirective } from 'nitro-graphql/define'
|
|
624
624
|
```
|
|
625
625
|
|
|
626
626
|
| Function | Purpose | Example |
|
|
@@ -628,7 +628,7 @@ import { defineResolver, defineQuery, defineMutation, defineType, defineDirectiv
|
|
|
628
628
|
| `defineResolver` | Complete resolvers | `defineResolver({ Query: {...}, Mutation: {...} })` |
|
|
629
629
|
| `defineQuery` | Query-only resolvers | `defineQuery({ users: () => [...] })` |
|
|
630
630
|
| `defineMutation` | Mutation-only resolvers | `defineMutation({ createUser: (...) => {...} })` |
|
|
631
|
-
| `
|
|
631
|
+
| `defineField` | Custom type resolvers | `defineField({ User: { posts: (parent) => [...] } })` |
|
|
632
632
|
| `defineDirective` | Custom directives | `defineDirective({ name: 'auth', ... })` |
|
|
633
633
|
| `defineGraphQLConfig` | GraphQL server config | `defineGraphQLConfig({ maskedErrors: {...} })` |
|
|
634
634
|
| `defineSchema` | Schema with Zod integration | `defineSchema({ Book: selectBookSchema })` |
|
|
@@ -777,7 +777,7 @@ This error occurs when the resolver scanner can't find the expected export in yo
|
|
|
777
777
|
- `defineResolver` - Complete resolver with Query, Mutation, etc.
|
|
778
778
|
- `defineQuery` - Query-only resolvers
|
|
779
779
|
- `defineMutation` - Mutation-only resolvers
|
|
780
|
-
- `
|
|
780
|
+
- `defineField` - Custom type resolvers
|
|
781
781
|
- `defineSubscription` - Subscription resolvers
|
|
782
782
|
- `defineDirective` - Directive resolvers
|
|
783
783
|
- Only exports using these functions are included in the virtual module
|
package/dist/define.d.mts
CHANGED
|
@@ -165,7 +165,7 @@ declare function defineSubscription(resolvers?: Resolvers['Subscription']): Reso
|
|
|
165
165
|
* @example
|
|
166
166
|
* ```typescript
|
|
167
167
|
* // For a User type with computed fields
|
|
168
|
-
* export const userTypeResolvers =
|
|
168
|
+
* export const userTypeResolvers = defineField({
|
|
169
169
|
* User: {
|
|
170
170
|
* fullName: (parent) => `${parent.firstName} ${parent.lastName}`,
|
|
171
171
|
* age: (parent) => {
|
|
@@ -183,7 +183,7 @@ declare function defineSubscription(resolvers?: Resolvers['Subscription']): Reso
|
|
|
183
183
|
* This is functionally equivalent to defineResolver but semantically indicates
|
|
184
184
|
* you're defining type-specific field resolvers rather than root-level operations.
|
|
185
185
|
*/
|
|
186
|
-
declare function
|
|
186
|
+
declare function defineField(resolvers: Resolvers): Resolvers;
|
|
187
187
|
/**
|
|
188
188
|
* Define GraphQL server configuration with full type safety.
|
|
189
189
|
*
|
|
@@ -293,4 +293,4 @@ declare function defineGraphQLConfig<T extends NPMConfig = NPMConfig>(config: Pa
|
|
|
293
293
|
*/
|
|
294
294
|
declare function defineDirective(config: DefineDirectiveConfig): DirectiveDefinition;
|
|
295
295
|
//#endregion
|
|
296
|
-
export { defineDirective, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription
|
|
296
|
+
export { defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription };
|
package/dist/define.mjs
CHANGED
|
@@ -169,7 +169,7 @@ function defineSubscription(resolvers = {}) {
|
|
|
169
169
|
* @example
|
|
170
170
|
* ```typescript
|
|
171
171
|
* // For a User type with computed fields
|
|
172
|
-
* export const userTypeResolvers =
|
|
172
|
+
* export const userTypeResolvers = defineField({
|
|
173
173
|
* User: {
|
|
174
174
|
* fullName: (parent) => `${parent.firstName} ${parent.lastName}`,
|
|
175
175
|
* age: (parent) => {
|
|
@@ -187,7 +187,7 @@ function defineSubscription(resolvers = {}) {
|
|
|
187
187
|
* This is functionally equivalent to defineResolver but semantically indicates
|
|
188
188
|
* you're defining type-specific field resolvers rather than root-level operations.
|
|
189
189
|
*/
|
|
190
|
-
function
|
|
190
|
+
function defineField(resolvers) {
|
|
191
191
|
return resolvers;
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
@@ -320,4 +320,4 @@ function defineDirective(config) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
//#endregion
|
|
323
|
-
export { defineDirective, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription
|
|
323
|
+
export { defineDirective, defineField, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h31 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: nitro_deps_h31.EventHandlerWithFetch<nitro_deps_h31.EventHandlerRequest, Promise<any>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h33 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: nitro_deps_h33.EventHandlerWithFetch<nitro_deps_h33.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/routes/health.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h35 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: nitro_deps_h35.EventHandlerWithFetch<nitro_deps_h35.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
package/dist/setup.mjs
CHANGED
|
@@ -198,22 +198,6 @@ async function setupNitroGraphQL(nitro) {
|
|
|
198
198
|
handler: join(runtime, "debug"),
|
|
199
199
|
method: "GET"
|
|
200
200
|
});
|
|
201
|
-
if (nitro.options.imports) {
|
|
202
|
-
nitro.options.imports.presets ??= [];
|
|
203
|
-
nitro.options.imports.presets.push({
|
|
204
|
-
from: fileURLToPath(new URL("define", import.meta.url)),
|
|
205
|
-
imports: [
|
|
206
|
-
"defineResolver",
|
|
207
|
-
"defineMutation",
|
|
208
|
-
"defineQuery",
|
|
209
|
-
"defineSubscription",
|
|
210
|
-
"defineType",
|
|
211
|
-
"defineGraphQLConfig",
|
|
212
|
-
"defineSchema",
|
|
213
|
-
"defineDirective"
|
|
214
|
-
]
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
201
|
nitro.hooks.hook("rollup:before", (_, rollupConfig$1) => {
|
|
218
202
|
const manualChunks = rollupConfig$1.output?.manualChunks;
|
|
219
203
|
const chunkFiles = rollupConfig$1.output?.chunkFileNames;
|
package/dist/utils/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createDefaultMaskError } from "./errors.mjs";
|
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { basename, join, relative } from "pathe";
|
|
5
5
|
import { hash } from "ohash";
|
|
6
|
-
import {
|
|
6
|
+
import { parseSync } from "oxc-parser";
|
|
7
7
|
import { glob } from "tinyglobby";
|
|
8
8
|
|
|
9
9
|
//#region src/utils/index.ts
|
|
@@ -70,20 +70,20 @@ async function scanResolvers(nitro) {
|
|
|
70
70
|
"defineResolver",
|
|
71
71
|
"defineQuery",
|
|
72
72
|
"defineMutation",
|
|
73
|
-
"
|
|
73
|
+
"defineField",
|
|
74
74
|
"defineSubscription",
|
|
75
75
|
"defineDirective"
|
|
76
76
|
];
|
|
77
77
|
for (const file of files) try {
|
|
78
78
|
const fileContent = await readFile(file.fullPath, "utf-8");
|
|
79
|
-
const parsed =
|
|
79
|
+
const parsed = parseSync(file.fullPath, fileContent);
|
|
80
80
|
if (parsed.errors && parsed.errors.length > 0) {
|
|
81
81
|
if (nitro.options.dev) {
|
|
82
82
|
const fileName = basename(file.fullPath);
|
|
83
83
|
const firstError = parsed.errors[0];
|
|
84
|
-
const location = firstError
|
|
84
|
+
const location = firstError?.labels?.[0];
|
|
85
85
|
const lineInfo = location ? `:${location.start}` : "";
|
|
86
|
-
const message = firstError
|
|
86
|
+
const message = firstError?.message.split(",")[0] || "Syntax error";
|
|
87
87
|
console.error(`✖ ${fileName}${lineInfo} - ${message}`);
|
|
88
88
|
}
|
|
89
89
|
continue;
|
|
@@ -117,7 +117,7 @@ async function scanResolvers(nitro) {
|
|
|
117
117
|
type: "mutation",
|
|
118
118
|
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
119
119
|
});
|
|
120
|
-
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "
|
|
120
|
+
if (decl.init.callee.type === "Identifier" && decl.init.callee.name === "defineField") exports.imports.push({
|
|
121
121
|
name: decl.id.name,
|
|
122
122
|
type: "type",
|
|
123
123
|
as: `_${hash(decl.id.name + file.fullPath).replace(/-/g, "").slice(0, 6)}`
|
|
@@ -137,6 +137,7 @@ async function scanResolvers(nitro) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
if (nitro.options.dev) {
|
|
140
|
+
const relPath = relative(nitro.options.rootDir, file.fullPath);
|
|
140
141
|
if (hasDefaultExport && !hasNamedExport) nitro.logger.warn(`[nitro-graphql] ${relPath}: Using default export instead of named export. Resolvers must use named exports like "export const myResolver = defineQuery(...)". Default exports are not detected.`);
|
|
141
142
|
if (exports.imports.length === 0 && hasNamedExport) {
|
|
142
143
|
const validFunctions = VALID_DEFINE_FUNCTIONS.join(", ");
|
|
@@ -146,8 +147,8 @@ async function scanResolvers(nitro) {
|
|
|
146
147
|
}
|
|
147
148
|
if (exports.imports.length > 0) exportName.push(exports);
|
|
148
149
|
} catch (error) {
|
|
149
|
-
const relPath
|
|
150
|
-
nitro.logger.error(`[nitro-graphql] Failed to parse resolver file ${relPath
|
|
150
|
+
const relPath = relative(nitro.options.rootDir, file.fullPath);
|
|
151
|
+
nitro.logger.error(`[nitro-graphql] Failed to parse resolver file ${relPath}:`, error);
|
|
151
152
|
}
|
|
152
153
|
return exportName;
|
|
153
154
|
}
|
|
@@ -166,7 +167,7 @@ async function scanDirectives(nitro) {
|
|
|
166
167
|
const exportName = [];
|
|
167
168
|
for (const file of files) {
|
|
168
169
|
const fileContent = await readFile(file.fullPath, "utf-8");
|
|
169
|
-
const parsed =
|
|
170
|
+
const parsed = parseSync(file.fullPath, fileContent);
|
|
170
171
|
const exports = {
|
|
171
172
|
imports: [],
|
|
172
173
|
specifier: file.fullPath
|
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.
|
|
4
|
+
"version": "2.0.0-beta.31",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"graphql-scalars": "^1.25.0",
|
|
103
103
|
"knitwork": "^1.3.0",
|
|
104
104
|
"ohash": "^2.0.11",
|
|
105
|
-
"oxc-parser": "^0.
|
|
105
|
+
"oxc-parser": "^0.98.0",
|
|
106
106
|
"pathe": "^2.0.3",
|
|
107
107
|
"tinyglobby": "^0.2.15"
|
|
108
108
|
},
|
|
@@ -119,10 +119,10 @@
|
|
|
119
119
|
"graphql": "16.12.0",
|
|
120
120
|
"graphql-yoga": "5.16.2",
|
|
121
121
|
"nitro": "npm:nitro-nightly@latest",
|
|
122
|
-
"tsdown": "^0.16.
|
|
122
|
+
"tsdown": "^0.16.6",
|
|
123
123
|
"typescript": "^5.9.3",
|
|
124
124
|
"vite": "npm:rolldown-vite@latest",
|
|
125
|
-
"vitepress-plugin-llms": "^1.9.
|
|
125
|
+
"vitepress-plugin-llms": "^1.9.3"
|
|
126
126
|
},
|
|
127
127
|
"resolutions": {
|
|
128
128
|
"nitro-graphql": "link:."
|