nuxt-graphql-middleware 4.1.0 → 4.1.1

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.
@@ -8,4 +8,4 @@
8
8
  <link rel="prefetch" as="style" href="/__nuxt-graphql-middleware/_nuxt/error-500.B4KzowuE.css">
9
9
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/KmIjpfWJ.js">
10
10
  <script type="module" src="/__nuxt-graphql-middleware/_nuxt/CUKk0hSk.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
11
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"debd7d31-13de-43c8-a23f-9d618b1b6aee",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"42e92f16-7f29-4b6f-8e46-68076031ade3",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -8,4 +8,4 @@
8
8
  <link rel="prefetch" as="style" href="/__nuxt-graphql-middleware/_nuxt/error-500.B4KzowuE.css">
9
9
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/KmIjpfWJ.js">
10
10
  <script type="module" src="/__nuxt-graphql-middleware/_nuxt/CUKk0hSk.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
11
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"debd7d31-13de-43c8-a23f-9d618b1b6aee",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"42e92f16-7f29-4b6f-8e46-68076031ade3",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +1 @@
1
- {"id":"debd7d31-13de-43c8-a23f-9d618b1b6aee","timestamp":1720017684576}
1
+ {"id":"42e92f16-7f29-4b6f-8e46-68076031ade3","timestamp":1722315551727}
@@ -0,0 +1 @@
1
+ {"id":"42e92f16-7f29-4b6f-8e46-68076031ade3","timestamp":1722315551727,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -8,4 +8,4 @@
8
8
  <link rel="prefetch" as="style" href="/__nuxt-graphql-middleware/_nuxt/error-500.B4KzowuE.css">
9
9
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/KmIjpfWJ.js">
10
10
  <script type="module" src="/__nuxt-graphql-middleware/_nuxt/CUKk0hSk.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
11
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"debd7d31-13de-43c8-a23f-9d618b1b6aee",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
11
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"42e92f16-7f29-4b6f-8e46-68076031ade3",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "4.1.0",
4
+ "version": "4.1.1",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.1.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -11,8 +11,6 @@ import { promises, existsSync as existsSync$1 } from 'node:fs';
11
11
  import { oldVisit } from '@graphql-codegen/plugin-helpers';
12
12
  import { validateGraphQlDocuments } from '@graphql-tools/utils';
13
13
  import { loadSchema } from '@graphql-tools/load';
14
- import Table from 'cli-table';
15
- import chalk from 'chalk';
16
14
  import { concatAST, parse, print, visit, Kind, Source } from 'graphql';
17
15
  import { falsy } from '../dist/runtime/helpers/index.js';
18
16
  import { generate as generate$1, executeCodegen } from '@graphql-codegen/cli';
@@ -20,9 +18,10 @@ import * as PluginTypescript from '@graphql-codegen/typescript';
20
18
  import * as PluginTypescriptOperations from '@graphql-codegen/typescript-operations';
21
19
  import * as PluginSchemaAst from '@graphql-codegen/schema-ast';
22
20
  import { pascalCase } from 'change-case-all';
21
+ import colors from 'picocolors';
23
22
 
24
23
  const name = "nuxt-graphql-middleware";
25
- const version = "4.1.0";
24
+ const version = "4.1.1";
26
25
 
27
26
  const DEVTOOLS_UI_ROUTE = "/__nuxt-graphql-middleware";
28
27
  const DEVTOOLS_UI_LOCAL_PORT = 3300;
@@ -345,6 +344,48 @@ function generateTemplates(documents, schemaPath, options) {
345
344
  });
346
345
  }
347
346
 
347
+ function getMaxLengths(documents) {
348
+ let longestOperation = 0;
349
+ let longestName = 0;
350
+ let longestPath = 0;
351
+ for (const { operation, name, relativePath } of documents) {
352
+ if (operation && operation.length > longestOperation) {
353
+ longestOperation = operation.length;
354
+ }
355
+ if (name && name.length > longestName) {
356
+ longestName = name.length;
357
+ }
358
+ if (relativePath && relativePath.length > longestPath) {
359
+ longestPath = relativePath.length;
360
+ }
361
+ }
362
+ return { longestOperation, longestName, longestPath };
363
+ }
364
+ function logDocuments(logger, documents, logEverything) {
365
+ const { longestOperation, longestName, longestPath } = getMaxLengths(documents);
366
+ logger.log(colors.green("GraphQL Document Validation"));
367
+ for (const { operation, name, relativePath, isValid, errors } of documents) {
368
+ if (logEverything || !isValid) {
369
+ let log = "";
370
+ log += (operation || "").padEnd(longestOperation + 2);
371
+ log += colors.cyan((name || "").padEnd(longestName + 2));
372
+ log += colors.dim((relativePath || "").padEnd(longestPath + 2));
373
+ log += isValid ? colors.green("\u2713") : colors.red("x");
374
+ if (!isValid && errors) {
375
+ log += "\n" + errors.map((error) => colors.red(error)).join("\n");
376
+ }
377
+ logger.log(log);
378
+ }
379
+ }
380
+ process.stdout.write("\n");
381
+ logger.restoreStd();
382
+ if (documents.some((v) => !v.isValid)) {
383
+ logger.error("GraphQL document validation failed with errors.");
384
+ } else {
385
+ logger.success("GraphQL document validation completed successfully.");
386
+ }
387
+ }
388
+
348
389
  const logger = useLogger("nuxt-graphql-middleware");
349
390
  const defaultOptions = {
350
391
  codegenConfig: {
@@ -365,7 +406,6 @@ const defaultOptions = {
365
406
  debug: false,
366
407
  includeComposables: true,
367
408
  documents: [],
368
- autoImportPatterns: [],
369
409
  devtools: true
370
410
  };
371
411
  function inlineFragments(source, resolver) {
@@ -647,27 +687,7 @@ async function generate(options, schemaPath, resolver, srcDir, logEverything = f
647
687
  );
648
688
  const hasErrors = extracted.some((v) => !v.isValid) || validated.some((v) => !v.isValid);
649
689
  if (hasErrors || logEverything) {
650
- const table = new Table({
651
- head: ["Operation", "Name", "File", "Errors"].map((v) => chalk.white(v))
652
- });
653
- extracted.forEach((document) => {
654
- if (logEverything || !document.isValid) {
655
- table.push(
656
- [
657
- document.operation || "",
658
- document.name || "",
659
- document.relativePath || "",
660
- document.errors?.join("\n\n") || ""
661
- ].map((v) => {
662
- if (document.isValid) {
663
- return v;
664
- }
665
- return chalk.red(v);
666
- })
667
- );
668
- }
669
- });
670
- logger.log("GraphQL code generation table:\n" + table.toString());
690
+ logDocuments(logger, extracted, logEverything);
671
691
  }
672
692
  process.stdout.write("\n");
673
693
  logger.restoreStd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "Module to perform GraphQL requests as a server middleware.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,9 +64,9 @@
64
64
  "@graphql-tools/utils": "^10.2.2",
65
65
  "@nuxt/devtools-kit": "1.3.7",
66
66
  "@nuxt/kit": "^3.12.2",
67
- "cli-table": "^0.3.11",
68
67
  "inquirer": "^9.3.2",
69
- "minisearch": "^6.3.0"
68
+ "minisearch": "^6.3.0",
69
+ "picocolors": "^1.0.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@iconify-json/carbon": "^1.1.36",
@@ -1 +0,0 @@
1
- {"id":"debd7d31-13de-43c8-a23f-9d618b1b6aee","timestamp":1720017684576,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}