@lewebsimple/nuxt-graphql 0.3.2 → 0.3.3
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/module.json +1 -1
- package/dist/module.mjs +38 -17
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -215,6 +215,24 @@ function getRemoteExecMiddlewareProxy(middlewarePath) {
|
|
|
215
215
|
].join("\n");
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
function getDummySchemaProxy() {
|
|
219
|
+
return [
|
|
220
|
+
`import { createSchema } from "graphql-yoga";`,
|
|
221
|
+
``,
|
|
222
|
+
`export const schema = createSchema({`,
|
|
223
|
+
` typeDefs: /* GraphQL */ \``,
|
|
224
|
+
` type Query {`,
|
|
225
|
+
` hello: String!`,
|
|
226
|
+
` } `,
|
|
227
|
+
` \`,`,
|
|
228
|
+
` resolvers: {`,
|
|
229
|
+
` Query: {`,
|
|
230
|
+
` hello: () => "Hello world!",`,
|
|
231
|
+
` },`,
|
|
232
|
+
` },`,
|
|
233
|
+
`});`
|
|
234
|
+
].join("\n");
|
|
235
|
+
}
|
|
218
236
|
async function getLocalSchemaProxy({ layerRootDirs, schemaDef }) {
|
|
219
237
|
const schemaPath = await findSingleFile(layerRootDirs, schemaDef.path, true);
|
|
220
238
|
const content = [
|
|
@@ -329,26 +347,29 @@ const module$1 = defineNuxtModule({
|
|
|
329
347
|
serverProxies["context"] = getGraphQLContextProxy(contextPath);
|
|
330
348
|
serverProxies["remote-executor"] = getGenericServerProxy(resolve("./runtime/server/lib/remote-executor.ts"));
|
|
331
349
|
if (Object.keys(options.schemas || {}).length === 0) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
350
|
+
logger.warn("No GraphQL schemas defined in nuxt.config.ts, using dummy schema.");
|
|
351
|
+
serverProxies["schemas/dummy"] = getDummySchemaProxy();
|
|
352
|
+
serverProxies["schema"] = await getStitchedSchemaProxy({ schemaNames: ["dummy"] });
|
|
353
|
+
} else {
|
|
354
|
+
for (const [schemaName, schemaDef] of Object.entries(options.schemas)) {
|
|
355
|
+
switch (schemaDef.type) {
|
|
356
|
+
case "local": {
|
|
357
|
+
serverProxies[`schemas/${schemaName}`] = await getLocalSchemaProxy({ layerRootDirs, schemaDef });
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "remote": {
|
|
361
|
+
const { middlewareContent, sdlContent, schemaContent } = await getRemoteSchemaProxy({ rootDir, schemaName, schemaDef });
|
|
362
|
+
serverProxies[`schemas/${schemaName}-middleware`] = middlewareContent;
|
|
363
|
+
serverProxies[`schemas/${schemaName}-sdl`] = sdlContent;
|
|
364
|
+
serverProxies[`schemas/${schemaName}`] = schemaContent;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
default:
|
|
368
|
+
throw new Error(`Unsupported GraphQL schema type: ${schemaDef.type}`);
|
|
346
369
|
}
|
|
347
|
-
default:
|
|
348
|
-
throw new Error(`Unsupported GraphQL schema type: ${schemaDef.type}`);
|
|
349
370
|
}
|
|
371
|
+
serverProxies["schema"] = await getStitchedSchemaProxy({ schemaNames: Object.keys(options.schemas) });
|
|
350
372
|
}
|
|
351
|
-
serverProxies["schema"] = await getStitchedSchemaProxy({ schemaNames: Object.keys(options.schemas) });
|
|
352
373
|
if (options.middleware) {
|
|
353
374
|
const yogaMiddlewarePath = await findSingleFile(layerRootDirs, options.middleware, true);
|
|
354
375
|
logger.info(`GraphQL Yoga middleware registered: ${cyan}${toRelativePath(nuxt.options.rootDir, yogaMiddlewarePath)}${reset}`);
|