nitro-graphql 2.0.0-beta.22 → 2.0.0-beta.24
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 +2 -2
- package/dist/routes/apollo-server.d.mts +2 -2
- package/dist/routes/debug.d.mts +2 -2
- package/dist/routes/graphql-yoga.d.mts +2 -2
- package/dist/utils/apollo.mjs +32 -34
- package/package.json +19 -23
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ pnpm add nitro-graphql graphql-yoga graphql
|
|
|
61
61
|
|
|
62
62
|
**Apollo Server:**
|
|
63
63
|
```bash
|
|
64
|
-
pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired
|
|
64
|
+
pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired graphql
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
### 2. Configure
|
|
@@ -1029,7 +1029,7 @@ Now implement this setup.
|
|
|
1029
1029
|
Set up nitro-graphql with Apollo Server following these exact specifications:
|
|
1030
1030
|
|
|
1031
1031
|
INSTALLATION:
|
|
1032
|
-
1. Run: pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired
|
|
1032
|
+
1. Run: pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired graphql
|
|
1033
1033
|
|
|
1034
1034
|
CONFIGURATION (nitro.config.ts):
|
|
1035
1035
|
import { defineNitroConfig } from 'nitro/config'
|
|
@@ -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.EventHandlerWithFetch<h33.EventHandlerRequest, Promise<any>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/routes/debug.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/debug.d.ts
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import * as h35 from "h3";
|
|
|
10
10
|
* - /_nitro/graphql/debug - HTML dashboard
|
|
11
11
|
* - /_nitro/graphql/debug?format=json - JSON API
|
|
12
12
|
*/
|
|
13
|
-
declare const _default:
|
|
13
|
+
declare const _default: h31.EventHandlerWithFetch<h31.EventHandlerRequest, Promise<string | {
|
|
14
14
|
timestamp: string;
|
|
15
15
|
environment: {
|
|
16
16
|
dev: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h35 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h35.EventHandlerWithFetch<h35.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
package/dist/utils/apollo.mjs
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
import { HeaderMap } from "@apollo/server";
|
|
2
|
-
import { eventHandler,
|
|
2
|
+
import { eventHandler, getRequestURL, readBody } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/apollo.ts
|
|
5
5
|
function startServerAndCreateH3Handler(server, options) {
|
|
6
6
|
const defaultContext = () => Promise.resolve({});
|
|
7
7
|
const contextFunction = options?.context ?? defaultContext;
|
|
8
|
-
return eventHandler({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
return eventHandler(async (event) => {
|
|
9
|
+
const apolloServer = typeof server === "function" ? server() : server;
|
|
10
|
+
if (!options?.serverAlreadyStarted) apolloServer.startInBackgroundHandlingStartupErrorsByLoggingAndFailingAllRequests();
|
|
11
|
+
if (event.req.method === "OPTIONS") {
|
|
12
|
+
event.res.status = 204;
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const graphqlRequest = await toGraphqlRequest(event);
|
|
17
|
+
const { body, headers, status } = await apolloServer.executeHTTPGraphQLRequest({
|
|
18
|
+
httpGraphQLRequest: graphqlRequest,
|
|
19
|
+
context: () => contextFunction({ event })
|
|
20
|
+
});
|
|
21
|
+
if (body.kind === "chunked") throw new Error("Incremental delivery not implemented");
|
|
22
|
+
for (const [key, value] of headers) event.res.headers.set(key, value);
|
|
23
|
+
event.res.status = status || 200;
|
|
24
|
+
return body.string;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error instanceof SyntaxError) {
|
|
27
|
+
event.res.status = 400;
|
|
28
|
+
return error.message;
|
|
29
|
+
} else throw error;
|
|
30
|
+
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async function toGraphqlRequest(event) {
|
|
34
|
+
const url = getRequestURL(event);
|
|
34
35
|
return {
|
|
35
36
|
method: event.req.method || "POST",
|
|
36
|
-
headers: normalizeHeaders(
|
|
37
|
-
search:
|
|
37
|
+
headers: normalizeHeaders(Object.fromEntries(event.req.headers.entries())),
|
|
38
|
+
search: url.search.slice(1),
|
|
38
39
|
body: await normalizeBody(event)
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
function normalizeHeaders(headers) {
|
|
42
43
|
const headerMap = new HeaderMap();
|
|
43
|
-
for (const [key, value] of Object.entries(headers)) if (
|
|
44
|
-
else if (value) headerMap.set(key, value);
|
|
44
|
+
for (const [key, value] of Object.entries(headers)) if (value !== void 0) headerMap.set(key, value);
|
|
45
45
|
return headerMap;
|
|
46
46
|
}
|
|
47
|
-
function normalizeQueryString(url) {
|
|
48
|
-
if (!url) return "";
|
|
49
|
-
return url.split("?")[1] || "";
|
|
50
|
-
}
|
|
51
47
|
async function normalizeBody(event) {
|
|
52
|
-
|
|
48
|
+
const PayloadMethods = [
|
|
53
49
|
"PATCH",
|
|
54
50
|
"POST",
|
|
55
51
|
"PUT",
|
|
56
52
|
"DELETE"
|
|
57
|
-
]
|
|
53
|
+
];
|
|
54
|
+
const method = event.req.method;
|
|
55
|
+
if (method && PayloadMethods.includes(method)) return await readBody(event);
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
//#endregion
|
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.24",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@apollo/server": "^5.0.0",
|
|
71
71
|
"@apollo/utils.withrequired": "^3.0.0",
|
|
72
|
-
"@as-integrations/h3": "^2.0.0",
|
|
73
72
|
"graphql": "^16.11.0",
|
|
74
73
|
"h3": "^2.0.1-rc.2",
|
|
75
74
|
"nitro": "^3.0.1-alpha.0"
|
|
@@ -80,34 +79,31 @@
|
|
|
80
79
|
},
|
|
81
80
|
"@apollo/utils.withrequired": {
|
|
82
81
|
"optional": true
|
|
83
|
-
},
|
|
84
|
-
"@as-integrations/h3": {
|
|
85
|
-
"optional": true
|
|
86
82
|
}
|
|
87
83
|
},
|
|
88
84
|
"dependencies": {
|
|
89
|
-
"@apollo/subgraph": "^2.
|
|
85
|
+
"@apollo/subgraph": "^2.12.1",
|
|
90
86
|
"@graphql-codegen/core": "^5.0.0",
|
|
91
87
|
"@graphql-codegen/import-types-preset": "^3.0.1",
|
|
92
|
-
"@graphql-codegen/typescript": "^5.0.
|
|
88
|
+
"@graphql-codegen/typescript": "^5.0.4",
|
|
93
89
|
"@graphql-codegen/typescript-generic-sdk": "^4.0.2",
|
|
94
|
-
"@graphql-codegen/typescript-operations": "^5.0.
|
|
95
|
-
"@graphql-codegen/typescript-resolvers": "^5.1.
|
|
96
|
-
"@graphql-tools/graphql-file-loader": "^8.1.
|
|
97
|
-
"@graphql-tools/load": "^8.1.
|
|
90
|
+
"@graphql-codegen/typescript-operations": "^5.0.4",
|
|
91
|
+
"@graphql-codegen/typescript-resolvers": "^5.1.2",
|
|
92
|
+
"@graphql-tools/graphql-file-loader": "^8.1.6",
|
|
93
|
+
"@graphql-tools/load": "^8.1.6",
|
|
98
94
|
"@graphql-tools/load-files": "^7.0.1",
|
|
99
|
-
"@graphql-tools/merge": "^9.1.
|
|
100
|
-
"@graphql-tools/schema": "^10.0.
|
|
101
|
-
"@graphql-tools/url-loader": "^9.0.
|
|
102
|
-
"@graphql-tools/utils": "^10.10.
|
|
95
|
+
"@graphql-tools/merge": "^9.1.5",
|
|
96
|
+
"@graphql-tools/schema": "^10.0.29",
|
|
97
|
+
"@graphql-tools/url-loader": "^9.0.4",
|
|
98
|
+
"@graphql-tools/utils": "^10.10.3",
|
|
103
99
|
"chokidar": "^4.0.3",
|
|
104
100
|
"consola": "^3.4.2",
|
|
105
101
|
"defu": "^6.1.4",
|
|
106
102
|
"graphql-config": "^5.1.5",
|
|
107
103
|
"graphql-scalars": "^1.25.0",
|
|
108
|
-
"knitwork": "^1.
|
|
104
|
+
"knitwork": "^1.3.0",
|
|
109
105
|
"ohash": "^2.0.11",
|
|
110
|
-
"oxc-parser": "^0.
|
|
106
|
+
"oxc-parser": "^0.97.0",
|
|
111
107
|
"pathe": "^2.0.3",
|
|
112
108
|
"tinyglobby": "^0.2.15"
|
|
113
109
|
},
|
|
@@ -115,17 +111,17 @@
|
|
|
115
111
|
"@antfu/eslint-config": "^6.2.0",
|
|
116
112
|
"@nuxt/kit": "^4.2.1",
|
|
117
113
|
"@nuxt/schema": "^4.2.1",
|
|
118
|
-
"@types/node": "^24.10.
|
|
114
|
+
"@types/node": "^24.10.1",
|
|
119
115
|
"@vitejs/devtools": "^0.0.0-alpha.16",
|
|
120
116
|
"bumpp": "^10.3.1",
|
|
121
117
|
"changelogen": "^0.6.2",
|
|
122
|
-
"crossws": "0.
|
|
118
|
+
"crossws": "^0.4.1",
|
|
123
119
|
"eslint": "^9.39.1",
|
|
124
120
|
"graphql": "^16.12.0",
|
|
125
|
-
"graphql-yoga": "^5.16.
|
|
121
|
+
"graphql-yoga": "^5.16.2",
|
|
126
122
|
"h3": "^2.0.1-rc.5",
|
|
127
123
|
"nitro": "npm:nitro-nightly@latest",
|
|
128
|
-
"tsdown": "^0.16.
|
|
124
|
+
"tsdown": "^0.16.4",
|
|
129
125
|
"typescript": "^5.9.3",
|
|
130
126
|
"vite": "npm:rolldown-vite@latest",
|
|
131
127
|
"vitepress-plugin-llms": "^1.9.1"
|
|
@@ -141,8 +137,8 @@
|
|
|
141
137
|
"playground:nitro": "cd playgrounds/nitro && pnpm install && pnpm dev",
|
|
142
138
|
"playground:nuxt": "cd playgrounds/nuxt && pnpm install && pnpm dev",
|
|
143
139
|
"playground:federation": "cd playgrounds/federation && pnpm install && pnpm dev",
|
|
144
|
-
"docs:dev": "cd .docs && pnpm install && pnpm dev",
|
|
145
|
-
"docs:build": "cd .docs && pnpm install && pnpm build",
|
|
140
|
+
"docs:dev": "cd .docs && pnpm install && pnpm update:metadata && pnpm dev",
|
|
141
|
+
"docs:build": "cd .docs && pnpm install && pnpm update:metadata && pnpm build",
|
|
146
142
|
"docs:preview": "cd .docs && pnpm preview",
|
|
147
143
|
"lint": "eslint .",
|
|
148
144
|
"lint:fix": "eslint . --fix",
|