nitro-graphql 2.0.0-beta.2 → 2.0.0-beta.4
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 +44 -1
- package/dist/index.d.ts +2 -2
- package/dist/rollup.js +5 -0
- package/dist/routes/apollo-server.d.ts +2 -2
- package/dist/routes/health.d.ts +2 -2
- package/dist/vite.d.ts +25 -0
- package/dist/vite.js +40 -0
- package/package.json +17 -13
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired @as-integration
|
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
54
|
// nitro.config.ts
|
|
55
|
-
import { defineNitroConfig } from '
|
|
55
|
+
import { defineNitroConfig } from 'nitro/config'
|
|
56
56
|
|
|
57
57
|
export default defineNitroConfig({
|
|
58
58
|
modules: ['nitro-graphql'],
|
|
@@ -64,6 +64,33 @@ export default defineNitroConfig({
|
|
|
64
64
|
|
|
65
65
|
</details>
|
|
66
66
|
|
|
67
|
+
<details>
|
|
68
|
+
<summary>⚡ <strong>Vite + Nitro Project</strong></summary>
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// vite.config.ts
|
|
72
|
+
import { defineConfig } from 'vite'
|
|
73
|
+
import { nitro } from 'nitro/vite'
|
|
74
|
+
import { graphql } from 'nitro-graphql/vite'
|
|
75
|
+
|
|
76
|
+
export default defineConfig({
|
|
77
|
+
plugins: [
|
|
78
|
+
graphql(), // ⚠️ Must be before nitro()
|
|
79
|
+
nitro(),
|
|
80
|
+
],
|
|
81
|
+
nitro: {
|
|
82
|
+
modules: ['nitro-graphql'],
|
|
83
|
+
graphql: {
|
|
84
|
+
framework: 'graphql-yoga',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> **⚠️ Important**: The `graphql()` plugin must be placed **before** `nitro()` to prevent Vite from trying to parse GraphQL files as JavaScript.
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
67
94
|
<details>
|
|
68
95
|
<summary>🟢 <strong>Nuxt Project</strong></summary>
|
|
69
96
|
|
|
@@ -125,6 +152,7 @@ Try these working examples:
|
|
|
125
152
|
| Example | Description | Demo |
|
|
126
153
|
|---------|-------------|------|
|
|
127
154
|
| [**Nitro Basic**](./playgrounds/nitro/) | Standalone Nitro with GraphQL | `pnpm playground:nitro` |
|
|
155
|
+
| [**Vite + Nitro**](./playgrounds/vite/) | Vite with Nitro GraphQL integration | `cd playgrounds/vite && pnpm dev` |
|
|
128
156
|
| [**Nuxt Integration**](./playgrounds/nuxt/) | Full Nuxt app with client types | `pnpm playground:nuxt` |
|
|
129
157
|
| [**Apollo Federation**](./playgrounds/federation/) | Federated GraphQL services | `pnpm playground:federation` |
|
|
130
158
|
|
|
@@ -357,6 +385,21 @@ server/
|
|
|
357
385
|
- ✅ Use correct path: `nitro-graphql/utils/define`
|
|
358
386
|
- ✅ Use named exports in resolvers
|
|
359
387
|
|
|
388
|
+
**Vite: "Parse failure: Expected ';', '}' or <eof>" on GraphQL files**
|
|
389
|
+
- ✅ Add `graphql()` plugin from `nitro-graphql/vite`
|
|
390
|
+
- ✅ Ensure `graphql()` is placed **before** `nitro()` in plugins array
|
|
391
|
+
- ✅ Example:
|
|
392
|
+
```ts
|
|
393
|
+
import { graphql } from 'nitro-graphql/vite'
|
|
394
|
+
|
|
395
|
+
export default defineConfig({
|
|
396
|
+
plugins: [
|
|
397
|
+
graphql(), // ← Must be first
|
|
398
|
+
nitro(),
|
|
399
|
+
]
|
|
400
|
+
})
|
|
401
|
+
```
|
|
402
|
+
|
|
360
403
|
</details>
|
|
361
404
|
|
|
362
405
|
## 🌟 Production Usage
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./types/standard-schema.js";
|
|
2
2
|
import { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions } from "./types/index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as nitro_types0 from "nitro/types";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: nitro_types0.NitroModule;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, StandardSchemaV1, _default as default };
|
package/dist/rollup.js
CHANGED
|
@@ -18,6 +18,10 @@ async function rollupConfig(app) {
|
|
|
18
18
|
if (Array.isArray(rollupConfig$1.plugins)) {
|
|
19
19
|
rollupConfig$1.plugins.push({
|
|
20
20
|
name: "nitro-graphql",
|
|
21
|
+
enforce: "pre",
|
|
22
|
+
resolveId(id) {
|
|
23
|
+
if (/\.(graphql|gql)$/i.test(id)) return null;
|
|
24
|
+
},
|
|
21
25
|
async load(id) {
|
|
22
26
|
if (exclude?.test?.(id)) return null;
|
|
23
27
|
if (!include.test(id)) return null;
|
|
@@ -34,6 +38,7 @@ async function rollupConfig(app) {
|
|
|
34
38
|
});
|
|
35
39
|
rollupConfig$1.plugins.push({
|
|
36
40
|
name: "nitro-graphql-watcher",
|
|
41
|
+
enforce: "pre",
|
|
37
42
|
async buildStart() {
|
|
38
43
|
const graphqlFiles = await scanGraphql(nitro);
|
|
39
44
|
for (const file of graphqlFiles) this.addWatchFile(file);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h33 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h33.EventHandler<h33.EventHandlerRequest, unknown>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h31.EventHandler<h31.EventHandlerRequest, unknown>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/vite.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Vite plugin to load GraphQL files as strings
|
|
7
|
+
* This prevents Vite from trying to parse .graphql/.gql files as JavaScript
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { defineConfig } from 'vite'
|
|
12
|
+
* import { nitro } from 'nitro/vite'
|
|
13
|
+
* import { graphql } from 'nitro-graphql/vite'
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* graphql(), // Must be before nitro()
|
|
18
|
+
* nitro()
|
|
19
|
+
* ]
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function graphql(): Plugin;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { graphql };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
//#region src/vite.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vite plugin to load GraphQL files as strings
|
|
6
|
+
* This prevents Vite from trying to parse .graphql/.gql files as JavaScript
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineConfig } from 'vite'
|
|
11
|
+
* import { nitro } from 'nitro/vite'
|
|
12
|
+
* import { graphql } from 'nitro-graphql/vite'
|
|
13
|
+
*
|
|
14
|
+
* export default defineConfig({
|
|
15
|
+
* plugins: [
|
|
16
|
+
* graphql(), // Must be before nitro()
|
|
17
|
+
* nitro()
|
|
18
|
+
* ]
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function graphql() {
|
|
23
|
+
return {
|
|
24
|
+
name: "nitro-graphql:vite",
|
|
25
|
+
enforce: "pre",
|
|
26
|
+
async load(id) {
|
|
27
|
+
if (!/\.(?:graphql|gql)$/i.test(id)) return null;
|
|
28
|
+
try {
|
|
29
|
+
const content = await readFile(id, "utf-8");
|
|
30
|
+
return `export default ${JSON.stringify(content)}`;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { graphql };
|
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.4",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
"./nuxt": {
|
|
52
52
|
"types": "./dist/ecosystem/nuxt.d.ts",
|
|
53
53
|
"import": "./dist/ecosystem/nuxt.js"
|
|
54
|
+
},
|
|
55
|
+
"./vite": {
|
|
56
|
+
"types": "./dist/vite.d.ts",
|
|
57
|
+
"import": "./dist/vite.js"
|
|
54
58
|
}
|
|
55
59
|
},
|
|
56
60
|
"module": "./dist/index.js",
|
|
@@ -78,13 +82,13 @@
|
|
|
78
82
|
}
|
|
79
83
|
},
|
|
80
84
|
"dependencies": {
|
|
81
|
-
"@apollo/subgraph": "^2.11.
|
|
85
|
+
"@apollo/subgraph": "^2.11.3",
|
|
82
86
|
"@graphql-codegen/core": "^5.0.0",
|
|
83
87
|
"@graphql-codegen/import-types-preset": "^3.0.1",
|
|
84
|
-
"@graphql-codegen/typescript": "^5.0.
|
|
88
|
+
"@graphql-codegen/typescript": "^5.0.2",
|
|
85
89
|
"@graphql-codegen/typescript-generic-sdk": "^4.0.2",
|
|
86
|
-
"@graphql-codegen/typescript-operations": "^5.0.
|
|
87
|
-
"@graphql-codegen/typescript-resolvers": "^5.0
|
|
90
|
+
"@graphql-codegen/typescript-operations": "^5.0.2",
|
|
91
|
+
"@graphql-codegen/typescript-resolvers": "^5.1.0",
|
|
88
92
|
"@graphql-tools/graphql-file-loader": "^8.1.2",
|
|
89
93
|
"@graphql-tools/load": "^8.1.2",
|
|
90
94
|
"@graphql-tools/load-files": "^7.0.1",
|
|
@@ -96,19 +100,19 @@
|
|
|
96
100
|
"consola": "^3.4.2",
|
|
97
101
|
"defu": "^6.1.4",
|
|
98
102
|
"graphql-config": "^5.1.5",
|
|
99
|
-
"graphql-scalars": "^1.
|
|
103
|
+
"graphql-scalars": "^1.25.0",
|
|
100
104
|
"knitwork": "^1.2.0",
|
|
101
105
|
"ohash": "^2.0.11",
|
|
102
|
-
"oxc-parser": "^0.
|
|
106
|
+
"oxc-parser": "^0.95.0",
|
|
103
107
|
"pathe": "^2.0.3",
|
|
104
108
|
"tinyglobby": "^0.2.15"
|
|
105
109
|
},
|
|
106
110
|
"devDependencies": {
|
|
107
|
-
"@antfu/eslint-config": "^
|
|
108
|
-
"@nuxt/kit": "^4.1.
|
|
109
|
-
"@nuxt/schema": "^4.1.
|
|
110
|
-
"@types/node": "^24.
|
|
111
|
-
"bumpp": "^10.
|
|
111
|
+
"@antfu/eslint-config": "^6.0.0",
|
|
112
|
+
"@nuxt/kit": "^4.1.3",
|
|
113
|
+
"@nuxt/schema": "^4.1.3",
|
|
114
|
+
"@types/node": "^24.7.2",
|
|
115
|
+
"bumpp": "^10.3.1",
|
|
112
116
|
"changelogen": "^0.6.2",
|
|
113
117
|
"crossws": "0.3.5",
|
|
114
118
|
"eslint": "^9.37.0",
|
|
@@ -116,7 +120,7 @@
|
|
|
116
120
|
"graphql-yoga": "^5.16.0",
|
|
117
121
|
"h3": "^2.0.1-rc.2",
|
|
118
122
|
"nitro": "^3.0.1-alpha.0",
|
|
119
|
-
"tsdown": "^0.15.
|
|
123
|
+
"tsdown": "^0.15.7",
|
|
120
124
|
"typescript": "^5.9.3"
|
|
121
125
|
},
|
|
122
126
|
"resolutions": {
|