nuxt-graphql-middleware 5.3.1 → 5.3.2

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.
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1766498306546,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1767614393800,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"2c5ed43d-9467-443e-93e6-e7235fa0768c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1766498306547,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1767614393800,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"2c5ed43d-9467-443e-93e6-e7235fa0768c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562","timestamp":1766498304481}
1
+ {"id":"2c5ed43d-9467-443e-93e6-e7235fa0768c","timestamp":1767614391495}
@@ -0,0 +1 @@
1
+ {"id":"2c5ed43d-9467-443e-93e6-e7235fa0768c","timestamp":1767614391495,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1766498306547,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cyocd7ae.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js"><script type="module" src="/__nuxt-graphql-middleware/_nuxt/DrXVleME.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1767614393800,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"2c5ed43d-9467-443e-93e6-e7235fa0768c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleContext, a as ModuleOptions } from './shared/nuxt-graphql-middleware.COufMnWs.mjs';
2
+ import { M as ModuleContext, a as ModuleOptions } from './shared/nuxt-graphql-middleware.B34q074V.mjs';
3
3
  import { OperationResponseError } from '../dist/runtime/types.js';
4
4
  import { HookResult } from 'nuxt/schema';
5
5
  import { GeneratorOutput } from 'graphql-typescript-deluxe';
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "5.3.1",
4
+ "version": "5.3.2",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.17.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -21,7 +21,7 @@ import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
21
21
  import { defineEventHandler, readBody, createError } from 'h3';
22
22
 
23
23
  const name = "nuxt-graphql-middleware";
24
- const version = "5.3.1";
24
+ const version = "5.3.2";
25
25
 
26
26
  const logger = useLogger("nuxt-graphql-middleware");
27
27
  const defaultOptions = {
@@ -715,7 +715,7 @@ class SchemaProvider {
715
715
  }
716
716
  async loadFromDiskFallback() {
717
717
  const hasSchemaOnDisk = await this.hasSchemaOnDisk();
718
- if (this.helper.isDev && hasSchemaOnDisk && this.helper.options.downloadSchema) {
718
+ if (this.helper.isDev && hasSchemaOnDisk && this.helper.shouldDownloadSchema()) {
719
719
  const shouldUseFromDisk = await this.helper.prompt.confirm(
720
720
  "Do you want to continue with the previously downloaded schema from disk?"
721
721
  );
@@ -796,9 +796,9 @@ class SchemaProvider {
796
796
  * @param forceDownload - Forces downloading the schema.
797
797
  */
798
798
  async loadSchema(opts) {
799
- if (opts?.forceDisk || this.helper.isPrepare) {
799
+ if (opts?.forceDisk) {
800
800
  this.schemaContent = await this.loadSchemaFromDisk();
801
- } else if (this.helper.options.downloadSchema || opts?.forceDownload) {
801
+ } else if (this.helper.shouldDownloadSchema() || opts?.forceDownload) {
802
802
  this.schemaContent = await this.downloadSchema();
803
803
  } else {
804
804
  this.schemaContent = await this.loadSchemaFromDisk();
@@ -959,6 +959,7 @@ class ModuleHelper {
959
959
  constructor(nuxt, moduleUrl, options) {
960
960
  this.nuxt = nuxt;
961
961
  this.isPrepare = nuxt.options._prepare;
962
+ this.isDev = nuxt.options.dev;
962
963
  const mergedOptions = defu(
963
964
  {},
964
965
  options,
@@ -1007,7 +1008,6 @@ class ModuleHelper {
1007
1008
  if (!nuxt.options._prepare) {
1008
1009
  validateOptions(this.options);
1009
1010
  }
1010
- this.isDev = nuxt.options.dev;
1011
1011
  this.resolvers = {
1012
1012
  module: createResolver(moduleUrl),
1013
1013
  server: createResolver(nuxt.options.serverDir),
@@ -1041,6 +1041,15 @@ class ModuleHelper {
1041
1041
  prompt = new ConsolePrompt();
1042
1042
  nitroExternals = [];
1043
1043
  tsPaths = {};
1044
+ /**
1045
+ * Whether the schema should be downloaded.
1046
+ */
1047
+ shouldDownloadSchema() {
1048
+ if (this.options.downloadSchema === "dev-only") {
1049
+ return this.isDev;
1050
+ }
1051
+ return this.options.downloadSchema;
1052
+ }
1044
1053
  /**
1045
1054
  * Find the path to the graphqlMiddleware.serverOptions.ts file.
1046
1055
  */
@@ -104,13 +104,16 @@ interface ModuleOptions {
104
104
  */
105
105
  graphqlEndpoint?: string;
106
106
  /**
107
- * Download the GraphQL schema and store it on disk.
107
+ * Whether to download the GraphQL schema and store it on disk.
108
108
  *
109
- * Usually you'll want to only enable this during dev mode.
109
+ * - `false` The GraphQL schema must exist on disk for the module to work.
110
+ * - `true` The GraphQL schema will be downloaded and stored on disk.
111
+ * - `'dev-only'` When running `npm run dev` the schema is downloaded,
112
+ * otherwise it is read from disk.
110
113
  *
111
114
  * @default true
112
115
  */
113
- downloadSchema?: boolean;
116
+ downloadSchema?: boolean | 'dev-only';
114
117
  /**
115
118
  * Path to the GraphQL schema file.
116
119
  *
@@ -349,6 +352,10 @@ declare class ModuleHelper {
349
352
  private nitroExternals;
350
353
  private tsPaths;
351
354
  constructor(nuxt: Nuxt, moduleUrl: string, options: ModuleOptions);
355
+ /**
356
+ * Whether the schema should be downloaded.
357
+ */
358
+ shouldDownloadSchema(): boolean;
352
359
  /**
353
360
  * Find the path to the graphqlMiddleware.serverOptions.ts file.
354
361
  */
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as ModuleContext } from './shared/nuxt-graphql-middleware.COufMnWs.mjs';
1
+ import { M as ModuleContext } from './shared/nuxt-graphql-middleware.B34q074V.mjs';
2
2
  import 'graphql';
3
3
  import 'nuxt/schema';
4
4
  import '@nuxt/kit';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "Module to perform GraphQL requests as a server middleware.",
5
5
  "author": "Jan Hug <me@dulnan.net>",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"id":"efa6c0a0-833e-4e5a-bc2d-ba9d0d3e4562","timestamp":1766498304481,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}