nuxt-graphql-middleware 5.0.0-alpha.5 → 5.0.0-alpha.7

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 (44) hide show
  1. package/dist/client/200.html +7 -7
  2. package/dist/client/404.html +7 -7
  3. package/dist/client/_nuxt/{CZ2Qwgdk.js → B4KMzhZo.js} +1 -1
  4. package/dist/client/_nuxt/BawWjxPx.js +25 -0
  5. package/dist/client/_nuxt/BtHrwWER.js +1 -0
  6. package/dist/client/_nuxt/BvMfLM9s.js +1 -0
  7. package/dist/client/_nuxt/{GOrnHr4p.js → DkAo05uu.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/1d4cde1f-51c0-4bab-b233-3b063cc8ad1c.json +1 -0
  10. package/dist/client/index.html +7 -7
  11. package/dist/module.d.mts +192 -162
  12. package/dist/module.d.ts +192 -162
  13. package/dist/module.json +1 -1
  14. package/dist/module.mjs +1027 -620
  15. package/dist/runtime/components/CodeFrame.vue +1 -1
  16. package/dist/runtime/composables/useAsyncGraphqlQuery.d.ts +1 -1
  17. package/dist/runtime/composables/useAsyncGraphqlQuery.js +9 -1
  18. package/dist/runtime/composables/useGraphqlMutation.d.ts +1 -1
  19. package/dist/runtime/composables/useGraphqlQuery.d.ts +1 -1
  20. package/dist/runtime/composables/useGraphqlUploadMutation.d.ts +1 -1
  21. package/dist/runtime/helpers/composables.d.ts +1 -1
  22. package/dist/runtime/server/api/mutation.js +28 -0
  23. package/dist/runtime/server/api/query.js +29 -0
  24. package/dist/runtime/server/api/upload.d.ts +2 -0
  25. package/dist/runtime/{serverHandler → server/api}/upload.js +11 -9
  26. package/dist/runtime/{serverHandler → server}/helpers/index.d.ts +8 -10
  27. package/dist/runtime/{serverHandler → server}/helpers/index.js +8 -25
  28. package/dist/runtime/server/utils/doGraphqlRequest.d.ts +18 -0
  29. package/dist/runtime/server/utils/doGraphqlRequest.js +67 -0
  30. package/dist/runtime/server/utils/useGraphqlMutation.d.ts +1 -1
  31. package/dist/runtime/server/utils/useGraphqlQuery.d.ts +1 -1
  32. package/dist/runtime/settings/index.d.ts +0 -39
  33. package/dist/runtime/settings/index.js +0 -13
  34. package/package.json +9 -7
  35. package/dist/client/_nuxt/BS583yk8.js +0 -25
  36. package/dist/client/_nuxt/DpxjPVZy.js +0 -1
  37. package/dist/client/_nuxt/builds/meta/c22c2916-33e9-427d-b6fe-10f11766c207.json +0 -1
  38. package/dist/client/_nuxt/exxdaCPN.js +0 -1
  39. package/dist/runtime/serverHandler/index.js +0 -78
  40. package/dist/runtime/serverHandler/tsconfig.json +0 -3
  41. /package/dist/runtime/{serverHandler → server/api}/debug.d.ts +0 -0
  42. /package/dist/runtime/{serverHandler → server/api}/debug.js +0 -0
  43. /package/dist/runtime/{serverHandler/index.d.ts → server/api/mutation.d.ts} +0 -0
  44. /package/dist/runtime/{serverHandler/upload.d.ts → server/api/query.d.ts} +0 -0
package/dist/module.d.ts CHANGED
@@ -1,19 +1,184 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
+ import { HookResult } from 'nuxt/schema';
3
+ import { ContextType, GraphqlServerResponse, OperationResponseError } from '../dist/runtime/types.js';
2
4
  import { Types } from '@graphql-codegen/plugin-helpers';
3
5
  import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
4
6
  import { GeneratorOptions } from 'graphql-typescript-deluxe';
5
- import { HookResult } from 'nuxt/schema';
6
- import { ContextType, GraphqlServerResponse, OperationResponseError } from '../dist/runtime/types.js';
7
7
  import { H3Event } from 'h3';
8
8
  import { FetchOptions, FetchResponse, FetchError } from 'ofetch';
9
9
 
10
+ interface ModuleOptions {
11
+ /**
12
+ * File glob patterns for the auto import feature.
13
+ *
14
+ * If left empty, no documents are auto imported.
15
+ *
16
+ * @default
17
+ * ```json
18
+ * ["**\/.{gql,graphql}", "!node_modules"]
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * // Load .graphql files from pages folder and from a node_modules dependency.
24
+ * const autoImportPatterns = [
25
+ * './pages/**\/*.graphql',
26
+ * 'node_modules/my_library/dist/**\/*.graphql'
27
+ * ]
28
+ * ```
29
+ */
30
+ autoImportPatterns?: string[];
31
+ /**
32
+ * The path where your graphql.config.ts is, relative to the location of nuxt.config.ts.
33
+ *
34
+ * Used to generate the correct paths in the graphql.config.ts file generated by the module.
35
+ *
36
+ * @default "./graphql.config.ts"
37
+ */
38
+ graphqlConfigFilePath?: string;
39
+ /**
40
+ * Additional raw documents to include.
41
+ *
42
+ * Useful if for example you need to generate queries during build time.
43
+ *
44
+ * @default []
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const documents = [`
49
+ * query myQuery {
50
+ * articles {
51
+ * title
52
+ * id
53
+ * }
54
+ * }`,
55
+ * ...getGeneratedDocuments()
56
+ * ]
57
+ * ```
58
+ */
59
+ documents?: string[];
60
+ /**
61
+ * Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
62
+ * composables should be included.
63
+ *
64
+ * @default ```ts
65
+ * true
66
+ * ```
67
+ */
68
+ includeComposables?: boolean;
69
+ /**
70
+ * Enable support for uploading files via GraphQL.
71
+ *
72
+ * When enabled, an additional `useGraphqlUploadMutation` composable is
73
+ * included, in addition to a new server endpoint that handles multi part
74
+ * file uploads for GraphQL mutations.
75
+ */
76
+ enableFileUploads?: boolean;
77
+ /**
78
+ * Enable detailled debugging messages.
79
+ *
80
+ * @default false
81
+ */
82
+ debug?: boolean;
83
+ /**
84
+ * Displays GraphQL response errors in an overlay in dev mode.
85
+ */
86
+ errorOverlay?: boolean;
87
+ /**
88
+ * The URL of the GraphQL server.
89
+ *
90
+ * For the runtime execution you can provide a method that determines the endpoint
91
+ * during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
92
+ * for more information.
93
+ */
94
+ graphqlEndpoint: string;
95
+ /**
96
+ * Download the GraphQL schema and store it on disk.
97
+ *
98
+ * Usually you'll want to only enable this during dev mode.
99
+ *
100
+ * @default true
101
+ */
102
+ downloadSchema?: boolean;
103
+ /**
104
+ * Path to the GraphQL schema file.
105
+ *
106
+ * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
107
+ * If `downloadSchema` is `false`, this file must be present in order to generate types.
108
+ *
109
+ * @default './schema.graphql'
110
+ */
111
+ schemaPath?: string;
112
+ /**
113
+ * The prefix for the server route.
114
+ *
115
+ * @default ```ts
116
+ * "/api/graphql_middleware"
117
+ * ```
118
+ */
119
+ serverApiPrefix?: string;
120
+ /**
121
+ * Logs only errors.
122
+ *
123
+ * When enabled only errors are logged to the console when generating the GraphQL operations.
124
+ * If false, all operations are logged, including valid ones.
125
+ */
126
+ logOnlyErrors?: boolean;
127
+ /**
128
+ * Options for graphql-typescript-deluxe code generator.
129
+ */
130
+ codegenConfig?: GeneratorOptions;
131
+ /**
132
+ * Configuration for graphql-codegen when downloading the schema.
133
+ */
134
+ codegenSchemaConfig?: {
135
+ /**
136
+ * Configure how the schema.graphql file should be generated.
137
+ */
138
+ schemaAstConfig?: SchemaASTConfig;
139
+ /**
140
+ * Configure how the schema-ast introspection request should be made.
141
+ *
142
+ * Usually this is where you can provide a custom authentication header:
143
+ *
144
+ * ```typescript
145
+ * const codegenSchemaConfig = {
146
+ * urlSchemaOptions: {
147
+ * headers: {
148
+ * authentication: 'foobar',
149
+ * }
150
+ * }
151
+ * }
152
+ * ```
153
+ */
154
+ urlSchemaOptions?: Types.UrlSchemaOptions;
155
+ };
156
+ /**
157
+ * Set to true if you want to output each compiled query and mutation in the
158
+ * .nuxt folder.
159
+ * Set to a path to output to a custom path.
160
+ */
161
+ outputDocuments?: boolean | string;
162
+ /**
163
+ * Enable Nuxt DevTools integration.
164
+ */
165
+ devtools?: boolean;
166
+ /**
167
+ * Client caching configuration.
168
+ */
169
+ clientCache?: {
170
+ enabled?: boolean;
171
+ maxSize?: number;
172
+ };
173
+ }
174
+
10
175
  type GraphqlMiddlewareRequestContext<C extends ContextType = ContextType> = {
11
176
  client?: Partial<C>;
12
177
  };
13
- type GraphqlMiddlewareGraphqlEndpointMethod<C extends ContextType> = (event?: H3Event, operation?: string, operationName?: string, context?: GraphqlMiddlewareRequestContext<C>) => string | Promise<string> | undefined;
14
- type GraphqlMiddlewareServerFetchOptionsMethod<C extends ContextType> = (event?: H3Event, operation?: string, operationName?: string, context?: GraphqlMiddlewareRequestContext<C>) => FetchOptions | Promise<FetchOptions>;
15
- type GraphqlMiddlewareOnServerResponseMethod<ServerReponse, T, C extends ContextType> = (event: H3Event, response: FetchResponse<ServerReponse>, operation?: string, operationName?: string, context?: GraphqlMiddlewareRequestContext<C>) => T | Promise<T>;
16
- type GraphqlMiddlewareOnServerErrorMethod<C extends ContextType> = (event: H3Event, error: FetchError, operation?: string, operationName?: string, context?: GraphqlMiddlewareRequestContext<C>) => any | Promise<any>;
178
+ type GraphqlMiddlewareGraphqlEndpointMethod<C extends ContextType> = (event?: H3Event, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => string | Promise<string> | undefined;
179
+ type GraphqlMiddlewareServerFetchOptionsMethod<C extends ContextType> = (event?: H3Event, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => FetchOptions | Promise<FetchOptions>;
180
+ type GraphqlMiddlewareOnServerResponseMethod<ServerReponse, T, C extends ContextType> = (event: H3Event, response: FetchResponse<ServerReponse>, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => T | Promise<T>;
181
+ type GraphqlMiddlewareOnServerErrorMethod<C extends ContextType> = (event: H3Event, error: FetchError, operation?: string | null, operationName?: string | null, context?: GraphqlMiddlewareRequestContext<C> | null) => any | Promise<any>;
17
182
  type GraphqlMiddlewareDoRequestMethodContext<C extends ContextType> = {
18
183
  /**
19
184
  * The incoming request event from H3.
@@ -22,11 +187,11 @@ type GraphqlMiddlewareDoRequestMethodContext<C extends ContextType> = {
22
187
  /**
23
188
  * The type of operation.
24
189
  */
25
- operation: 'query' | 'mutation';
190
+ operation?: 'query' | 'mutation';
26
191
  /**
27
192
  * The name of the operation.
28
193
  */
29
- operationName: string;
194
+ operationName?: string;
30
195
  /**
31
196
  * The operation document (the raw GraphQL query/mutation as a string).
32
197
  */
@@ -199,160 +364,6 @@ type GraphqlMiddlewareServerOptions<Additions extends object = object, ResponseU
199
364
  doGraphqlRequest?: GraphqlMiddlewareDoRequestMethod<CustomResponse, C>;
200
365
  };
201
366
 
202
- interface ModuleOptions {
203
- /**
204
- * File glob patterns for the auto import feature.
205
- *
206
- * If left empty, no documents are auto imported.
207
- *
208
- * @default
209
- * ```json
210
- * ["**\/.{gql,graphql}", "!node_modules"]
211
- * ```
212
- *
213
- * @example
214
- * ```ts
215
- * // Load .graphql files from pages folder and from a node_modules dependency.
216
- * const autoImportPatterns = [
217
- * './pages/**\/*.graphql',
218
- * 'node_modules/my_library/dist/**\/*.graphql'
219
- * ]
220
- * ```
221
- */
222
- autoImportPatterns?: string[];
223
- /**
224
- * Additional raw documents to include.
225
- *
226
- * Useful if for example you need to generate queries during build time.
227
- *
228
- * @default []
229
- *
230
- * @example
231
- * ```ts
232
- * const documents = [`
233
- * query myQuery {
234
- * articles {
235
- * title
236
- * id
237
- * }
238
- * }`,
239
- * ...getGeneratedDocuments()
240
- * ]
241
- * ```
242
- */
243
- documents?: string[];
244
- /**
245
- * Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
246
- * composables should be included.
247
- *
248
- * @default ```ts
249
- * true
250
- * ```
251
- */
252
- includeComposables?: boolean;
253
- /**
254
- * Enable support for uploading files via GraphQL.
255
- *
256
- * When enabled, an additional `useGraphqlUploadMutation` composable is
257
- * included, in addition to a new server endpoint that handles multi part
258
- * file uploads for GraphQL mutations.
259
- */
260
- enableFileUploads?: boolean;
261
- /**
262
- * Enable detailled debugging messages.
263
- *
264
- * @default false
265
- */
266
- debug?: boolean;
267
- /**
268
- * Displays GraphQL response errors in an overlay in dev mode.
269
- */
270
- errorOverlay?: boolean;
271
- /**
272
- * The URL of the GraphQL server.
273
- *
274
- * For the runtime execution you can provide a method that determines the endpoint
275
- * during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
276
- * for more information.
277
- */
278
- graphqlEndpoint: string;
279
- /**
280
- * Download the GraphQL schema and store it on disk.
281
- *
282
- * @default true
283
- */
284
- downloadSchema?: boolean;
285
- /**
286
- * The prefix for the server route.
287
- *
288
- * @default ```ts
289
- * "/api/graphql_middleware"
290
- * ```
291
- */
292
- serverApiPrefix?: string;
293
- /**
294
- * Path to the GraphQL schema file.
295
- *
296
- * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
297
- * If `downloadSchema` is `false`, this file must be present in order to generate types.
298
- *
299
- * @default './schema.graphql'
300
- */
301
- schemaPath?: string;
302
- /**
303
- * Logs only errors.
304
- *
305
- * When enabled only errors are logged to the console when generating the GraphQL operations.
306
- * If false, all operations are logged, including valid ones.
307
- */
308
- logOnlyErrors?: boolean;
309
- /**
310
- * Options for graphql-typescript-deluxe code generator.
311
- */
312
- codegenConfig?: GeneratorOptions;
313
- /**
314
- * Configuration for graphql-codegen when downloading the schema.
315
- */
316
- codegenSchemaConfig?: {
317
- /**
318
- * Configure how the schema.graphql file should be generated.
319
- */
320
- schemaAstConfig?: SchemaASTConfig;
321
- /**
322
- * Configure how the schema-ast introspection request should be made.
323
- *
324
- * Usually this is where you can provide a custom authentication header:
325
- *
326
- * ```typescript
327
- * const codegenSchemaConfig = {
328
- * urlSchemaOptions: {
329
- * headers: {
330
- * authentication: 'foobar',
331
- * }
332
- * }
333
- * }
334
- * ```
335
- */
336
- urlSchemaOptions?: Types.UrlSchemaOptions;
337
- };
338
- /**
339
- * Set to true if you want to output each compiled query and mutation in the
340
- * .nuxt folder.
341
- * Set to a path to output to a custom path.
342
- */
343
- outputDocuments?: boolean | string;
344
- /**
345
- * Enable Nuxt DevTools integration.
346
- */
347
- devtools?: boolean;
348
- /**
349
- * Client caching configuration.
350
- */
351
- clientCache?: {
352
- enabled?: boolean;
353
- maxSize?: number;
354
- };
355
- }
356
367
  interface ModuleHooks {
357
368
  }
358
369
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
@@ -360,15 +371,34 @@ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, fa
360
371
  declare module '@nuxt/schema' {
361
372
  interface AppConfig {
362
373
  graphqlMiddleware: {
374
+ /**
375
+ * Whether the client cache is enabled.
376
+ */
363
377
  clientCacheEnabled: boolean;
378
+ /**
379
+ * The max number of items in the cache.
380
+ */
364
381
  clientCacheMaxSize: number;
365
382
  };
366
383
  }
367
384
  }
368
385
  declare module '#app' {
369
386
  interface RuntimeNuxtHooks {
387
+ /**
388
+ * Emitted when any GraphQL response contains errors.
389
+ */
370
390
  'nuxt-graphql-middleware:errors': (errors: OperationResponseError) => HookResult;
371
391
  }
372
392
  }
393
+ declare module 'vite/types/customEvent.d.ts' {
394
+ interface CustomEventMap {
395
+ /**
396
+ * Emitted when GraphQL operations have been updated.
397
+ */
398
+ 'nuxt-graphql-middleware:reload': {
399
+ operations: string[];
400
+ };
401
+ }
402
+ }
373
403
 
374
404
  export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql-middleware",
3
3
  "configKey": "graphqlMiddleware",
4
- "version": "5.0.0-alpha.5",
4
+ "version": "5.0.0-alpha.7",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.15.0"
7
7
  },