nuxt-graphql-middleware 5.0.0-alpha.16 → 5.0.0-alpha.17

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.
Files changed (39) hide show
  1. package/dist/client/200.html +6 -6
  2. package/dist/client/404.html +6 -6
  3. package/dist/client/_nuxt/{B2Rg1ezw.js → BM34SYth.js} +1 -1
  4. package/dist/client/_nuxt/{AZpplOcD.js → CROlboVl.js} +1 -1
  5. package/dist/client/_nuxt/{M311G39J.js → D5hBL5aZ.js} +3 -3
  6. package/dist/client/_nuxt/{u9er1db2.js → FTbv7CO6.js} +1 -1
  7. package/dist/client/_nuxt/builds/latest.json +1 -1
  8. package/dist/client/_nuxt/builds/meta/35b756ec-db3a-48e0-a262-4036827a35c5.json +1 -0
  9. package/dist/client/_nuxt/{Bt6N0bOg.js → lIgCBhS_.js} +2 -2
  10. package/dist/client/index.html +6 -6
  11. package/dist/client-options.d.mts +6 -0
  12. package/dist/client-options.mjs +5 -0
  13. package/dist/module.d.mts +9 -506
  14. package/dist/module.json +3 -3
  15. package/dist/module.mjs +25 -28
  16. package/dist/runtime/components/CodeFrame.vue +19 -28
  17. package/dist/runtime/components/CodeFrame.vue.d.ts +7 -0
  18. package/dist/runtime/components/DevModeOverlay.vue +25 -33
  19. package/dist/runtime/components/DevModeOverlay.vue.d.ts +3 -0
  20. package/dist/runtime/components/ErrorExtensions.vue +9 -11
  21. package/dist/runtime/components/ErrorExtensions.vue.d.ts +5 -0
  22. package/dist/runtime/components/ErrorGroup.vue +27 -38
  23. package/dist/runtime/components/ErrorGroup.vue.d.ts +9 -0
  24. package/dist/server-options.d.mts +8 -0
  25. package/dist/server-options.mjs +5 -0
  26. package/dist/{module.d.ts → shared/nuxt-graphql-middleware.DLNGE1zJ.d.mts} +15 -88
  27. package/dist/types.d.mts +1 -7
  28. package/dist/utils.d.mts +15 -0
  29. package/dist/utils.mjs +18 -0
  30. package/package.json +25 -23
  31. package/dist/client/_nuxt/builds/meta/e1a39e19-d46f-47f9-88fd-317d5fa8bf87.json +0 -1
  32. package/dist/module.cjs +0 -5
  33. package/dist/runtime/clientOptions/index.d.ts +0 -2
  34. package/dist/runtime/clientOptions/index.js +0 -3
  35. package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +0 -4
  36. package/dist/runtime/serverOptions/defineGraphqlServerOptions.js +0 -3
  37. package/dist/runtime/serverOptions/index.d.ts +0 -2
  38. package/dist/runtime/serverOptions/index.js +0 -2
  39. package/dist/types.d.ts +0 -7
@@ -21,40 +21,32 @@
21
21
  </div>
22
22
  </template>
23
23
 
24
- <script setup lang="ts">
25
- import './../css/output.css'
26
- import { useState, computed } from '#imports'
27
-
28
- import type { OperationResponseError } from '../types'
29
- import ErrorGroup from './ErrorGroup.vue'
30
-
31
- const errors = useState<OperationResponseError[]>(
32
- 'nuxt-graphql-middleware-errors',
33
- () => [],
34
- )
35
-
36
- const groups = computed<OperationResponseError[]>(() => {
24
+ <script setup>
25
+ import "./../css/output.css";
26
+ import { useState, computed } from "#imports";
27
+ import ErrorGroup from "./ErrorGroup.vue";
28
+ const errors = useState(
29
+ "nuxt-graphql-middleware-errors",
30
+ () => []
31
+ );
32
+ const groups = computed(() => {
37
33
  return [
38
- ...errors.value
39
- .reduce<Map<string, OperationResponseError>>((acc, v) => {
40
- const key = `${v.operation}_${v.operationName}`
41
- if (!acc.has(key)) {
42
- acc.set(key, {
43
- operation: v.operation,
44
- operationName: v.operationName,
45
- errors: [],
46
- stack: v.stack,
47
- })
48
- }
49
- acc.get(key)!.errors.push(...v.errors)
50
- return acc
51
- }, new Map())
52
- .values(),
53
- ]
54
- })
55
-
56
- /** Clear the error state => close/hide the overlay */
34
+ ...errors.value.reduce((acc, v) => {
35
+ const key = `${v.operation}_${v.operationName}`;
36
+ if (!acc.has(key)) {
37
+ acc.set(key, {
38
+ operation: v.operation,
39
+ operationName: v.operationName,
40
+ errors: [],
41
+ stack: v.stack
42
+ });
43
+ }
44
+ acc.get(key).errors.push(...v.errors);
45
+ return acc;
46
+ }, /* @__PURE__ */ new Map()).values()
47
+ ];
48
+ });
57
49
  function clearErrors() {
58
- errors.value = []
50
+ errors.value = [];
59
51
  }
60
52
  </script>
@@ -0,0 +1,3 @@
1
+ import './../css/output.css.js';
2
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
+ export default _default;
@@ -5,19 +5,17 @@
5
5
  </tr>
6
6
  </template>
7
7
 
8
- <script setup lang="ts">
9
- import { computed } from '#imports'
10
-
11
- const props = defineProps<{
12
- extensions?: Record<string, unknown>
13
- }>()
14
-
8
+ <script setup>
9
+ import { computed } from "#imports";
10
+ const props = defineProps({
11
+ extensions: { type: Object, required: false }
12
+ });
15
13
  const mapped = computed(() => {
16
14
  if (!props.extensions) {
17
- return []
15
+ return [];
18
16
  }
19
17
  return Object.entries(props.extensions).map(([key, value]) => {
20
- return { key, value }
21
- })
22
- })
18
+ return { key, value };
19
+ });
20
+ });
23
21
  </script>
@@ -0,0 +1,5 @@
1
+ type __VLS_Props = {
2
+ extensions?: Record<string, unknown>;
3
+ };
4
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ export default _default;
@@ -46,44 +46,33 @@
46
46
  </table>
47
47
  </template>
48
48
 
49
- <script lang="ts" setup>
50
- import type { GraphqlResponseError } from '../types'
51
- import { documents } from '#nuxt-graphql-middleware/documents'
52
- import { operationSources } from '#nuxt-graphql-middleware/sources'
53
- import { computed } from '#imports'
54
- import CodeFrame from './CodeFrame.vue'
55
- import ErrorExtensions from './ErrorExtensions.vue'
56
-
57
- type MappedError = GraphqlResponseError & { count: number; key: string }
58
-
59
- const props = defineProps<{
60
- operation: string
61
- operationName: string
62
- errors: GraphqlResponseError[]
63
- stack?: string
64
- }>()
65
-
66
- const key = computed(() => props.operation + '_' + props.operationName)
67
-
49
+ <script setup>
50
+ import { documents } from "#nuxt-graphql-middleware/documents";
51
+ import { operationSources } from "#nuxt-graphql-middleware/sources";
52
+ import { computed } from "#imports";
53
+ import CodeFrame from "./CodeFrame.vue";
54
+ import ErrorExtensions from "./ErrorExtensions.vue";
55
+ const props = defineProps({
56
+ operation: { type: String, required: true },
57
+ operationName: { type: String, required: true },
58
+ errors: { type: Array, required: true },
59
+ stack: { type: String, required: false }
60
+ });
61
+ const key = computed(() => props.operation + "_" + props.operationName);
68
62
  const filePath = computed(() => {
69
- return operationSources[key.value]
70
- })
71
-
63
+ return operationSources[key.value];
64
+ });
72
65
  const source = computed(
73
- () => (documents as any)[props.operation]?.[props.operationName],
74
- )
75
-
76
- const uniqueErrors = computed<MappedError[]>(() => {
77
- return props.errors
78
- .reduce<Map<string, MappedError>>((acc, v) => {
79
- const key = v.message
80
- if (!acc.has(key)) {
81
- acc.set(key, { ...v, key, count: 0 })
82
- }
83
- acc.get(key)!.count++
84
- return acc
85
- }, new Map())
86
- .values()
87
- .toArray()
88
- })
66
+ () => documents[props.operation]?.[props.operationName]
67
+ );
68
+ const uniqueErrors = computed(() => {
69
+ return props.errors.reduce((acc, v) => {
70
+ const key2 = v.message;
71
+ if (!acc.has(key2)) {
72
+ acc.set(key2, { ...v, key: key2, count: 0 });
73
+ }
74
+ acc.get(key2).count++;
75
+ return acc;
76
+ }, /* @__PURE__ */ new Map()).values().toArray();
77
+ });
89
78
  </script>
@@ -0,0 +1,9 @@
1
+ import type { GraphqlResponseError } from '../types.js';
2
+ type __VLS_Props = {
3
+ operation: string;
4
+ operationName: string;
5
+ errors: GraphqlResponseError[];
6
+ stack?: string;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
2
+ import { GraphqlMiddlewareResponseUnion } from '#nuxt-graphql-middleware/response';
3
+ import { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
4
+ export { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
5
+
6
+ declare function defineGraphqlServerOptions<T extends object = object>(options: GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>): GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>;
7
+
8
+ export { defineGraphqlServerOptions };
@@ -0,0 +1,5 @@
1
+ function defineGraphqlServerOptions(options) {
2
+ return options;
3
+ }
4
+
5
+ export { defineGraphqlServerOptions };
@@ -1,13 +1,19 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { Types } from '@graphql-codegen/plugin-helpers';
3
- import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
4
- import { GeneratorOptions, GeneratorOutput } from 'graphql-typescript-deluxe';
5
1
  import { GraphQLSchema, GraphQLNamedType } from 'graphql';
6
- import { Nuxt, ResolvedNuxtTemplate, WatchEvent, HookResult } from 'nuxt/schema';
2
+ import { Nuxt, ResolvedNuxtTemplate, WatchEvent } from 'nuxt/schema';
7
3
  import { Resolver } from '@nuxt/kit';
8
4
  import { RouterMethod } from 'h3';
9
- import { OperationResponseError } from '../dist/runtime/types.js';
10
- export { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
5
+ import { Types } from '@graphql-codegen/plugin-helpers';
6
+ import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
7
+ import { GeneratorOptions, GeneratorOutput } from 'graphql-typescript-deluxe';
8
+
9
+ type RpcItem = {
10
+ id: string;
11
+ timestamp?: number;
12
+ source: string;
13
+ name: string;
14
+ identifier: 'fragment' | 'query' | 'mutation';
15
+ filePath: string;
16
+ };
11
17
 
12
18
  interface ModuleOptions {
13
19
  /**
@@ -180,15 +186,6 @@ interface ModuleOptions {
180
186
  };
181
187
  }
182
188
 
183
- type RpcItem = {
184
- id: string;
185
- timestamp?: number;
186
- source: string;
187
- name: string;
188
- identifier: 'fragment' | 'query' | 'mutation';
189
- filePath: string;
190
- };
191
-
192
189
  declare const defaultOptions: ModuleOptions;
193
190
 
194
191
  declare class ConsolePrompt {
@@ -501,75 +498,5 @@ declare class ModuleContext {
501
498
  addImportFile(filePath: string): ModuleContext;
502
499
  }
503
500
 
504
- declare function useGraphqlModuleContext(): ModuleContext;
505
- declare function useGraphqlModuleContext(options: {
506
- nullOnMissing: true;
507
- }): ModuleContext | null;
508
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
509
-
510
- declare module '#app' {
511
- interface RuntimeNuxtHooks {
512
- /**
513
- * Emitted when any GraphQL response contains errors.
514
- */
515
- 'nuxt-graphql-middleware:errors': (errors: OperationResponseError) => HookResult;
516
- }
517
- }
518
- declare module 'vite/types/customEvent.d.ts' {
519
- interface CustomEventMap {
520
- /**
521
- * Emitted when GraphQL operations have been updated.
522
- */
523
- 'nuxt-graphql-middleware:reload': {
524
- operations: string[];
525
- };
526
- }
527
- }
528
- declare module '@nuxt/schema' {
529
- interface AppConfig {
530
- graphqlMiddleware: {
531
- /**
532
- * Whether the client cache is enabled.
533
- */
534
- clientCacheEnabled: boolean;
535
- /**
536
- * The max number of items in the cache.
537
- */
538
- clientCacheMaxSize: number;
539
- };
540
- }
541
- interface Nuxt {
542
- /**
543
- * The nuxt-graphql-middleware module context.
544
- */
545
- _nuxt_graphql_middleware?: ModuleContext;
546
- }
547
- interface NuxtHooks {
548
- /**
549
- * Called once right before the documents are initialised.
550
- *
551
- * Use this hook to add any additional documents based on for example the parsed schema.
552
- *
553
- * @example
554
- *
555
- * ```typescript`
556
- * export default defineNuxtConfig({
557
- * hooks: {
558
- * 'nuxt-graphql-middleware:init': (ctx) => {
559
- * if (ctx.schemaHasType('Comment')) {
560
- * ctx.addDocument(
561
- * 'queryFromHook',
562
- * `query loadComments { author subject date body }`
563
- * )
564
- * }
565
- * },
566
- * },
567
- * })
568
- * ```
569
- */
570
- 'nuxt-graphql-middleware:init': (ctx: ModuleContext) => void | Promise<void>;
571
- }
572
- }
573
-
574
- export { _default as default, useGraphqlModuleContext };
575
- export type { ModuleOptions };
501
+ export { ModuleContext as M };
502
+ export type { ModuleOptions as a };
package/dist/types.d.mts CHANGED
@@ -1,7 +1 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module.js'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { type GraphqlMiddlewareServerOptions } from './module.js'
1
+ export { type ModuleOptions, default } from './module.mjs'
@@ -0,0 +1,15 @@
1
+ import { M as ModuleContext } from './shared/nuxt-graphql-middleware.DLNGE1zJ.mjs';
2
+ import 'graphql';
3
+ import 'nuxt/schema';
4
+ import '@nuxt/kit';
5
+ import 'h3';
6
+ import '@graphql-codegen/plugin-helpers';
7
+ import '@graphql-codegen/schema-ast';
8
+ import 'graphql-typescript-deluxe';
9
+
10
+ declare function useGraphqlModuleContext(): ModuleContext;
11
+ declare function useGraphqlModuleContext(options: {
12
+ nullOnMissing: true;
13
+ }): ModuleContext | null;
14
+
15
+ export { useGraphqlModuleContext };
package/dist/utils.mjs ADDED
@@ -0,0 +1,18 @@
1
+ import { useNuxt } from '@nuxt/kit';
2
+
3
+ const CONTEXT_KEY = "_nuxt_graphql_middleware";
4
+ function useGraphqlModuleContext(options) {
5
+ const nuxt = useNuxt();
6
+ const context = nuxt[CONTEXT_KEY];
7
+ if (!context) {
8
+ if (options?.nullOnMissing) {
9
+ return null;
10
+ }
11
+ throw new Error(
12
+ "nuxt-graphql-middleware context is not available. Make sure you call this method only after nuxt-graphql-middleware has been setup. If you call this in a module, make sure your module is declared after nuxt-graphql-middleware in your `modules` Nuxt config."
13
+ );
14
+ }
15
+ return context;
16
+ }
17
+
18
+ export { useGraphqlModuleContext };
package/package.json CHANGED
@@ -1,39 +1,42 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
- "version": "5.0.0-alpha.16",
3
+ "version": "5.0.0-alpha.17",
4
4
  "description": "Module to perform GraphQL requests as a server middleware.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/dulnan/nuxt-graphql-middleware.git"
8
8
  },
9
- "license": "MIT",
10
9
  "type": "module",
11
10
  "exports": {
12
11
  ".": {
13
- "import": {
14
- "types": "./dist/types.d.ts",
15
- "default": "./dist/module.mjs"
16
- },
17
- "require": {
18
- "types": "./dist/types.d.ts",
19
- "default": "./dist/module.cjs"
20
- }
21
- },
22
- "./dist/runtime/serverOptions": {
23
- "import": "./dist/runtime/serverOptions/index.js",
24
- "types": "./dist/runtime/serverOptions/index.d.ts"
12
+ "types": "./dist/types.d.mts",
13
+ "import": "./dist/module.mjs"
25
14
  },
26
- "./dist/runtime/clientOptions": {
27
- "import": "./dist/runtime/clientOptions/index.js",
28
- "types": "./dist/runtime/clientOptions/index.d.ts"
15
+ "./utils": "./dist/utils.mjs",
16
+ "./client-options": "./dist/client-options.mjs",
17
+ "./server-options": "./dist/server-options.mjs"
18
+ },
19
+ "main": "./dist/module.mjs",
20
+ "typesVersions": {
21
+ "*": {
22
+ ".": [
23
+ "./dist/types.d.mts"
24
+ ],
25
+ "utils": [
26
+ "./dist/utils.d.mts"
27
+ ],
28
+ "client-options": [
29
+ "./dist/client-options.d.mts"
30
+ ],
31
+ "server-options": [
32
+ "./dist/server-options.d.mts"
33
+ ]
29
34
  }
30
35
  },
31
- "main": "./dist/module.cjs",
32
- "module": "./dist/module.mjs",
33
- "types": "./dist/types.d.ts",
34
36
  "files": [
35
37
  "dist"
36
38
  ],
39
+ "license": "MIT",
37
40
  "scripts": {
38
41
  "prepack": "npm run styles:build && nuxt-module-build build && npm run client:build",
39
42
  "dev": "nuxi dev playground --trace-warnings",
@@ -79,7 +82,7 @@
79
82
  "@nuxt/devtools-ui-kit": "^2.3.1",
80
83
  "@nuxt/eslint": "^1.2.0",
81
84
  "@nuxt/kit": "^3.16.2",
82
- "@nuxt/module-builder": "^0.8.4",
85
+ "@nuxt/module-builder": "^1.0.1",
83
86
  "@nuxt/schema": "^3.16.2",
84
87
  "@types/micromatch": "^4.0.9",
85
88
  "cypress": "^13.12.0",
@@ -102,7 +105,6 @@
102
105
  "typedoc-vitepress-theme": "^1.1.2",
103
106
  "vitepress": "^1.6.3",
104
107
  "vitepress-plugin-mermaid": "^2.0.17",
105
- "vitest": "^1.6.0",
106
- "vue-tsc": "^2.2.8"
108
+ "vitest": "^1.6.0"
107
109
  }
108
110
  }
@@ -1 +0,0 @@
1
- {"id":"e1a39e19-d46f-47f9-88fd-317d5fa8bf87","timestamp":1744204371551,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
@@ -1,2 +0,0 @@
1
- import type { GraphqlClientOptions, ContextType } from './../types.js';
2
- export declare function defineGraphqlClientOptions<T extends ContextType>(options: GraphqlClientOptions<T>): GraphqlClientOptions<T>;
@@ -1,3 +0,0 @@
1
- export function defineGraphqlClientOptions(options) {
2
- return options;
3
- }
@@ -1,4 +0,0 @@
1
- import type { GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
2
- import type { GraphqlMiddlewareResponseUnion } from '#nuxt-graphql-middleware/response';
3
- import type { GraphqlMiddlewareServerOptions } from './../types.js';
4
- export declare function defineGraphqlServerOptions<T extends object>(options: GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>): GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>;
@@ -1,3 +0,0 @@
1
- export function defineGraphqlServerOptions(options) {
2
- return options;
3
- }
@@ -1,2 +0,0 @@
1
- import { defineGraphqlServerOptions } from './defineGraphqlServerOptions.js';
2
- export { defineGraphqlServerOptions };
@@ -1,2 +0,0 @@
1
- import { defineGraphqlServerOptions } from "./defineGraphqlServerOptions.js";
2
- export { defineGraphqlServerOptions };
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { type GraphqlMiddlewareServerOptions } from './module'