nitro-graphql 2.0.0-beta.31 → 2.0.0-beta.33
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/codegen/client-types.d.mts +13 -0
- package/dist/codegen/client-types.mjs +131 -0
- package/dist/codegen/external-types.d.mts +12 -0
- package/dist/codegen/external-types.mjs +88 -0
- package/dist/codegen/index.d.mts +18 -0
- package/dist/codegen/index.mjs +24 -0
- package/dist/codegen/server-types.d.mts +13 -0
- package/dist/codegen/server-types.mjs +64 -0
- package/dist/codegen/validation.d.mts +13 -0
- package/dist/codegen/validation.mjs +96 -0
- package/dist/config/defaults.mjs +36 -0
- package/dist/constants/scalars.mjs +27 -0
- package/dist/constants.mjs +106 -0
- package/dist/ecosystem/nuxt.mjs +3 -3
- package/dist/rollup.d.mts +2 -8
- package/dist/rollup.mjs +24 -199
- package/dist/routes/apollo-server.d.mts +2 -2
- package/dist/routes/apollo-server.mjs +7 -51
- package/dist/routes/debug-template.d.mts +15 -0
- package/dist/routes/debug-template.mjs +385 -0
- package/dist/routes/debug.d.mts +2 -2
- package/dist/routes/debug.mjs +1 -344
- package/dist/routes/graphql-yoga.d.mts +2 -2
- package/dist/routes/graphql-yoga.mjs +7 -51
- package/dist/routes/health.d.mts +2 -2
- package/dist/setup/file-watcher.mjs +84 -0
- package/dist/setup/graphql-scanner.mjs +25 -0
- package/dist/setup/rollup-integration.mjs +90 -0
- package/dist/setup/scaffold-generator.mjs +109 -0
- package/dist/setup/ts-config.mjs +69 -0
- package/dist/setup.d.mts +2 -2
- package/dist/setup.mjs +147 -303
- package/dist/types/index.d.mts +2 -2
- package/dist/utils/client-codegen.d.mts +1 -1
- package/dist/utils/client-codegen.mjs +5 -28
- package/dist/utils/codegen-plugin.d.mts +20 -0
- package/dist/utils/codegen-plugin.mjs +30 -0
- package/dist/utils/directive-parser.d.mts +2 -1
- package/dist/utils/directive-parser.mjs +4 -2
- package/dist/utils/federation.d.mts +29 -0
- package/dist/utils/federation.mjs +40 -0
- package/dist/utils/file-generator.mjs +1 -1
- package/dist/utils/file-writer.d.mts +35 -0
- package/dist/utils/file-writer.mjs +32 -0
- package/dist/utils/imports.d.mts +15 -0
- package/dist/utils/imports.mjs +25 -0
- package/dist/utils/index.d.mts +11 -38
- package/dist/utils/index.mjs +10 -287
- package/dist/utils/layers.d.mts +22 -0
- package/dist/utils/layers.mjs +28 -0
- package/dist/utils/ofetch-templates.d.mts +30 -0
- package/dist/utils/ofetch-templates.mjs +135 -0
- package/dist/utils/path-resolver.d.mts +2 -2
- package/dist/utils/path-resolver.mjs +2 -2
- package/dist/utils/scanning/common.d.mts +23 -0
- package/dist/utils/scanning/common.mjs +39 -0
- package/dist/utils/scanning/directives.d.mts +11 -0
- package/dist/utils/scanning/directives.mjs +43 -0
- package/dist/utils/scanning/documents.d.mts +15 -0
- package/dist/utils/scanning/documents.mjs +46 -0
- package/dist/utils/scanning/index.d.mts +6 -0
- package/dist/utils/scanning/index.mjs +7 -0
- package/dist/utils/scanning/resolvers.d.mts +11 -0
- package/dist/utils/scanning/resolvers.mjs +100 -0
- package/dist/utils/scanning/schemas.d.mts +15 -0
- package/dist/utils/scanning/schemas.mjs +29 -0
- package/dist/utils/schema-builder.d.mts +48 -0
- package/dist/utils/schema-builder.mjs +51 -0
- package/dist/utils/server-codegen.mjs +4 -27
- package/dist/utils/type-generation.d.mts +6 -12
- package/dist/utils/type-generation.mjs +6 -419
- package/dist/utils/validation.d.mts +11 -0
- package/dist/utils/validation.mjs +34 -0
- package/dist/virtual/generators/config.d.mts +22 -0
- package/dist/virtual/generators/config.mjs +36 -0
- package/dist/virtual/generators/debug.d.mts +14 -0
- package/dist/virtual/generators/debug.mjs +53 -0
- package/dist/virtual/generators/directives.d.mts +14 -0
- package/dist/virtual/generators/directives.mjs +52 -0
- package/dist/virtual/generators/index.d.mts +6 -0
- package/dist/virtual/generators/index.mjs +7 -0
- package/dist/virtual/generators/resolvers.d.mts +14 -0
- package/dist/virtual/generators/resolvers.mjs +55 -0
- package/dist/virtual/generators/schemas.d.mts +14 -0
- package/dist/virtual/generators/schemas.mjs +43 -0
- package/package.json +75 -57
package/dist/routes/debug.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { generateHtmlDashboard } from "./debug-template.mjs";
|
|
1
2
|
import { moduleConfig } from "#nitro-graphql/module-config";
|
|
2
3
|
import { directives } from "#nitro-graphql/server-directives";
|
|
3
4
|
import { resolvers } from "#nitro-graphql/server-resolvers";
|
|
@@ -96,350 +97,6 @@ var debug_default = defineEventHandler(async (event) => {
|
|
|
96
97
|
event.res.headers.set("Content-Type", "text/html");
|
|
97
98
|
return generateHtmlDashboard(fullDebugInfo);
|
|
98
99
|
});
|
|
99
|
-
function generateHtmlDashboard(debugInfo$1) {
|
|
100
|
-
return `<!DOCTYPE html>
|
|
101
|
-
<html lang="en">
|
|
102
|
-
<head>
|
|
103
|
-
<meta charset="UTF-8">
|
|
104
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
105
|
-
<title>Nitro GraphQL Debug Dashboard</title>
|
|
106
|
-
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"><\/script>
|
|
107
|
-
<style>
|
|
108
|
-
@keyframes fadeIn {
|
|
109
|
-
from { opacity: 0; transform: translateY(10px); }
|
|
110
|
-
to { opacity: 1; transform: translateY(0); }
|
|
111
|
-
}
|
|
112
|
-
.animate-fade-in {
|
|
113
|
-
animation: fadeIn 0.3s ease-out;
|
|
114
|
-
}
|
|
115
|
-
/* Custom Scrollbar */
|
|
116
|
-
::-webkit-scrollbar {
|
|
117
|
-
width: 8px;
|
|
118
|
-
height: 8px;
|
|
119
|
-
}
|
|
120
|
-
::-webkit-scrollbar-track {
|
|
121
|
-
background: #0f172a;
|
|
122
|
-
border-radius: 4px;
|
|
123
|
-
}
|
|
124
|
-
::-webkit-scrollbar-thumb {
|
|
125
|
-
background: #334155;
|
|
126
|
-
border-radius: 4px;
|
|
127
|
-
}
|
|
128
|
-
::-webkit-scrollbar-thumb:hover {
|
|
129
|
-
background: #475569;
|
|
130
|
-
}
|
|
131
|
-
</style>
|
|
132
|
-
</head>
|
|
133
|
-
<body class="bg-slate-950 text-slate-200 min-h-screen">
|
|
134
|
-
<div class="container mx-auto max-w-7xl p-6 space-y-6 animate-fade-in">
|
|
135
|
-
<!-- Header -->
|
|
136
|
-
<div class="mb-8 border-b border-slate-800 pb-6">
|
|
137
|
-
<div class="flex items-center gap-3 mb-2">
|
|
138
|
-
<svg class="w-10 h-10" viewBox="0 0 400 400" fill="none">
|
|
139
|
-
<path d="M57.468 302.66l-14.376-8.3 160.15-277.38 14.376 8.3z" fill="#E535AB"/>
|
|
140
|
-
<path d="M39.8 272.2h320.3v16.6H39.8z" fill="#E535AB"/>
|
|
141
|
-
<path d="M206.348 374.026l-160.21-92.5 8.3-14.376 160.21 92.5z" fill="#E535AB"/>
|
|
142
|
-
<path d="M345.522 132.947l-160.21-92.5 8.3-14.376 160.21 92.5z" fill="#E535AB"/>
|
|
143
|
-
<path d="M54.482 132.883l-8.3-14.375 160.21-92.5 8.3 14.376z" fill="#E535AB"/>
|
|
144
|
-
<path d="M342.568 302.663l-160.15-277.38 14.376-8.3 160.15 277.38z" fill="#E535AB"/>
|
|
145
|
-
<path d="M52.5 107.5h16.6v185H52.5z" fill="#E535AB"/>
|
|
146
|
-
<path d="M330.9 107.5h16.6v185h-16.6z" fill="#E535AB"/>
|
|
147
|
-
<path d="M203.522 367l-7.25-12.558 139.34-80.45 7.25 12.557z" fill="#E535AB"/>
|
|
148
|
-
<path d="M369.5 297.9c-9.6 16.7-31 22.4-47.7 12.8-16.7-9.6-22.4-31-12.8-47.7 9.6-16.7 31-22.4 47.7-12.8 16.8 9.7 22.5 31 12.8 47.7M90.9 137c-9.6 16.7-31 22.4-47.7 12.8-16.7-9.6-22.4-31-12.8-47.7 9.6-16.7 31-22.4 47.7-12.8 16.7 9.7 22.4 31 12.8 47.7M30.5 297.9c-9.6-16.7-3.9-38 12.8-47.7 16.7-9.6 38-3.9 47.7 12.8 9.6 16.7 3.9 38-12.8 47.7-16.8 9.6-38.1 3.9-47.7-12.8M309.1 137c-9.6-16.7-3.9-38 12.8-47.7 16.7-9.6 38-3.9 47.7 12.8 9.6 16.7 3.9 38-12.8 47.7-16.7 9.6-38.1 3.9-47.7-12.8M200 395.8c-19.3 0-34.9-15.6-34.9-34.9 0-19.3 15.6-34.9 34.9-34.9 19.3 0 34.9 15.6 34.9 34.9 0 19.2-15.6 34.9-34.9 34.9M200 74c-19.3 0-34.9-15.6-34.9-34.9 0-19.3 15.6-34.9 34.9-34.9 19.3 0 34.9 15.6 34.9 34.9 0 19.3-15.6 34.9-34.9 34.9" fill="#E535AB"/>
|
|
149
|
-
</svg>
|
|
150
|
-
<div>
|
|
151
|
-
<h1 class="text-3xl font-bold text-slate-100">
|
|
152
|
-
Nitro GraphQL Debug
|
|
153
|
-
</h1>
|
|
154
|
-
<p class="text-sm text-slate-500">Development Diagnostics Dashboard</p>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
|
|
159
|
-
<!-- Top Stats Grid -->
|
|
160
|
-
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
161
|
-
<!-- Environment Card -->
|
|
162
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
163
|
-
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
164
|
-
<span class="text-[#E535AB]">●</span> Environment
|
|
165
|
-
</h2>
|
|
166
|
-
<div class="space-y-3">
|
|
167
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
168
|
-
<span class="text-slate-400 text-sm">Mode</span>
|
|
169
|
-
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.environment.dev ? "Development" : "Production"}</span>
|
|
170
|
-
</div>
|
|
171
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
172
|
-
<span class="text-slate-400 text-sm">Framework</span>
|
|
173
|
-
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.environment.framework}</span>
|
|
174
|
-
</div>
|
|
175
|
-
<div class="flex justify-between items-center py-2">
|
|
176
|
-
<span class="text-slate-400 text-sm">GraphQL Server</span>
|
|
177
|
-
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.graphql.framework || "Not configured"}</span>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
<!-- Scanned Files Card -->
|
|
183
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
184
|
-
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
185
|
-
<span class="text-[#E535AB]">●</span> Scanned Files
|
|
186
|
-
</h2>
|
|
187
|
-
<div class="space-y-3">
|
|
188
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
189
|
-
<span class="text-slate-400 text-sm">Schemas</span>
|
|
190
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.schemas}</span>
|
|
191
|
-
</div>
|
|
192
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
193
|
-
<span class="text-slate-400 text-sm">Resolvers</span>
|
|
194
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.resolvers}</span>
|
|
195
|
-
</div>
|
|
196
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
197
|
-
<span class="text-slate-400 text-sm">Directives</span>
|
|
198
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.directives}</span>
|
|
199
|
-
</div>
|
|
200
|
-
<div class="flex justify-between items-center py-2">
|
|
201
|
-
<span class="text-slate-400 text-sm">Documents</span>
|
|
202
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.documents}</span>
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<!-- Runtime Info Card -->
|
|
208
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
209
|
-
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
210
|
-
<span class="text-[#E535AB]">●</span> Runtime Loaded
|
|
211
|
-
</h2>
|
|
212
|
-
<div class="space-y-3">
|
|
213
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
214
|
-
<span class="text-slate-400 text-sm">Resolvers</span>
|
|
215
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedResolvers}</span>
|
|
216
|
-
</div>
|
|
217
|
-
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
218
|
-
<span class="text-slate-400 text-sm">Schemas</span>
|
|
219
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedSchemas}</span>
|
|
220
|
-
</div>
|
|
221
|
-
<div class="flex justify-between items-center py-2">
|
|
222
|
-
<span class="text-slate-400 text-sm">Directives</span>
|
|
223
|
-
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedDirectives}</span>
|
|
224
|
-
</div>
|
|
225
|
-
</div>
|
|
226
|
-
</div>
|
|
227
|
-
</div>
|
|
228
|
-
|
|
229
|
-
<!-- Resolver Exports -->
|
|
230
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6">
|
|
231
|
-
<div class="flex justify-between items-center mb-4">
|
|
232
|
-
<h2 class="text-xl font-semibold text-slate-200 flex items-center gap-2">
|
|
233
|
-
<span class="text-[#E535AB]">●</span> Resolver Exports
|
|
234
|
-
</h2>
|
|
235
|
-
${debugInfo$1.scanned.resolverFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.resolverFiles.length} files</span>` : ""}
|
|
236
|
-
</div>
|
|
237
|
-
${debugInfo$1.scanned.resolverFiles.length > 0 ? `
|
|
238
|
-
<div class="max-h-96 overflow-y-auto space-y-2 pr-2">
|
|
239
|
-
${debugInfo$1.scanned.resolverFiles.map((r) => {
|
|
240
|
-
const totalExports = r.exports.length;
|
|
241
|
-
return `
|
|
242
|
-
<div class="border border-slate-700/50 rounded-lg p-4 hover:border-[#E535AB]/20 hover:bg-slate-800/30 transition-all">
|
|
243
|
-
<div class="flex justify-between items-center mb-3">
|
|
244
|
-
<span class="text-slate-300 font-mono text-xs truncate pr-2">${r.file}</span>
|
|
245
|
-
<span class="bg-slate-800/80 px-2.5 py-0.5 rounded text-[#E535AB] text-[10px] font-semibold whitespace-nowrap">
|
|
246
|
-
${totalExports} export${totalExports !== 1 ? "s" : ""}
|
|
247
|
-
</span>
|
|
248
|
-
</div>
|
|
249
|
-
<div class="flex flex-wrap gap-1.5">
|
|
250
|
-
${r.exports.map((e) => {
|
|
251
|
-
const typeConfig = {
|
|
252
|
-
query: {
|
|
253
|
-
bg: "bg-blue-500/10",
|
|
254
|
-
text: "text-blue-400",
|
|
255
|
-
border: "border-blue-500/30",
|
|
256
|
-
symbol: "◆",
|
|
257
|
-
label: "query"
|
|
258
|
-
},
|
|
259
|
-
mutation: {
|
|
260
|
-
bg: "bg-[#E535AB]/10",
|
|
261
|
-
text: "text-[#E535AB]",
|
|
262
|
-
border: "border-[#E535AB]/30",
|
|
263
|
-
symbol: "●",
|
|
264
|
-
label: "mutation"
|
|
265
|
-
},
|
|
266
|
-
type: {
|
|
267
|
-
bg: "bg-purple-500/10",
|
|
268
|
-
text: "text-purple-400",
|
|
269
|
-
border: "border-purple-500/30",
|
|
270
|
-
symbol: "▲",
|
|
271
|
-
label: "type"
|
|
272
|
-
},
|
|
273
|
-
directive: {
|
|
274
|
-
bg: "bg-amber-500/10",
|
|
275
|
-
text: "text-amber-400",
|
|
276
|
-
border: "border-amber-500/30",
|
|
277
|
-
symbol: "@",
|
|
278
|
-
label: "directive"
|
|
279
|
-
},
|
|
280
|
-
resolver: {
|
|
281
|
-
bg: "bg-emerald-500/10",
|
|
282
|
-
text: "text-emerald-400",
|
|
283
|
-
border: "border-emerald-500/30",
|
|
284
|
-
symbol: "◉",
|
|
285
|
-
label: "resolver"
|
|
286
|
-
},
|
|
287
|
-
subscription: {
|
|
288
|
-
bg: "bg-teal-500/10",
|
|
289
|
-
text: "text-teal-400",
|
|
290
|
-
border: "border-teal-500/30",
|
|
291
|
-
symbol: "↻",
|
|
292
|
-
label: "subscription"
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
const config = typeConfig[e.type] || typeConfig.resolver;
|
|
296
|
-
return `<span class="px-2.5 py-1 rounded border text-[11px] font-mono ${config.bg} ${config.text} ${config.border} hover:scale-105 transition-transform inline-flex items-center gap-1.5">
|
|
297
|
-
<span class="font-bold">${config.symbol}</span>
|
|
298
|
-
<span class="font-medium">${e.name}</span>
|
|
299
|
-
<span class="opacity-60 text-[9px] uppercase tracking-wide">${config.label}</span>
|
|
300
|
-
</span>`;
|
|
301
|
-
}).join("")}
|
|
302
|
-
</div>
|
|
303
|
-
</div>
|
|
304
|
-
`;
|
|
305
|
-
}).join("")}
|
|
306
|
-
</div>
|
|
307
|
-
` : "<p class=\"text-slate-500 text-sm\">No resolvers found</p>"}
|
|
308
|
-
</div>
|
|
309
|
-
|
|
310
|
-
<!-- Generated Virtual Modules -->
|
|
311
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6">
|
|
312
|
-
<div class="flex justify-between items-center mb-4">
|
|
313
|
-
<h2 class="text-xl font-semibold text-slate-200 flex items-center gap-2">
|
|
314
|
-
<span class="text-[#E535AB]">●</span> Generated Virtual Modules
|
|
315
|
-
</h2>
|
|
316
|
-
<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">
|
|
317
|
-
${Object.keys(debugInfo$1.virtualModules).length} modules
|
|
318
|
-
</span>
|
|
319
|
-
</div>
|
|
320
|
-
<div class="space-y-3">
|
|
321
|
-
${Object.entries(debugInfo$1.virtualModules).map(([moduleName, codeContent]) => {
|
|
322
|
-
const code = String(codeContent);
|
|
323
|
-
const moduleColors = {
|
|
324
|
-
"server-schemas": {
|
|
325
|
-
bg: "bg-blue-500/5",
|
|
326
|
-
border: "border-blue-500/20",
|
|
327
|
-
text: "text-blue-400"
|
|
328
|
-
},
|
|
329
|
-
"server-resolvers": {
|
|
330
|
-
bg: "bg-[#E535AB]/5",
|
|
331
|
-
border: "border-[#E535AB]/20",
|
|
332
|
-
text: "text-[#E535AB]"
|
|
333
|
-
},
|
|
334
|
-
"server-directives": {
|
|
335
|
-
bg: "bg-amber-500/5",
|
|
336
|
-
border: "border-amber-500/20",
|
|
337
|
-
text: "text-amber-400"
|
|
338
|
-
},
|
|
339
|
-
"module-config": {
|
|
340
|
-
bg: "bg-purple-500/5",
|
|
341
|
-
border: "border-purple-500/20",
|
|
342
|
-
text: "text-purple-400"
|
|
343
|
-
},
|
|
344
|
-
"graphql-config": {
|
|
345
|
-
bg: "bg-emerald-500/5",
|
|
346
|
-
border: "border-emerald-500/20",
|
|
347
|
-
text: "text-emerald-400"
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
const colorConfig = moduleColors[moduleName] || moduleColors["module-config"];
|
|
351
|
-
const lineCount = code.split("\\n").length;
|
|
352
|
-
const byteSize = new TextEncoder().encode(code).length;
|
|
353
|
-
return `
|
|
354
|
-
<details class="border ${colorConfig.border} ${colorConfig.bg} rounded-lg overflow-hidden group">
|
|
355
|
-
<summary class="cursor-pointer p-4 hover:bg-slate-800/30 transition-all flex justify-between items-center">
|
|
356
|
-
<div class="flex items-center gap-3">
|
|
357
|
-
<span class="${colorConfig.text} text-lg">▸</span>
|
|
358
|
-
<div>
|
|
359
|
-
<span class="font-mono text-sm ${colorConfig.text} font-semibold">#nitro-graphql/${moduleName}</span>
|
|
360
|
-
<div class="text-[10px] text-slate-500 mt-0.5">
|
|
361
|
-
${lineCount} lines · ${(byteSize / 1024).toFixed(2)} KB
|
|
362
|
-
</div>
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
<button
|
|
366
|
-
onclick="event.stopPropagation(); navigator.clipboard.writeText(this.getAttribute('data-code')); this.textContent = '✓ Copied!'; setTimeout(() => this.textContent = 'Copy', 1000)"
|
|
367
|
-
data-code="${escapeHtml(code).replace(/"/g, """)}"
|
|
368
|
-
class="text-xs px-3 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded border border-slate-600/50 transition-colors"
|
|
369
|
-
>
|
|
370
|
-
Copy
|
|
371
|
-
</button>
|
|
372
|
-
</summary>
|
|
373
|
-
<div class="border-t ${colorConfig.border}">
|
|
374
|
-
<div class="bg-slate-950/80 p-4 max-h-96 overflow-auto">
|
|
375
|
-
<pre class="text-xs font-mono text-slate-300 leading-relaxed"><code>${escapeHtml(code)}</code></pre>
|
|
376
|
-
</div>
|
|
377
|
-
</div>
|
|
378
|
-
</details>
|
|
379
|
-
`;
|
|
380
|
-
}).join("")}
|
|
381
|
-
</div>
|
|
382
|
-
</div>
|
|
383
|
-
|
|
384
|
-
<!-- Files Grid -->
|
|
385
|
-
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
386
|
-
<!-- Schema Files -->
|
|
387
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
388
|
-
<div class="flex justify-between items-center mb-4">
|
|
389
|
-
<h2 class="text-lg font-semibold text-slate-200 flex items-center gap-2">
|
|
390
|
-
<span class="text-[#E535AB]">●</span> Schema Files
|
|
391
|
-
</h2>
|
|
392
|
-
${debugInfo$1.scanned.schemaFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.schemaFiles.length} file${debugInfo$1.scanned.schemaFiles.length !== 1 ? "s" : ""}</span>` : ""}
|
|
393
|
-
</div>
|
|
394
|
-
<ul class="space-y-2 max-h-64 overflow-y-auto pr-2">
|
|
395
|
-
${debugInfo$1.scanned.schemaFiles.length > 0 ? debugInfo$1.scanned.schemaFiles.map((f) => `<li class="text-slate-400 font-mono text-xs flex items-start gap-2 py-1.5 px-2 rounded hover:bg-slate-800/50 transition-colors group">
|
|
396
|
-
<span class="text-[#E535AB] text-[10px] mt-0.5 group-hover:scale-110 transition-transform">▸</span>
|
|
397
|
-
<span class="truncate group-hover:text-slate-300">${f}</span>
|
|
398
|
-
</li>`).join("") : "<li class=\"text-slate-500 text-sm\">No schemas found</li>"}
|
|
399
|
-
</ul>
|
|
400
|
-
</div>
|
|
401
|
-
|
|
402
|
-
<!-- Document Files -->
|
|
403
|
-
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
404
|
-
<div class="flex justify-between items-center mb-4">
|
|
405
|
-
<h2 class="text-lg font-semibold text-slate-200 flex items-center gap-2">
|
|
406
|
-
<span class="text-[#E535AB]">●</span> Document Files
|
|
407
|
-
</h2>
|
|
408
|
-
${debugInfo$1.scanned.documentFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.documentFiles.length} file${debugInfo$1.scanned.documentFiles.length !== 1 ? "s" : ""}</span>` : ""}
|
|
409
|
-
</div>
|
|
410
|
-
<ul class="space-y-2 max-h-64 overflow-y-auto pr-2">
|
|
411
|
-
${debugInfo$1.scanned.documentFiles.length > 0 ? debugInfo$1.scanned.documentFiles.map((f) => `<li class="text-slate-400 font-mono text-xs flex items-start gap-2 py-1.5 px-2 rounded hover:bg-slate-800/50 transition-colors group">
|
|
412
|
-
<span class="text-[#E535AB] text-[10px] mt-0.5 group-hover:scale-110 transition-transform">▸</span>
|
|
413
|
-
<span class="truncate group-hover:text-slate-300">${f}</span>
|
|
414
|
-
</li>`).join("") : "<li class=\"text-slate-500 text-sm\">No documents found</li>"}
|
|
415
|
-
</ul>
|
|
416
|
-
</div>
|
|
417
|
-
</div>
|
|
418
|
-
|
|
419
|
-
<!-- Reload Button -->
|
|
420
|
-
<button
|
|
421
|
-
onclick="location.reload()"
|
|
422
|
-
class="fixed bottom-8 right-8 bg-[#E535AB] hover:bg-[#d12a99] text-white font-semibold px-6 py-3 rounded-lg shadow-lg hover:shadow-xl hover:shadow-[#E535AB]/20 transform hover:-translate-y-1 transition-all duration-200 flex items-center gap-2 border border-[#E535AB]/20"
|
|
423
|
-
>
|
|
424
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
425
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
|
426
|
-
</svg>
|
|
427
|
-
Reload
|
|
428
|
-
</button>
|
|
429
|
-
</div>
|
|
430
|
-
</body>
|
|
431
|
-
</html>`;
|
|
432
|
-
}
|
|
433
|
-
function escapeHtml(text) {
|
|
434
|
-
const map = {
|
|
435
|
-
"&": "&",
|
|
436
|
-
"<": "<",
|
|
437
|
-
">": ">",
|
|
438
|
-
"\"": """,
|
|
439
|
-
"'": "'"
|
|
440
|
-
};
|
|
441
|
-
return text.replace(/[&<>"']/g, (m) => map[m] || m);
|
|
442
|
-
}
|
|
443
100
|
|
|
444
101
|
//#endregion
|
|
445
102
|
export { debug_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h31 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_h31.EventHandlerWithFetch<nitro_deps_h31.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
+
import { createMergedSchema } from "../utils/schema-builder.mjs";
|
|
1
2
|
import defu from "defu";
|
|
2
|
-
import { consola as consola$1 } from "consola";
|
|
3
|
-
import { parse } from "graphql";
|
|
4
|
-
import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
|
|
5
3
|
import { importedConfig } from "#nitro-graphql/graphql-config";
|
|
6
4
|
import { moduleConfig } from "#nitro-graphql/module-config";
|
|
7
5
|
import { directives } from "#nitro-graphql/server-directives";
|
|
8
6
|
import { resolvers } from "#nitro-graphql/server-resolvers";
|
|
9
7
|
import { schemas } from "#nitro-graphql/server-schemas";
|
|
10
|
-
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
11
8
|
import { defineEventHandler } from "nitro/h3";
|
|
12
9
|
import { createYoga } from "graphql-yoga";
|
|
13
10
|
|
|
14
11
|
//#region src/routes/graphql-yoga.ts
|
|
15
|
-
let buildSubgraphSchema = null;
|
|
16
|
-
async function loadFederationSupport() {
|
|
17
|
-
if (buildSubgraphSchema !== null) return buildSubgraphSchema;
|
|
18
|
-
try {
|
|
19
|
-
buildSubgraphSchema = (await import("@apollo/subgraph")).buildSubgraphSchema;
|
|
20
|
-
} catch {
|
|
21
|
-
buildSubgraphSchema = false;
|
|
22
|
-
}
|
|
23
|
-
return buildSubgraphSchema;
|
|
24
|
-
}
|
|
25
12
|
const apolloSandboxHtml = `<!DOCTYPE html>
|
|
26
13
|
<html lang="en">
|
|
27
14
|
<body style="margin: 0; overflow-x: hidden; overflow-y: hidden">
|
|
@@ -39,46 +26,15 @@ new window.EmbeddedSandbox({
|
|
|
39
26
|
<\/script>
|
|
40
27
|
</body>
|
|
41
28
|
</html>`;
|
|
42
|
-
async function createMergedSchema() {
|
|
43
|
-
try {
|
|
44
|
-
const typeDefs = mergeTypeDefs([schemas.map((schema$1) => schema$1.def).join("\n\n")], {
|
|
45
|
-
throwOnConflict: true,
|
|
46
|
-
commentDescriptions: true,
|
|
47
|
-
sort: true
|
|
48
|
-
});
|
|
49
|
-
const mergedResolvers = mergeResolvers(resolvers.map((r) => r.resolver));
|
|
50
|
-
const federationEnabled = moduleConfig.federation?.enabled;
|
|
51
|
-
let schema;
|
|
52
|
-
if (federationEnabled) {
|
|
53
|
-
const buildSubgraph = await loadFederationSupport();
|
|
54
|
-
if (buildSubgraph) schema = buildSubgraph({
|
|
55
|
-
typeDefs: typeof typeDefs === "string" ? parse(typeDefs) : typeDefs,
|
|
56
|
-
resolvers: mergedResolvers
|
|
57
|
-
});
|
|
58
|
-
else {
|
|
59
|
-
console.warn("Federation enabled but @apollo/subgraph not available, falling back to regular schema");
|
|
60
|
-
schema = makeExecutableSchema({
|
|
61
|
-
typeDefs,
|
|
62
|
-
resolvers: mergedResolvers
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
} else schema = makeExecutableSchema({
|
|
66
|
-
typeDefs,
|
|
67
|
-
resolvers: mergedResolvers
|
|
68
|
-
});
|
|
69
|
-
if (directives && directives.length > 0) {
|
|
70
|
-
for (const { directive } of directives) if (directive.transformer) schema = directive.transformer(schema);
|
|
71
|
-
}
|
|
72
|
-
return schema;
|
|
73
|
-
} catch (error) {
|
|
74
|
-
consola$1.error("Schema merge error:", error);
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
29
|
let yoga;
|
|
79
30
|
var graphql_yoga_default = defineEventHandler(async (event) => {
|
|
80
31
|
if (!yoga) yoga = createYoga(defu({
|
|
81
|
-
schema: await createMergedSchema(
|
|
32
|
+
schema: await createMergedSchema({
|
|
33
|
+
schemas,
|
|
34
|
+
resolvers,
|
|
35
|
+
directives,
|
|
36
|
+
moduleConfig
|
|
37
|
+
}),
|
|
82
38
|
graphqlEndpoint: "/api/graphql",
|
|
83
39
|
landingPage: false,
|
|
84
40
|
renderGraphiQL: () => apolloSandboxHtml
|
package/dist/routes/health.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nitro_deps_h33 from "nitro/deps/h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: nitro_deps_h33.EventHandlerWithFetch<nitro_deps_h33.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DIRECTIVE_EXTENSIONS, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, GRAPHQL_EXTENSIONS, LOG_TAG, RESOLVER_EXTENSIONS } from "../constants.mjs";
|
|
2
|
+
import { generateServerTypes } from "../codegen/server-types.mjs";
|
|
3
|
+
import { generateClientTypes } from "../codegen/index.mjs";
|
|
4
|
+
import { DEFAULT_WATCHER_IGNORE_INITIAL, DEFAULT_WATCHER_PERSISTENT } from "../config/defaults.mjs";
|
|
5
|
+
import { generateDirectiveSchemas } from "../utils/directive-parser.mjs";
|
|
6
|
+
import { generateLayerIgnorePatterns, getLayerAppDirectories, getLayerServerDirectories } from "../utils/layers.mjs";
|
|
7
|
+
import { scanDirectives } from "../utils/scanning/directives.mjs";
|
|
8
|
+
import { scanResolvers } from "../utils/scanning/resolvers.mjs";
|
|
9
|
+
import { scanSchemas } from "../utils/scanning/schemas.mjs";
|
|
10
|
+
import consola from "consola";
|
|
11
|
+
import { join } from "pathe";
|
|
12
|
+
import { watch } from "chokidar";
|
|
13
|
+
|
|
14
|
+
//#region src/setup/file-watcher.ts
|
|
15
|
+
const logger = consola.withTag(LOG_TAG);
|
|
16
|
+
/**
|
|
17
|
+
* Setup file watcher for GraphQL files (schemas, resolvers, directives, documents)
|
|
18
|
+
* Watches for changes and triggers type regeneration and dev server reload
|
|
19
|
+
*/
|
|
20
|
+
function setupFileWatcher(nitro, watchDirs) {
|
|
21
|
+
const watcher = watch(watchDirs, {
|
|
22
|
+
persistent: DEFAULT_WATCHER_PERSISTENT,
|
|
23
|
+
ignoreInitial: DEFAULT_WATCHER_IGNORE_INITIAL,
|
|
24
|
+
ignored: [...nitro.options.ignore, ...generateLayerIgnorePatterns()]
|
|
25
|
+
});
|
|
26
|
+
watcher.on("all", async (_, path) => {
|
|
27
|
+
const isGraphQLFile = GRAPHQL_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
28
|
+
const isResolverFile = RESOLVER_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
29
|
+
const isDirectiveFile = DIRECTIVE_EXTENSIONS.some((ext) => path.endsWith(ext));
|
|
30
|
+
if (isGraphQLFile || isResolverFile || isDirectiveFile) if (path.includes(nitro.graphql.serverDir) || path.includes(DIR_SERVER_GRAPHQL) || path.includes(DIR_SERVER_GRAPHQL_WIN) || isResolverFile || isDirectiveFile) {
|
|
31
|
+
const directives = await scanDirectives(nitro);
|
|
32
|
+
nitro.scanDirectives = directives;
|
|
33
|
+
if (!nitro.scanSchemas) nitro.scanSchemas = [];
|
|
34
|
+
const directivesPath = await generateDirectiveSchemas(nitro, directives);
|
|
35
|
+
const schemas = await scanSchemas(nitro);
|
|
36
|
+
if (directivesPath && !schemas.includes(directivesPath)) schemas.push(directivesPath);
|
|
37
|
+
nitro.scanSchemas = schemas;
|
|
38
|
+
await scanResolvers(nitro).then((r) => nitro.scanResolvers = r);
|
|
39
|
+
logger.success("Types regenerated");
|
|
40
|
+
await generateServerTypes(nitro, { silent: true });
|
|
41
|
+
await generateClientTypes(nitro, { silent: true });
|
|
42
|
+
await nitro.hooks.callHook("dev:reload");
|
|
43
|
+
} else {
|
|
44
|
+
logger.success("Types regenerated");
|
|
45
|
+
await generateClientTypes(nitro, { silent: true });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return watcher;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Determine which directories to watch based on framework and configuration
|
|
52
|
+
*/
|
|
53
|
+
function getWatchDirectories(nitro) {
|
|
54
|
+
const watchDirs = [];
|
|
55
|
+
switch (nitro.options.framework.name) {
|
|
56
|
+
case "nuxt": {
|
|
57
|
+
watchDirs.push(nitro.graphql.clientDir);
|
|
58
|
+
const layerServerDirs = getLayerServerDirectories(nitro);
|
|
59
|
+
const layerAppDirs = getLayerAppDirectories(nitro);
|
|
60
|
+
for (const layerServerDir of layerServerDirs) watchDirs.push(join(layerServerDir, "graphql"));
|
|
61
|
+
for (const layerAppDir of layerAppDirs) watchDirs.push(join(layerAppDir, "graphql"));
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "nitro":
|
|
65
|
+
watchDirs.push(nitro.graphql.clientDir);
|
|
66
|
+
watchDirs.push(nitro.graphql.serverDir);
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
watchDirs.push(nitro.graphql.clientDir);
|
|
70
|
+
watchDirs.push(nitro.graphql.serverDir);
|
|
71
|
+
}
|
|
72
|
+
if (nitro.options.graphql?.externalServices?.length) {
|
|
73
|
+
for (const service of nitro.options.graphql.externalServices) if (service.documents?.length) for (const pattern of service.documents) {
|
|
74
|
+
if (!pattern) continue;
|
|
75
|
+
const baseDir = pattern.split("**")[0]?.replace(/\/$/, "") || ".";
|
|
76
|
+
const resolvedDir = join(nitro.options.rootDir, baseDir);
|
|
77
|
+
if (!watchDirs.includes(resolvedDir)) watchDirs.push(resolvedDir);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return watchDirs;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { getWatchDirectories, setupFileWatcher };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { generateDirectiveSchemas } from "../utils/directive-parser.mjs";
|
|
2
|
+
import { scanDirectives } from "../utils/scanning/directives.mjs";
|
|
3
|
+
import { scanDocuments } from "../utils/scanning/documents.mjs";
|
|
4
|
+
import { scanResolvers } from "../utils/scanning/resolvers.mjs";
|
|
5
|
+
import { scanSchemas } from "../utils/scanning/schemas.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/setup/graphql-scanner.ts
|
|
8
|
+
/**
|
|
9
|
+
* Scan all GraphQL files and update Nitro state
|
|
10
|
+
* Used by both initial setup and dev:start hook
|
|
11
|
+
*/
|
|
12
|
+
async function scanAllGraphQLFiles(nitro) {
|
|
13
|
+
const directives = await scanDirectives(nitro);
|
|
14
|
+
nitro.scanDirectives = directives;
|
|
15
|
+
if (!nitro.scanSchemas) nitro.scanSchemas = [];
|
|
16
|
+
const directivesPath = await generateDirectiveSchemas(nitro, directives);
|
|
17
|
+
const schemas = await scanSchemas(nitro);
|
|
18
|
+
if (directivesPath && !schemas.includes(directivesPath)) schemas.push(directivesPath);
|
|
19
|
+
nitro.scanSchemas = schemas;
|
|
20
|
+
nitro.scanDocuments = await scanDocuments(nitro);
|
|
21
|
+
nitro.scanResolvers = await scanResolvers(nitro);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { scanAllGraphQLFiles };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, GRAPHQL_EXTENSIONS, RESOLVER_EXTENSIONS } from "../constants.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/setup/rollup-integration.ts
|
|
4
|
+
/**
|
|
5
|
+
* Setup Rollup/Rolldown chunking configuration for GraphQL files
|
|
6
|
+
* Creates separate chunks for schemas and resolvers to optimize bundle size
|
|
7
|
+
*/
|
|
8
|
+
function setupRollupChunking(nitro) {
|
|
9
|
+
nitro.hooks.hook("rollup:before", (_, rollupConfig) => {
|
|
10
|
+
const manualChunks = rollupConfig.output?.manualChunks;
|
|
11
|
+
const chunkFiles = rollupConfig.output?.chunkFileNames;
|
|
12
|
+
if (!rollupConfig.output.inlineDynamicImports) {
|
|
13
|
+
rollupConfig.output.manualChunks = (id, _meta) => {
|
|
14
|
+
if (isGraphQLFile(id)) return getSchemaChunkName(id);
|
|
15
|
+
if (isResolverFile(id)) return getResolverChunkName(id);
|
|
16
|
+
if (typeof manualChunks === "function") return manualChunks(id, meta);
|
|
17
|
+
};
|
|
18
|
+
rollupConfig.output.advancedChunks = {
|
|
19
|
+
groups: [{
|
|
20
|
+
name: CHUNK_NAME_SCHEMAS,
|
|
21
|
+
test: /* @__PURE__ */ new RegExp(`\\.(${GRAPHQL_EXTENSIONS.map((e) => e.slice(1)).join("|")})$`)
|
|
22
|
+
}, {
|
|
23
|
+
name: CHUNK_NAME_RESOLVERS,
|
|
24
|
+
test: /\.resolver\.(ts|js)$/
|
|
25
|
+
}],
|
|
26
|
+
minSize: 0,
|
|
27
|
+
minShareCount: 1
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
rollupConfig.output.chunkFileNames = (chunkInfo) => {
|
|
31
|
+
if (chunkInfo.moduleIds && chunkInfo.moduleIds.some((id) => isGraphQLFile(id) || isResolverFile(id))) return CHUNK_PATH_GRAPHQL;
|
|
32
|
+
if (typeof chunkFiles === "function") return chunkFiles(chunkInfo);
|
|
33
|
+
return CHUNK_PATH_UNKNOWN;
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a file is a GraphQL schema file
|
|
39
|
+
*/
|
|
40
|
+
function isGraphQLFile(id) {
|
|
41
|
+
return GRAPHQL_EXTENSIONS.some((ext) => id.endsWith(ext));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a file is a resolver file
|
|
45
|
+
*/
|
|
46
|
+
function isResolverFile(id) {
|
|
47
|
+
return RESOLVER_EXTENSIONS.some((ext) => id.endsWith(ext));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get chunk name for GraphQL schema files
|
|
51
|
+
* All schemas are bundled into a single chunk since GraphQL server
|
|
52
|
+
* merges them at runtime anyway - no benefit from separate chunks
|
|
53
|
+
*/
|
|
54
|
+
function getSchemaChunkName(_id) {
|
|
55
|
+
return CHUNK_NAME_SCHEMAS;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get chunk name for resolver files
|
|
59
|
+
* All resolvers are bundled into a single chunk since GraphQL server
|
|
60
|
+
* requires all resolvers to be registered at startup - no runtime lazy loading
|
|
61
|
+
*/
|
|
62
|
+
function getResolverChunkName(_id) {
|
|
63
|
+
return CHUNK_NAME_RESOLVERS;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Configure external dependencies for Rollup
|
|
67
|
+
* Marks codegen and federation packages as external
|
|
68
|
+
*/
|
|
69
|
+
function setupRollupExternals(nitro) {
|
|
70
|
+
nitro.hooks.hook("rollup:before", (_, rollupConfig) => {
|
|
71
|
+
rollupConfig.external = rollupConfig.external || [];
|
|
72
|
+
const allExternals = [...["oxc-parser", "@oxc-parser"]];
|
|
73
|
+
if (!nitro.options.graphql?.federation?.enabled) allExternals.push(...[
|
|
74
|
+
"@apollo/subgraph",
|
|
75
|
+
"@apollo/federation-internals",
|
|
76
|
+
"@apollo/cache-control-types"
|
|
77
|
+
]);
|
|
78
|
+
if (Array.isArray(rollupConfig.external)) rollupConfig.external.push(...allExternals);
|
|
79
|
+
else if (typeof rollupConfig.external === "function") {
|
|
80
|
+
const originalExternal = rollupConfig.external;
|
|
81
|
+
rollupConfig.external = (id, parent, isResolved) => {
|
|
82
|
+
if (allExternals.some((external) => id.includes(external))) return true;
|
|
83
|
+
return originalExternal(id, parent, isResolved);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { setupRollupChunking, setupRollupExternals };
|