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

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/f9591c09-e7d8-4bd8-85b5-0987cee82c28.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 -38
  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
package/dist/module.d.mts CHANGED
@@ -1,510 +1,14 @@
1
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
- import { GraphQLSchema, GraphQLNamedType } from 'graphql';
6
- import { Nuxt, ResolvedNuxtTemplate, WatchEvent, HookResult } from 'nuxt/schema';
7
- import { Resolver } from '@nuxt/kit';
8
- import { RouterMethod } from 'h3';
2
+ import { M as ModuleContext, a as ModuleOptions } from './shared/nuxt-graphql-middleware.DLNGE1zJ.mjs';
9
3
  import { OperationResponseError } from '../dist/runtime/types.js';
10
- export { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
4
+ import { HookResult } from 'nuxt/schema';
5
+ import 'graphql';
6
+ import '@nuxt/kit';
7
+ import 'h3';
8
+ import '@graphql-codegen/plugin-helpers';
9
+ import '@graphql-codegen/schema-ast';
10
+ import 'graphql-typescript-deluxe';
11
11
 
12
- interface ModuleOptions {
13
- /**
14
- * File glob patterns for the auto import feature.
15
- *
16
- * If left empty, no documents are auto imported.
17
- *
18
- * @default
19
- * ```json
20
- * ["**\/.{gql,graphql}", "!node_modules"]
21
- * ```
22
- *
23
- * @example
24
- * ```ts
25
- * // Load .graphql files from pages folder and from a node_modules dependency.
26
- * const autoImportPatterns = [
27
- * './pages/**\/*.graphql',
28
- * 'node_modules/my_library/dist/**\/*.graphql'
29
- * ]
30
- * ```
31
- */
32
- autoImportPatterns?: string[];
33
- /**
34
- * The path where your graphql.config.ts is, relative to the location of nuxt.config.ts.
35
- *
36
- * Used to generate the correct paths in the graphql.config.ts file generated by the module.
37
- *
38
- * @default "./graphql.config.ts"
39
- */
40
- graphqlConfigFilePath?: string;
41
- /**
42
- * Additional raw documents to include.
43
- *
44
- * Useful if for example you need to generate queries during build time.
45
- *
46
- * @default []
47
- *
48
- * @example
49
- * ```ts
50
- * const documents = [`
51
- * query myQuery {
52
- * articles {
53
- * title
54
- * id
55
- * }
56
- * }`,
57
- * ...getGeneratedDocuments()
58
- * ]
59
- * ```
60
- */
61
- documents?: string[];
62
- /**
63
- * Wether the useGraphqlQuery, useGraphqlMutation and useGraphqlState
64
- * composables should be included.
65
- *
66
- * @default ```ts
67
- * true
68
- * ```
69
- */
70
- includeComposables?: boolean;
71
- /**
72
- * Enable support for uploading files via GraphQL.
73
- *
74
- * When enabled, an additional `useGraphqlUploadMutation` composable is
75
- * included, in addition to a new server endpoint that handles multi part
76
- * file uploads for GraphQL mutations.
77
- */
78
- enableFileUploads?: boolean;
79
- /**
80
- * Enable detailled debugging messages.
81
- *
82
- * @default false
83
- */
84
- debug?: boolean;
85
- /**
86
- * Displays GraphQL response errors in an overlay in dev mode.
87
- */
88
- errorOverlay?: boolean;
89
- /**
90
- * The URL of the GraphQL server.
91
- *
92
- * For the runtime execution you can provide a method that determines the endpoint
93
- * during runtime. See the server/graphqlMiddleware.serverOptions.ts documentation
94
- * for more information.
95
- */
96
- graphqlEndpoint: string;
97
- /**
98
- * Download the GraphQL schema and store it on disk.
99
- *
100
- * Usually you'll want to only enable this during dev mode.
101
- *
102
- * @default true
103
- */
104
- downloadSchema?: boolean;
105
- /**
106
- * Path to the GraphQL schema file.
107
- *
108
- * If `downloadSchema` is `true`, the downloaded schema is written to this specified path.
109
- * If `downloadSchema` is `false`, this file must be present in order to generate types.
110
- *
111
- * @default './schema.graphql'
112
- */
113
- schemaPath?: string;
114
- /**
115
- * The prefix for the server route.
116
- *
117
- * @default ```ts
118
- * "/api/graphql_middleware"
119
- * ```
120
- */
121
- serverApiPrefix?: string;
122
- /**
123
- * Logs only errors.
124
- *
125
- * When enabled only errors are logged to the console when generating the GraphQL operations.
126
- * If false, all operations are logged, including valid ones.
127
- */
128
- logOnlyErrors?: boolean;
129
- /**
130
- * Options for graphql-typescript-deluxe code generator.
131
- *
132
- * @see [GeneratorOptions](https://github.com/dulnan/graphql-typescript-deluxe/blob/main/src/types/options.ts#L193)
133
- */
134
- codegenConfig?: GeneratorOptions;
135
- /**
136
- * Configuration for graphql-codegen when downloading the schema.
137
- */
138
- codegenSchemaConfig?: {
139
- /**
140
- * Configure how the schema.graphql file should be generated.
141
- *
142
- * @see [SchemaASTConfig](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/schema-ast/src/index.ts#L23)
143
- */
144
- schemaAstConfig?: SchemaASTConfig;
145
- /**
146
- * Configure how the schema-ast introspection request should be made.
147
- *
148
- * Usually this is where you can provide a custom authentication header:
149
- *
150
- * ```typescript
151
- * const codegenSchemaConfig = {
152
- * urlSchemaOptions: {
153
- * headers: {
154
- * authentication: 'foobar',
155
- * }
156
- * }
157
- * }
158
- * ```
159
- *
160
- * @see [Types.UrlSchemaOptions](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/utils/plugins-helpers/src/types.ts#L82)
161
- */
162
- urlSchemaOptions?: Types.UrlSchemaOptions;
163
- };
164
- /**
165
- * Set to true if you want to output each compiled query and mutation in the
166
- * .nuxt folder.
167
- * Set to a path to output to a custom path.
168
- */
169
- outputDocuments?: boolean | string;
170
- /**
171
- * Enable Nuxt DevTools integration.
172
- */
173
- devtools?: boolean;
174
- /**
175
- * Client caching configuration.
176
- */
177
- clientCache?: {
178
- enabled?: boolean;
179
- maxSize?: number;
180
- };
181
- }
182
-
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
- declare const defaultOptions: ModuleOptions;
193
-
194
- declare class ConsolePrompt {
195
- private abortController;
196
- confirm(message: string): Promise<'yes' | 'no' | 'cancel'>;
197
- abort(): void;
198
- }
199
-
200
- type TemplateOptions = {
201
- path: string;
202
- virtual?: boolean;
203
- };
204
- type GeneratorTemplateCallback = (output: GeneratorOutput, helper: ModuleHelper) => string;
205
- type StaticTemplateCallback = (helper: ModuleHelper) => string;
206
- type GeneratorTemplate = {
207
- type: 'generator';
208
- options: TemplateOptions;
209
- build: GeneratorTemplateCallback | null;
210
- buildTypes: GeneratorTemplateCallback | null;
211
- virtual?: boolean;
212
- };
213
- type StaticTemplate = {
214
- type: 'static';
215
- options: TemplateOptions;
216
- build: StaticTemplateCallback | null;
217
- buildTypes: StaticTemplateCallback | null;
218
- virtual?: boolean;
219
- };
220
-
221
- type WithRequired<T, K extends keyof T> = T & {
222
- [P in K]-?: T[P];
223
- };
224
- type RequiredModuleOptions = WithRequired<ModuleOptions, keyof typeof defaultOptions>;
225
- type ModuleHelperResolvers = {
226
- /**
227
- * Resolver for paths relative to the module root.
228
- */
229
- module: Resolver;
230
- /**
231
- * Resolve relative to the app's server directory.
232
- */
233
- server: Resolver;
234
- /**
235
- * Resolve relative to the Nuxt src folder.
236
- */
237
- src: Resolver;
238
- /**
239
- * Resolve relative to the Nuxt app directory.
240
- */
241
- app: Resolver;
242
- /**
243
- * Resolve relative to the Nuxt root.
244
- *
245
- * Should be where nuxt.config.ts is located.
246
- */
247
- root: Resolver;
248
- };
249
- type ModuleHelperPaths = {
250
- runtimeTypes: string;
251
- root: string;
252
- nuxtConfig: string;
253
- serverDir: string;
254
- schema: string;
255
- serverOptions: string | null;
256
- clientOptions: string | null;
257
- moduleBuildDir: string;
258
- moduleTypesDir: string;
259
- };
260
- declare class ModuleHelper {
261
- private nuxt;
262
- readonly resolvers: ModuleHelperResolvers;
263
- readonly paths: ModuleHelperPaths;
264
- readonly isDev: boolean;
265
- readonly options: RequiredModuleOptions;
266
- readonly prompt: ConsolePrompt;
267
- private nitroExternals;
268
- private tsPaths;
269
- constructor(nuxt: Nuxt, moduleUrl: string, options: ModuleOptions);
270
- /**
271
- * Find the path to the graphqlMiddleware.serverOptions.ts file.
272
- */
273
- private findServerOptions;
274
- private findClientOptions;
275
- /**
276
- * Transform the path relative to the module's build directory.
277
- *
278
- * @param path - The absolute path.
279
- *
280
- * @returns The path relative to the module's build directory.
281
- */
282
- toModuleBuildRelative(path: string): string;
283
- /**
284
- * Transform the path relative to the Nuxt build directory.
285
- *
286
- * @param path - The absolute path.
287
- *
288
- * @returns The path relative to the module's build directory.
289
- */
290
- toBuildRelative(path: string): string;
291
- /**
292
- * Get all file paths that match the import patterns.
293
- */
294
- getImportPatternFiles(): Promise<string[]>;
295
- matchesImportPattern(filePath: string): boolean;
296
- addAlias(name: string, path: string): void;
297
- inlineNitroExternals(arg: ResolvedNuxtTemplate | string): void;
298
- transpile(path: string): void;
299
- applyBuildConfig(): void;
300
- processTemplate(path: string, content: string): string;
301
- addTemplate(template: StaticTemplate): void;
302
- addPlugin(name: string): void;
303
- addServerHandler(name: string, path: string, method: RouterMethod): void;
304
- addComposable(name: string): void;
305
- addServerUtil(name: string): void;
306
- }
307
-
308
- type CollectorWatchEventResult = {
309
- hasChanged: boolean;
310
- affectedOperations: string[];
311
- error?: {
312
- message: string;
313
- };
314
- };
315
- declare class Collector {
316
- private schema;
317
- private helper;
318
- /**
319
- * All collected files.
320
- */
321
- private files;
322
- /**
323
- * All documents provided by hooks.
324
- */
325
- private hookDocuments;
326
- /**
327
- * All file paths provided by hooks.
328
- */
329
- private hookFiles;
330
- /**
331
- * The code generator.
332
- */
333
- private generator;
334
- /**
335
- * A map of operation name and timestamp when the operation was last validated.
336
- */
337
- private operationTimestamps;
338
- /**
339
- * The generated operations and fragments.
340
- */
341
- readonly rpcItems: Map<string, RpcItem>;
342
- /**
343
- * The registered templates.
344
- */
345
- private templates;
346
- /**
347
- * The generated template contents.
348
- */
349
- private templateResult;
350
- constructor(schema: GraphQLSchema, helper: ModuleHelper);
351
- reset(): Promise<void>;
352
- updateSchema(schema: GraphQLSchema): Promise<void>;
353
- private filePathToBuildRelative;
354
- private filePathToSourceRelative;
355
- private operationToLogEntry;
356
- private getTemplate;
357
- /**
358
- * Executes code gen and performs validation for operations.
359
- */
360
- private buildState;
361
- private buildErrorMessage;
362
- private logError;
363
- /**
364
- * Initialise the collector.
365
- *
366
- * In dev mode, the method will call itself recursively until all documents
367
- * are valid.
368
- *
369
- * If not in dev mode the method will throw an error when documents are not
370
- * valid.
371
- */
372
- init(): Promise<void>;
373
- addHookDocument(identifier: string, source: string): void;
374
- addHookFile(filePath: string): void;
375
- /**
376
- * Initialise the collector.
377
- */
378
- private initDocuments;
379
- /**
380
- * Add a file.
381
- */
382
- private addFile;
383
- private matchesPatternOrExists;
384
- private handleAdd;
385
- private handleChange;
386
- private handleUnlink;
387
- private handleUnlinkDir;
388
- /**
389
- * Handle the watcher event for the given file path.
390
- */
391
- handleWatchEvent(event: WatchEvent, filePath: string): Promise<CollectorWatchEventResult>;
392
- /**
393
- * Adds a virtual template (not written to disk) for both Nuxt and Nitro.
394
- *
395
- * For some reason a template written to disk works for both Nuxt and Nitro,
396
- * but a virtual template requires adding two templates.
397
- */
398
- private addVirtualTemplate;
399
- /**
400
- * Adds a template that dependes on Collector state.
401
- */
402
- addTemplate(template: GeneratorTemplate): void;
403
- }
404
-
405
- /**
406
- * Handles downloading, loading and saving the GraphQL schema.
407
- */
408
- declare class SchemaProvider {
409
- private helper;
410
- /**
411
- * The raw schema content.
412
- */
413
- private schemaContent;
414
- /**
415
- * The parsed schema object.
416
- */
417
- private schema;
418
- constructor(helper: ModuleHelper);
419
- init(): Promise<void>;
420
- private loadFromDiskFallback;
421
- /**
422
- * Loads the schema from disk.
423
- *
424
- * @returns The schema contents from disk.
425
- */
426
- private loadSchemaFromDisk;
427
- /**
428
- * Downloads the schema and saves it to disk.
429
- *
430
- * @returns The schema contents.
431
- */
432
- private downloadSchema;
433
- /**
434
- * Determine if the schema exists on disk.
435
- *
436
- * @returns True if the schema file exists on disk.
437
- */
438
- hasSchemaOnDisk(): Promise<boolean>;
439
- /**
440
- * Load the schema either from disk or by downloading it.
441
- *
442
- * @param forceDownload - Forces downloading the schema.
443
- */
444
- loadSchema(opts?: {
445
- forceDownload?: boolean;
446
- forceDisk?: boolean;
447
- }): Promise<void>;
448
- /**
449
- * Get the schema.
450
- *
451
- * @returns The parsed GraphQL schema object.
452
- */
453
- getSchema(): GraphQLSchema;
454
- }
455
-
456
- /**
457
- * The public module context class.
458
- */
459
- declare class ModuleContext {
460
- private schemaProvider;
461
- private collector;
462
- constructor(schemaProvider: SchemaProvider, collector: Collector);
463
- /**
464
- * Return the GraphQL schema.
465
- *
466
- * Note that the schema may be updated during development, so it can become
467
- * stale. Prefer using methods like `schemaHasType()` to query the schema.
468
- *
469
- * @returns The GraphQL schema.
470
- */
471
- getSchema(): GraphQLSchema;
472
- /**
473
- * Check if the given GraphQL type (interface, concrete type, enum, input type)
474
- * exists in the schema.
475
- *
476
- * @param name - The name of the type.
477
- *
478
- * @returns True if the type exists in the schema.
479
- */
480
- schemaHasType(name: string): boolean;
481
- /**
482
- * Get a type from the schema.
483
- *
484
- * @param name - The name of the type.
485
- *
486
- * @returns The type.
487
- */
488
- schemaGetType(name: string): GraphQLNamedType | undefined;
489
- /**
490
- * Add an additional static document.
491
- *
492
- * @param identifier - The unique identifier for your document.
493
- * @param source - The document source.
494
- */
495
- addDocument(identifier: string, source: string): ModuleContext;
496
- /**
497
- * Add an additional GraphQL file to import.
498
- *
499
- * @param filePath - The absolute path to the file.
500
- */
501
- addImportFile(filePath: string): ModuleContext;
502
- }
503
-
504
- declare function useGraphqlModuleContext(): ModuleContext;
505
- declare function useGraphqlModuleContext(options: {
506
- nullOnMissing: true;
507
- }): ModuleContext | null;
508
12
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
509
13
 
510
14
  declare module '#app' {
@@ -571,5 +75,4 @@ declare module '@nuxt/schema' {
571
75
  }
572
76
  }
573
77
 
574
- export { _default as default, useGraphqlModuleContext };
575
- export type { ModuleOptions };
78
+ 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.16",
4
+ "version": "5.0.0-alpha.18",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.15.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
  }
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { useLogger, addTemplate, addServerTemplate, addTypeTemplate, createResolver, resolveAlias, resolveFiles, addPlugin, addServerHandler, addImports, addServerImports, useNitro, defineNuxtModule, useNuxt } from '@nuxt/kit';
2
+ import { useLogger, addTemplate, addServerTemplate, addTypeTemplate, createResolver, resolveAlias, resolveFiles, addPlugin, addServerHandler, addImports, addServerImports, useNitro, defineNuxtModule } from '@nuxt/kit';
3
3
  import { existsSync, promises } from 'node:fs';
4
4
  import { basename } from 'node:path';
5
5
  import { relative } from 'pathe';
@@ -19,7 +19,7 @@ import { existsSync as existsSync$1 } from 'fs';
19
19
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
20
20
 
21
21
  const name = "nuxt-graphql-middleware";
22
- const version = "5.0.0-alpha.16";
22
+ const version = "5.0.0-alpha.18";
23
23
 
24
24
  const logger = useLogger("nuxt-graphql-middleware");
25
25
  const defaultOptions = {
@@ -778,7 +778,6 @@ ${color.cyan(S_BAR_END)}
778
778
  class ModuleHelper {
779
779
  constructor(nuxt, moduleUrl, options) {
780
780
  this.nuxt = nuxt;
781
- const isModuleBuild = process.env.PLAYGROUND_MODULE_BUILD === "true" && nuxt.options._prepare;
782
781
  const mergedOptions = defu({}, options, defaultOptions);
783
782
  if (!mergedOptions.autoImportPatterns) {
784
783
  mergedOptions.autoImportPatterns = [
@@ -786,15 +785,6 @@ class ModuleHelper {
786
785
  "!node_modules"
787
786
  ];
788
787
  }
789
- if (isModuleBuild) {
790
- mergedOptions.graphqlEndpoint = "http://localhost";
791
- mergedOptions.downloadSchema = false;
792
- mergedOptions.schemaPath = "~~/schema.graphql";
793
- mergedOptions.autoImportPatterns = [
794
- "~~/playground/**/*.{gql,graphql}",
795
- "!node_modules"
796
- ];
797
- }
798
788
  const layerAliases = nuxt.options._layers.map((layer) => {
799
789
  return {
800
790
  "~~": layer.config.rootDir,
@@ -1052,16 +1042,16 @@ export { clientOptions }
1052
1042
  helper.paths.clientOptions
1053
1043
  );
1054
1044
  return `import type { GraphqlClientOptions } from '${helper.paths.runtimeTypes}'
1055
- import clientOptions from '${pathRelative}'
1056
-
1057
- export type GraphqlClientContext = typeof clientOptions extends GraphqlClientOptions<infer R> ? R : {}
1045
+ import clientOptionsImport from '${pathRelative}'
1058
1046
 
1059
- export { clientOptions }`;
1047
+ declare export const clientOptions: GraphqlClientOptions
1048
+ export type GraphqlClientContext = typeof clientOptionsImport extends GraphqlClientOptions<infer R> ? R : {}
1049
+ `;
1060
1050
  }
1061
1051
  return `
1062
1052
  import type { GraphqlClientOptions } from '${helper.paths.runtimeTypes}'
1063
- export const clientOptions: GraphqlClientOptions
1064
1053
 
1054
+ declare export const clientOptions: GraphqlClientOptions
1065
1055
  export type GraphqlClientContext = {}
1066
1056
  `;
1067
1057
  }
@@ -1228,16 +1218,27 @@ export { serverOptions }
1228
1218
  `;
1229
1219
  },
1230
1220
  (helper) => {
1231
- const resolvedPathRelative = helper.paths.serverOptions ? helper.toModuleBuildRelative(helper.paths.serverOptions) : null;
1232
- const serverOptionsLineTypes = resolvedPathRelative ? `import serverOptions from '${resolvedPathRelative}'` : `const serverOptions: GraphqlMiddlewareServerOptions = {}`;
1233
- return `
1221
+ if (helper.paths.serverOptions) {
1222
+ const resolvedPathRelative = helper.toModuleBuildRelative(
1223
+ helper.paths.serverOptions
1224
+ );
1225
+ return `
1234
1226
  import type { GraphqlMiddlewareServerOptions } from '${helper.paths.runtimeTypes}'
1235
- ${serverOptionsLineTypes}
1227
+ import serverOptionsImport from '${resolvedPathRelative}'
1236
1228
 
1237
1229
  export type GraphqlResponseAdditions =
1238
- typeof serverOptions extends GraphqlMiddlewareServerOptions<infer R, any, any> ? R : {}
1230
+ typeof serverOptionsImport extends GraphqlMiddlewareServerOptions<infer R, any, any> ? R : {}
1239
1231
 
1240
- export { serverOptions }`;
1232
+ declare export const serverOptions: GraphqlMiddlewareServerOptions
1233
+ `;
1234
+ }
1235
+ return `
1236
+ import type { GraphqlMiddlewareServerOptions } from '${helper.paths.runtimeTypes}'
1237
+
1238
+ declare export const serverOptions: GraphqlMiddlewareServerOptions
1239
+
1240
+ export type GraphqlResponseAdditions = object
1241
+ `;
1241
1242
  }
1242
1243
  );
1243
1244
 
@@ -1508,20 +1509,6 @@ class ModuleContext {
1508
1509
  }
1509
1510
  }
1510
1511
 
1511
- const CONTEXT_KEY = "_nuxt_graphql_middleware";
1512
- function useGraphqlModuleContext(options) {
1513
- const nuxt = useNuxt();
1514
- const context = nuxt[CONTEXT_KEY];
1515
- if (!context) {
1516
- if (options?.nullOnMissing) {
1517
- return null;
1518
- }
1519
- throw new Error(
1520
- "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."
1521
- );
1522
- }
1523
- return context;
1524
- }
1525
1512
  const module = defineNuxtModule({
1526
1513
  meta: {
1527
1514
  name,
@@ -1601,4 +1588,4 @@ const module = defineNuxtModule({
1601
1588
  }
1602
1589
  });
1603
1590
 
1604
- export { module as default, useGraphqlModuleContext };
1591
+ export { module as default };