nuxt-graphql-middleware 5.0.0-alpha.9 → 5.1.0

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 (72) hide show
  1. package/README.md +101 -19
  2. package/dist/client/200.html +8 -8
  3. package/dist/client/404.html +8 -8
  4. package/dist/client/_nuxt/{C9pb_2rp.js → CPiV13Ng.js} +2 -2
  5. package/dist/client/_nuxt/CQCiRbEL.js +1 -0
  6. package/dist/client/_nuxt/CYI2eNUl.js +1 -0
  7. package/dist/client/_nuxt/UAIVpYSK.js +25 -0
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/48332277-c4ad-4d6a-8f09-7a58a109c32d.json +1 -0
  10. package/dist/client/_nuxt/error-404.Bbd2eCoc.css +1 -0
  11. package/dist/client/_nuxt/error-500.Cd2cwFc3.css +1 -0
  12. package/dist/client/_nuxt/{BLvMh1Ga.js → u1b7LyOw.js} +1 -1
  13. package/dist/client/index.html +8 -8
  14. package/dist/client-options.d.mts +6 -0
  15. package/dist/client-options.mjs +5 -0
  16. package/dist/module.d.mts +63 -181
  17. package/dist/module.json +4 -4
  18. package/dist/module.mjs +435 -92
  19. package/dist/runtime/components/CodeFrame.vue +19 -28
  20. package/dist/runtime/components/CodeFrame.vue.d.ts +7 -0
  21. package/dist/runtime/components/DevModeOverlay.vue +25 -33
  22. package/dist/runtime/components/DevModeOverlay.vue.d.ts +3 -0
  23. package/dist/runtime/components/ErrorExtensions.vue +9 -11
  24. package/dist/runtime/components/ErrorExtensions.vue.d.ts +5 -0
  25. package/dist/runtime/components/ErrorGroup.vue +28 -39
  26. package/dist/runtime/components/ErrorGroup.vue.d.ts +9 -0
  27. package/dist/runtime/composables/nuxtApp.d.ts +30 -2
  28. package/dist/runtime/composables/nuxtApp.js +66 -24
  29. package/dist/runtime/composables/useAsyncGraphqlQuery.js +28 -25
  30. package/dist/runtime/composables/useGraphqlMutation.d.ts +1 -1
  31. package/dist/runtime/composables/useGraphqlMutation.js +11 -16
  32. package/dist/runtime/composables/useGraphqlQuery.d.ts +1 -1
  33. package/dist/runtime/composables/useGraphqlQuery.js +7 -25
  34. package/dist/runtime/composables/useGraphqlUploadMutation.js +1 -1
  35. package/dist/runtime/helpers/ClientCache.d.ts +1 -0
  36. package/dist/runtime/helpers/ClientCache.js +12 -0
  37. package/dist/runtime/helpers/composables.d.ts +8 -0
  38. package/dist/runtime/helpers/composables.js +27 -0
  39. package/dist/runtime/helpers/index.d.ts +0 -4
  40. package/dist/runtime/helpers/index.js +0 -13
  41. package/dist/runtime/helpers/queryEncoding.d.ts +11 -0
  42. package/dist/runtime/helpers/queryEncoding.js +89 -0
  43. package/dist/runtime/plugins/devMode.js +2 -1
  44. package/dist/runtime/server/api/mutation.js +2 -1
  45. package/dist/runtime/server/api/query.js +7 -8
  46. package/dist/runtime/server/utils/doGraphqlRequest.js +5 -4
  47. package/dist/runtime/server/utils/useGraphqlQuery.js +2 -2
  48. package/dist/runtime/settings/index.d.ts +1 -0
  49. package/dist/runtime/settings/index.js +1 -0
  50. package/dist/runtime/types.d.ts +2 -2
  51. package/dist/server-options.d.mts +8 -0
  52. package/dist/server-options.mjs +5 -0
  53. package/dist/shared/nuxt-graphql-middleware.-BeiPV4H.d.mts +566 -0
  54. package/dist/types.d.mts +1 -7
  55. package/dist/utils.d.mts +15 -0
  56. package/dist/utils.mjs +18 -0
  57. package/package.json +36 -32
  58. package/dist/client/_nuxt/CBwfSTyQ.js +0 -1
  59. package/dist/client/_nuxt/CPyoLiCY.js +0 -1
  60. package/dist/client/_nuxt/VpkRx2_e.js +0 -25
  61. package/dist/client/_nuxt/builds/meta/826a43da-d42c-4fbf-8dfd-2572141eaf8f.json +0 -1
  62. package/dist/client/_nuxt/error-404.BJkSn6RI.css +0 -1
  63. package/dist/client/_nuxt/error-500.TOCKLquH.css +0 -1
  64. package/dist/module.cjs +0 -5
  65. package/dist/module.d.ts +0 -210
  66. package/dist/runtime/clientOptions/index.d.ts +0 -2
  67. package/dist/runtime/clientOptions/index.js +0 -3
  68. package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +0 -4
  69. package/dist/runtime/serverOptions/defineGraphqlServerOptions.js +0 -3
  70. package/dist/runtime/serverOptions/index.d.ts +0 -2
  71. package/dist/runtime/serverOptions/index.js +0 -2
  72. package/dist/types.d.ts +0 -7
package/dist/module.d.mts CHANGED
@@ -1,178 +1,38 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { HookResult } from 'nuxt/schema';
2
+ import { M as ModuleContext, a as ModuleOptions } from './shared/nuxt-graphql-middleware.-BeiPV4H.mjs';
3
3
  import { OperationResponseError } from '../dist/runtime/types.js';
4
- 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 } from 'graphql-typescript-deluxe';
4
+ import { HookResult } from 'nuxt/schema';
5
+ import { GeneratorOutput } from 'graphql-typescript-deluxe';
6
+ import 'graphql';
7
+ import '@nuxt/kit';
8
+ import 'h3';
9
+ import '@graphql-codegen/plugin-helpers';
10
+ import '@graphql-codegen/schema-ast';
11
+
12
+ type BuildHookContext = {
13
+ output: GeneratorOutput;
14
+ };
8
15
 
9
- interface ModuleOptions {
10
- /**
11
- * File glob patterns for the auto import feature.
12
- *
13
- * If left empty, no documents are auto imported.
14
- *
15
- * @default
16
- * ```json
17
- * ["**\/.{gql,graphql}", "!node_modules"]
18
- * ```
19
- *
20
- * @example
21
- * ```ts
22
- * // Load .graphql files from pages folder and from a node_modules dependency.
23
- * const autoImportPatterns = [
24
- * './pages/**\/*.graphql',
25
- * 'node_modules/my_library/dist/**\/*.graphql'
26
- * ]
27
- * ```
28
- */
29
- autoImportPatterns?: string[];
30
- /**
31
- * The path where your graphql.config.ts is, relative to the location of nuxt.config.ts.
32
- *
33
- * Used to generate the correct paths in the graphql.config.ts file generated by the module.
34
- *
35
- * @default "./graphql.config.ts"
36
- */
37
- graphqlConfigFilePath?: string;
38
- /**
39
- * Additional raw documents to include.
40
- *
41
- * Useful if for example you need to generate queries during build time.
42
- *
43
- * @default []
44
- *
45
- * @example
46
- * ```ts
47
- * const documents = [`
48
- * query myQuery {
49
- * articles {
50
- * title
51
- * id
52
- * }
53
- * }`,
54
- * ...getGeneratedDocuments()
55
- * ]
56
- * ```
57
- */
58
- documents?: string[];
59
- /**
60
- * Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
61
- * composables should be included.
62
- *
63
- * @default ```ts
64
- * true
65
- * ```
66
- */
67
- includeComposables?: boolean;
68
- /**
69
- * Enable support for uploading files via GraphQL.
70
- *
71
- * When enabled, an additional `useGraphqlUploadMutation` composable is
72
- * included, in addition to a new server endpoint that handles multi part
73
- * file uploads for GraphQL mutations.
74
- */
75
- enableFileUploads?: boolean;
76
- /**
77
- * Enable detailled debugging messages.
78
- *
79
- * @default false
80
- */
81
- debug?: boolean;
82
- /**
83
- * Displays GraphQL response errors in an overlay in dev mode.
84
- */
85
- errorOverlay?: boolean;
86
- /**
87
- * The URL of the GraphQL server.
88
- *
89
- * For the runtime execution you can provide a method that determines the endpoint
90
- * during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
91
- * for more information.
92
- */
93
- graphqlEndpoint: string;
94
- /**
95
- * Download the GraphQL schema and store it on disk.
96
- *
97
- * Usually you'll want to only enable this during dev mode.
98
- *
99
- * @default true
100
- */
101
- downloadSchema?: boolean;
102
- /**
103
- * Path to the GraphQL schema file.
104
- *
105
- * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
106
- * If `downloadSchema` is `false`, this file must be present in order to generate types.
107
- *
108
- * @default './schema.graphql'
109
- */
110
- schemaPath?: string;
111
- /**
112
- * The prefix for the server route.
113
- *
114
- * @default ```ts
115
- * "/api/graphql_middleware"
116
- * ```
117
- */
118
- serverApiPrefix?: string;
119
- /**
120
- * Logs only errors.
121
- *
122
- * When enabled only errors are logged to the console when generating the GraphQL operations.
123
- * If false, all operations are logged, including valid ones.
124
- */
125
- logOnlyErrors?: boolean;
126
- /**
127
- * Options for graphql-typescript-deluxe code generator.
128
- */
129
- codegenConfig?: GeneratorOptions;
130
- /**
131
- * Configuration for graphql-codegen when downloading the schema.
132
- */
133
- codegenSchemaConfig?: {
16
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
17
+
18
+ declare module '#app' {
19
+ interface RuntimeNuxtHooks {
134
20
  /**
135
- * Configure how the schema.graphql file should be generated.
21
+ * Emitted when any GraphQL response contains errors.
136
22
  */
137
- schemaAstConfig?: SchemaASTConfig;
23
+ 'nuxt-graphql-middleware:errors': (errors: OperationResponseError) => HookResult;
24
+ }
25
+ }
26
+ declare module 'vite/types/customEvent.d.ts' {
27
+ interface CustomEventMap {
138
28
  /**
139
- * Configure how the schema-ast introspection request should be made.
140
- *
141
- * Usually this is where you can provide a custom authentication header:
142
- *
143
- * ```typescript
144
- * const codegenSchemaConfig = {
145
- * urlSchemaOptions: {
146
- * headers: {
147
- * authentication: 'foobar',
148
- * }
149
- * }
150
- * }
151
- * ```
29
+ * Emitted when GraphQL operations have been updated.
152
30
  */
153
- urlSchemaOptions?: Types.UrlSchemaOptions;
154
- };
155
- /**
156
- * Set to true if you want to output each compiled query and mutation in the
157
- * .nuxt folder.
158
- * Set to a path to output to a custom path.
159
- */
160
- outputDocuments?: boolean | string;
161
- /**
162
- * Enable Nuxt DevTools integration.
163
- */
164
- devtools?: boolean;
165
- /**
166
- * Client caching configuration.
167
- */
168
- clientCache?: {
169
- enabled?: boolean;
170
- maxSize?: number;
171
- };
31
+ 'nuxt-graphql-middleware:reload': {
32
+ operations: string[];
33
+ };
34
+ }
172
35
  }
173
-
174
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
175
-
176
36
  declare module '@nuxt/schema' {
177
37
  interface AppConfig {
178
38
  graphqlMiddleware: {
@@ -186,25 +46,47 @@ declare module '@nuxt/schema' {
186
46
  clientCacheMaxSize: number;
187
47
  };
188
48
  }
189
- }
190
- declare module '#app' {
191
- interface RuntimeNuxtHooks {
49
+ interface Nuxt {
192
50
  /**
193
- * Emitted when any GraphQL response contains errors.
51
+ * The nuxt-graphql-middleware module context.
194
52
  */
195
- 'nuxt-graphql-middleware:errors': (errors: OperationResponseError) => HookResult;
53
+ _nuxt_graphql_middleware?: ModuleContext;
196
54
  }
197
- }
198
- declare module 'vite/types/customEvent.d.ts' {
199
- interface CustomEventMap {
55
+ interface NuxtHooks {
200
56
  /**
201
- * Emitted when GraphQL operations have been updated.
57
+ * Called once right before the documents are initialised.
58
+ *
59
+ * Use this hook to add any additional documents based on for example the parsed schema.
60
+ *
61
+ * @example
62
+ *
63
+ * ```typescript`
64
+ * export default defineNuxtConfig({
65
+ * hooks: {
66
+ * 'nuxt-graphql-middleware:init': (ctx) => {
67
+ * if (ctx.schemaHasType('Comment')) {
68
+ * ctx.addDocument(
69
+ * 'queryFromHook',
70
+ * `query loadComments { author subject date body }`
71
+ * )
72
+ * }
73
+ * },
74
+ * },
75
+ * })
76
+ * ```
202
77
  */
203
- 'nuxt-graphql-middleware:reload': {
204
- operations: string[];
205
- };
78
+ 'nuxt-graphql-middleware:init': (ctx: ModuleContext) => void | Promise<void>;
79
+ /**
80
+ * Called when building the state and templates.
81
+ *
82
+ * Generally this hook is called from within the builder:watch event, when
83
+ * a GraphQL file change was detected.
84
+ *
85
+ * The received argument is the output from the graphql-typescript-deluxe
86
+ * generator.
87
+ */
88
+ 'nuxt-graphql-middleware:build': (ctx: BuildHookContext) => void | Promise<void>;
206
89
  }
207
90
  }
208
91
 
209
- export { _default as default };
210
- export type { ModuleOptions };
92
+ export { ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "5.0.0-alpha.9",
4
+ "version": "5.1.0",
5
5
  "compatibility": {
6
- "nuxt": ">=3.15.0"
6
+ "nuxt": ">=3.17.0"
7
7
  },
8
8
  "builder": {
9
- "@nuxt/module-builder": "0.8.4",
10
- "unbuild": "2.0.0"
9
+ "@nuxt/module-builder": "1.0.1",
10
+ "unbuild": "3.5.0"
11
11
  }
12
12
  }