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

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.
@@ -0,0 +1 @@
1
+ .n-code-block-lines code{counter-increment:step calc(var(--start, 1) - 1);counter-reset:step}.n-code-block-lines code .line:before{content:counter(step);counter-increment:step;display:inline-block;margin-right:.5rem;padding-right:.5rem;text-align:right;width:2.5rem;color:#a3a3a380}details[data-v-f3591bcd],summary[data-v-f3591bcd]{border-style:none}summary[data-v-f3591bcd]{list-style:none}details[open] summary[data-v-f3591bcd]{border-style:none}details summary[data-v-f3591bcd]::-webkit-details-marker{display:none}details[open] .chevron[data-v-f3591bcd]{opacity:.75;transform:rotate(180deg)}
@@ -1,11 +1,11 @@
1
1
  <!DOCTYPE html><html><head><meta charset="utf-8">
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1">
3
- <link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.AjgXSF89.css" crossorigin>
4
- <link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BawWjxPx.js">
3
+ <link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.Cn9qfNGa.css" crossorigin>
4
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/VpkRx2_e.js">
5
5
  <link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-404.BJkSn6RI.css">
6
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BtHrwWER.js">
7
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BvMfLM9s.js">
6
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CPyoLiCY.js">
7
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/BLvMh1Ga.js">
8
8
  <link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-500.TOCKLquH.css">
9
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/DkAo05uu.js">
10
- <script type="module" src="/__nuxt-graphql-middleware/_nuxt/BawWjxPx.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1742651617305,false]</script>
11
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"1d4cde1f-51c0-4bab-b233-3b063cc8ad1c",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
9
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CBwfSTyQ.js">
10
+ <script type="module" src="/__nuxt-graphql-middleware/_nuxt/VpkRx2_e.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1743158983534,false]</script>
11
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"c16b1fe3-c3fb-4c15-952d-ba148d4025cb",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.d.mts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from 'nuxt/schema';
3
- import { ContextType, GraphqlServerResponse, OperationResponseError } from '../dist/runtime/types.js';
3
+ import { OperationResponseError } from '../dist/runtime/types.js';
4
+ export { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
4
5
  import { Types } from '@graphql-codegen/plugin-helpers';
5
6
  import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
6
7
  import { GeneratorOptions } from 'graphql-typescript-deluxe';
7
- import { H3Event } from 'h3';
8
- import { FetchOptions, FetchResponse, FetchError } from 'ofetch';
9
8
 
10
9
  interface ModuleOptions {
11
10
  /**
@@ -172,200 +171,6 @@ interface ModuleOptions {
172
171
  };
173
172
  }
174
173
 
175
- type GraphqlMiddlewareRequestContext<C extends ContextType = ContextType> = {
176
- client?: Partial<C>;
177
- };
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>;
182
- type GraphqlMiddlewareDoRequestMethodContext<C extends ContextType> = {
183
- /**
184
- * The incoming request event from H3.
185
- */
186
- event: H3Event;
187
- /**
188
- * The type of operation.
189
- */
190
- operation?: 'query' | 'mutation';
191
- /**
192
- * The name of the operation.
193
- */
194
- operationName?: string;
195
- /**
196
- * The operation document (the raw GraphQL query/mutation as a string).
197
- */
198
- operationDocument: string;
199
- /**
200
- * Variables for the operation.
201
- */
202
- variables: Record<string, any>;
203
- /**
204
- * For file uploads (which are done using FormData), this contains the full
205
- * form data with these keys:
206
- *
207
- * - operations: string
208
- * A JSON string of an object with "query", "variables" and "operationName" properties.
209
- * Example:
210
- * operations='{ "query": "mutation ($id: String!, $file: Upload!) { uploadFile(id: $id, file: $file) { id filename } }", "variables": { "file": null, "id": "1" } }'
211
- * - map: string
212
- * A JSON string of an object whose keys are strings starting at '0' and the values being an array with a single string:
213
- * Example:
214
- * map='{ "0": ["variables.file"] }'
215
- * - [number]
216
- * For every file there is a FormData entry with a name that matches the key in `map`.
217
- * Example:
218
- * 0=[Binary File]
219
- */
220
- formData?: FormData;
221
- context: GraphqlMiddlewareRequestContext<C>;
222
- };
223
- type GraphqlMiddlewareDoRequestMethod<T, C extends ContextType> = (context: GraphqlMiddlewareDoRequestMethodContext<C>) => Promise<T>;
224
- /**
225
- * Configuration options during runtime.
226
- */
227
- type GraphqlMiddlewareServerOptions<Additions extends object = object, ResponseUnion extends object = object, C extends ContextType = ContextType, CustomResponse = GraphqlServerResponse<ResponseUnion> & Additions> = {
228
- /**
229
- * Custom callback to return the GraphQL endpoint per request.
230
- *
231
- * The method is only called if no `doGraphqlRequest` method is implemented.
232
- *
233
- * @default undefined
234
- *
235
- * @example
236
- * ```ts
237
- * function graphqlEndpoint(event, operation, operationName) {
238
- * const language = getLanguageFromRequest(event)
239
- * return `https://api.example.com/${language}/graphql`
240
- * }
241
- * ```
242
- */
243
- graphqlEndpoint?: GraphqlMiddlewareGraphqlEndpointMethod<C>;
244
- /**
245
- * Provide the options for the ofetch request to the GraphQL server.
246
- *
247
- * The method is only called if no `doGraphqlRequest` method is implemented.
248
- *
249
- * @default undefined
250
- *
251
- * @example
252
- * ```ts
253
- * import { getHeader } from 'h3'
254
- *
255
- * // Pass the cookie from the client request to the GraphQL request.
256
- * function serverFetchOptions(event, operation, operationName) {
257
- * return {
258
- * headers: {
259
- * Cookie: getHeader(event, 'cookie')
260
- * }
261
- * }
262
- * }
263
- * ```
264
- */
265
- serverFetchOptions?: GraphqlMiddlewareServerFetchOptionsMethod<C>;
266
- /**
267
- * Handle the response from the GraphQL server.
268
- *
269
- * The method is only called if no `doGraphqlRequest` method is implemented.
270
- *
271
- * You can alter the response, add additional properties to the data, get
272
- * and set headers, etc.
273
- *
274
- * ```ts
275
- * import type { H3Event } from 'h3'
276
- * import type { FetchResponse } from 'ofetch'
277
- *
278
- * function onServerResponse(event: H3Event, graphqlResponse: FetchResponse) {
279
- * // Set a static header.
280
- * event.node.res.setHeader('x-nuxt-custom-header', 'A custom header value')
281
- *
282
- * // Pass the set-cookie header from the GraphQL response to the client.
283
- * const setCookie = graphqlResponse.headers.get('set-cookie')
284
- * if (setCookie) {
285
- * event.node.res.setHeader('set-cookie', setCookie)
286
- * }
287
- *
288
- * // Add additional properties to the response.
289
- * graphqlResponse._data.__customProperty = ['My', 'values']
290
- *
291
- * // Return the GraphQL response.
292
- * return graphqlResponse._data
293
- * }
294
- * ```
295
- */
296
- onServerResponse?: GraphqlMiddlewareOnServerResponseMethod<GraphqlServerResponse<ResponseUnion>, CustomResponse, C>;
297
- /**
298
- * Handle a fetch error from the GraphQL request.
299
- *
300
- * The method is only called if no `doGraphqlRequest` method is implemented.
301
- *
302
- * Note that errors are only thrown for responses that are not status
303
- * 200-299. See https://github.com/unjs/ofetch#%EF%B8%8F-handling-errors for
304
- * more information.
305
- *
306
- * ```ts
307
- * import { createError } from 'h3'
308
- * import type { H3Event } from 'h3'
309
- * import type { FetchError } from 'ofetch'
310
- *
311
- * function onServerError(
312
- * event: H3Event,
313
- * error: FetchError,
314
- * operation: string,
315
- * operationName: string,
316
- * ) {
317
- * // Throw a h3 error.
318
- * throw createError({
319
- * statusCode: 500,
320
- * statusMessage: `Couldn't execute GraphQL ${operation} "${operationName}".`,
321
- * data: error.message
322
- * })
323
- * }
324
- * ```
325
- */
326
- onServerError?: GraphqlMiddlewareOnServerErrorMethod<C>;
327
- /**
328
- * Provide a custom fetch method for requests to the GraphQL server.
329
- *
330
- * This can be used if onServerError, onServerResponse, serverFetchOptions
331
- * and graphqlEndpoint are not enough to meet your requirements.
332
- *
333
- * When this method is implemented, all other methods are not called.
334
- *
335
- * The method will be called in the /api/graphql server route and should
336
- * perform the GraphQL request and return the response.
337
- *
338
- * An example use case might be to handle expired tokens.
339
- *
340
- * * ```ts
341
- * async function doGraphqlRequest({
342
- * event,
343
- * operation,
344
- * operationName,
345
- * operationDocument,
346
- * variables,
347
- * }) {
348
- * const result = await $fetch.raw('https://example.com/graphql', {
349
- * method: 'POST'
350
- * body: {
351
- * query: operationDocument,
352
- * variables,
353
- * operationName
354
- * },
355
- * headers: {
356
- * 'custom-header': 'foobar'
357
- * }
358
- * })
359
- *
360
- * return result._data
361
- * }
362
- * ```
363
- */
364
- doGraphqlRequest?: GraphqlMiddlewareDoRequestMethod<CustomResponse, C>;
365
- };
366
-
367
- interface ModuleHooks {
368
- }
369
174
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
370
175
 
371
176
  declare module '@nuxt/schema' {
@@ -401,4 +206,5 @@ declare module 'vite/types/customEvent.d.ts' {
401
206
  }
402
207
  }
403
208
 
404
- export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
209
+ export { _default as default };
210
+ export type { ModuleOptions };
package/dist/module.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from 'nuxt/schema';
3
- import { ContextType, GraphqlServerResponse, OperationResponseError } from '../dist/runtime/types.js';
3
+ import { OperationResponseError } from '../dist/runtime/types.js';
4
+ export { GraphqlMiddlewareServerOptions } from '../dist/runtime/types.js';
4
5
  import { Types } from '@graphql-codegen/plugin-helpers';
5
6
  import { SchemaASTConfig } from '@graphql-codegen/schema-ast';
6
7
  import { GeneratorOptions } from 'graphql-typescript-deluxe';
7
- import { H3Event } from 'h3';
8
- import { FetchOptions, FetchResponse, FetchError } from 'ofetch';
9
8
 
10
9
  interface ModuleOptions {
11
10
  /**
@@ -172,200 +171,6 @@ interface ModuleOptions {
172
171
  };
173
172
  }
174
173
 
175
- type GraphqlMiddlewareRequestContext<C extends ContextType = ContextType> = {
176
- client?: Partial<C>;
177
- };
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>;
182
- type GraphqlMiddlewareDoRequestMethodContext<C extends ContextType> = {
183
- /**
184
- * The incoming request event from H3.
185
- */
186
- event: H3Event;
187
- /**
188
- * The type of operation.
189
- */
190
- operation?: 'query' | 'mutation';
191
- /**
192
- * The name of the operation.
193
- */
194
- operationName?: string;
195
- /**
196
- * The operation document (the raw GraphQL query/mutation as a string).
197
- */
198
- operationDocument: string;
199
- /**
200
- * Variables for the operation.
201
- */
202
- variables: Record<string, any>;
203
- /**
204
- * For file uploads (which are done using FormData), this contains the full
205
- * form data with these keys:
206
- *
207
- * - operations: string
208
- * A JSON string of an object with "query", "variables" and "operationName" properties.
209
- * Example:
210
- * operations='{ "query": "mutation ($id: String!, $file: Upload!) { uploadFile(id: $id, file: $file) { id filename } }", "variables": { "file": null, "id": "1" } }'
211
- * - map: string
212
- * A JSON string of an object whose keys are strings starting at '0' and the values being an array with a single string:
213
- * Example:
214
- * map='{ "0": ["variables.file"] }'
215
- * - [number]
216
- * For every file there is a FormData entry with a name that matches the key in `map`.
217
- * Example:
218
- * 0=[Binary File]
219
- */
220
- formData?: FormData;
221
- context: GraphqlMiddlewareRequestContext<C>;
222
- };
223
- type GraphqlMiddlewareDoRequestMethod<T, C extends ContextType> = (context: GraphqlMiddlewareDoRequestMethodContext<C>) => Promise<T>;
224
- /**
225
- * Configuration options during runtime.
226
- */
227
- type GraphqlMiddlewareServerOptions<Additions extends object = object, ResponseUnion extends object = object, C extends ContextType = ContextType, CustomResponse = GraphqlServerResponse<ResponseUnion> & Additions> = {
228
- /**
229
- * Custom callback to return the GraphQL endpoint per request.
230
- *
231
- * The method is only called if no `doGraphqlRequest` method is implemented.
232
- *
233
- * @default undefined
234
- *
235
- * @example
236
- * ```ts
237
- * function graphqlEndpoint(event, operation, operationName) {
238
- * const language = getLanguageFromRequest(event)
239
- * return `https://api.example.com/${language}/graphql`
240
- * }
241
- * ```
242
- */
243
- graphqlEndpoint?: GraphqlMiddlewareGraphqlEndpointMethod<C>;
244
- /**
245
- * Provide the options for the ofetch request to the GraphQL server.
246
- *
247
- * The method is only called if no `doGraphqlRequest` method is implemented.
248
- *
249
- * @default undefined
250
- *
251
- * @example
252
- * ```ts
253
- * import { getHeader } from 'h3'
254
- *
255
- * // Pass the cookie from the client request to the GraphQL request.
256
- * function serverFetchOptions(event, operation, operationName) {
257
- * return {
258
- * headers: {
259
- * Cookie: getHeader(event, 'cookie')
260
- * }
261
- * }
262
- * }
263
- * ```
264
- */
265
- serverFetchOptions?: GraphqlMiddlewareServerFetchOptionsMethod<C>;
266
- /**
267
- * Handle the response from the GraphQL server.
268
- *
269
- * The method is only called if no `doGraphqlRequest` method is implemented.
270
- *
271
- * You can alter the response, add additional properties to the data, get
272
- * and set headers, etc.
273
- *
274
- * ```ts
275
- * import type { H3Event } from 'h3'
276
- * import type { FetchResponse } from 'ofetch'
277
- *
278
- * function onServerResponse(event: H3Event, graphqlResponse: FetchResponse) {
279
- * // Set a static header.
280
- * event.node.res.setHeader('x-nuxt-custom-header', 'A custom header value')
281
- *
282
- * // Pass the set-cookie header from the GraphQL response to the client.
283
- * const setCookie = graphqlResponse.headers.get('set-cookie')
284
- * if (setCookie) {
285
- * event.node.res.setHeader('set-cookie', setCookie)
286
- * }
287
- *
288
- * // Add additional properties to the response.
289
- * graphqlResponse._data.__customProperty = ['My', 'values']
290
- *
291
- * // Return the GraphQL response.
292
- * return graphqlResponse._data
293
- * }
294
- * ```
295
- */
296
- onServerResponse?: GraphqlMiddlewareOnServerResponseMethod<GraphqlServerResponse<ResponseUnion>, CustomResponse, C>;
297
- /**
298
- * Handle a fetch error from the GraphQL request.
299
- *
300
- * The method is only called if no `doGraphqlRequest` method is implemented.
301
- *
302
- * Note that errors are only thrown for responses that are not status
303
- * 200-299. See https://github.com/unjs/ofetch#%EF%B8%8F-handling-errors for
304
- * more information.
305
- *
306
- * ```ts
307
- * import { createError } from 'h3'
308
- * import type { H3Event } from 'h3'
309
- * import type { FetchError } from 'ofetch'
310
- *
311
- * function onServerError(
312
- * event: H3Event,
313
- * error: FetchError,
314
- * operation: string,
315
- * operationName: string,
316
- * ) {
317
- * // Throw a h3 error.
318
- * throw createError({
319
- * statusCode: 500,
320
- * statusMessage: `Couldn't execute GraphQL ${operation} "${operationName}".`,
321
- * data: error.message
322
- * })
323
- * }
324
- * ```
325
- */
326
- onServerError?: GraphqlMiddlewareOnServerErrorMethod<C>;
327
- /**
328
- * Provide a custom fetch method for requests to the GraphQL server.
329
- *
330
- * This can be used if onServerError, onServerResponse, serverFetchOptions
331
- * and graphqlEndpoint are not enough to meet your requirements.
332
- *
333
- * When this method is implemented, all other methods are not called.
334
- *
335
- * The method will be called in the /api/graphql server route and should
336
- * perform the GraphQL request and return the response.
337
- *
338
- * An example use case might be to handle expired tokens.
339
- *
340
- * * ```ts
341
- * async function doGraphqlRequest({
342
- * event,
343
- * operation,
344
- * operationName,
345
- * operationDocument,
346
- * variables,
347
- * }) {
348
- * const result = await $fetch.raw('https://example.com/graphql', {
349
- * method: 'POST'
350
- * body: {
351
- * query: operationDocument,
352
- * variables,
353
- * operationName
354
- * },
355
- * headers: {
356
- * 'custom-header': 'foobar'
357
- * }
358
- * })
359
- *
360
- * return result._data
361
- * }
362
- * ```
363
- */
364
- doGraphqlRequest?: GraphqlMiddlewareDoRequestMethod<CustomResponse, C>;
365
- };
366
-
367
- interface ModuleHooks {
368
- }
369
174
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
370
175
 
371
176
  declare module '@nuxt/schema' {
@@ -401,4 +206,5 @@ declare module 'vite/types/customEvent.d.ts' {
401
206
  }
402
207
  }
403
208
 
404
- export { type GraphqlMiddlewareServerOptions, type ModuleHooks, type ModuleOptions, _default as default };
209
+ export { _default as default };
210
+ export type { ModuleOptions };
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.7",
4
+ "version": "5.0.0-alpha.8",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.15.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import { useLogger, addTemplate, addServerTemplate, addTypeTemplate, resolveAlias, createResolver, resolveFiles, addPlugin, addServerHandler, addImports, addServerImports, useNitro, defineNuxtModule } from '@nuxt/kit';
3
- import fs from 'node:fs/promises';
4
3
  import { existsSync, promises } from 'node:fs';
5
4
  import { relative } from 'pathe';
6
5
  import { basename } from 'node:path';
@@ -8,6 +7,7 @@ import { printSourceLocation, parse, Source, OperationTypeNode } from 'graphql';
8
7
  import { Generator, FieldNotFoundError, TypeNotFoundError, FragmentNotFoundError } from 'graphql-typescript-deluxe';
9
8
  import color from 'picocolors';
10
9
  import { validateGraphQlDocuments } from '@graphql-tools/utils';
10
+ import fs from 'node:fs/promises';
11
11
  import { generate } from '@graphql-codegen/cli';
12
12
  import * as PluginSchemaAst from '@graphql-codegen/schema-ast';
13
13
  import { loadSchema } from '@graphql-tools/load';
@@ -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.7";
22
+ const version = "5.0.0-alpha.8";
23
23
 
24
24
  const logger = useLogger(name);
25
25
  const defaultOptions = {
@@ -325,7 +325,7 @@ class Collector {
325
325
  async init() {
326
326
  try {
327
327
  await this.initDocuments();
328
- } catch (e) {
328
+ } catch {
329
329
  if (this.helper.isDev) {
330
330
  const shouldRevalidate = await this.helper.prompt.confirm(
331
331
  "Do you want to revalidate the GraphQL documents?"
@@ -868,6 +868,15 @@ class ModuleHelper {
868
868
  pathFromName
869
869
  ];
870
870
  this.nuxt.options.nitro.typescript.tsConfig.compilerOptions.paths[name + "/*"] = [pathFromName + "/*"];
871
+ this.nuxt.options.typescript.tsConfig ||= {};
872
+ this.nuxt.options.typescript.tsConfig.compilerOptions ||= {};
873
+ this.nuxt.options.typescript.tsConfig.compilerOptions.paths ||= {};
874
+ this.nuxt.options.typescript.tsConfig.compilerOptions.paths[name] = [
875
+ pathFromName
876
+ ];
877
+ this.nuxt.options.typescript.tsConfig.compilerOptions.paths[name + "/*"] = [
878
+ pathFromName + "/*"
879
+ ];
871
880
  this.inlineNitroExternals(name);
872
881
  }
873
882
  inlineNitroExternals(arg) {
@@ -1144,11 +1153,8 @@ export { serverOptions }
1144
1153
  (helper) => {
1145
1154
  const resolvedPathRelative = helper.paths.serverOptions ? helper.toModuleBuildRelative(helper.paths.serverOptions) : null;
1146
1155
  const serverOptionsLineTypes = resolvedPathRelative ? `import serverOptions from '${resolvedPathRelative}'` : `const serverOptions: GraphqlMiddlewareServerOptions = {}`;
1147
- const moduleTypesPath = helper.toModuleBuildRelative(
1148
- helper.resolvers.module.resolve("./types")
1149
- );
1150
1156
  return `
1151
- import type { GraphqlMiddlewareServerOptions } from '${moduleTypesPath}'
1157
+ import type { GraphqlMiddlewareServerOptions } from '${helper.paths.runtimeTypes}'
1152
1158
  ${serverOptionsLineTypes}
1153
1159
 
1154
1160
  export type GraphqlResponseAdditions =
@@ -5,7 +5,7 @@ export const useGraphqlState = function(providedApp) {
5
5
  if (app.$graphqlState) {
6
6
  return app.$graphqlState;
7
7
  }
8
- } catch (_e) {
8
+ } catch {
9
9
  }
10
10
  return null;
11
11
  };
@@ -1,7 +1,7 @@
1
- import { type QueryObject } from 'ufo';
1
+ import type { QueryObject } from 'ufo';
2
2
  import type { H3Event } from 'h3';
3
3
  import type { FetchOptions, FetchResponse, FetchError } from 'ofetch';
4
- import type { GraphqlMiddlewareRequestContext, GraphqlMiddlewareRuntimeConfig, GraphqlMiddlewareServerOptions } from './../../../types.js';
4
+ import type { GraphqlMiddlewareRequestContext, GraphqlMiddlewareRuntimeConfig, GraphqlMiddlewareServerOptions } from './../../types.js';
5
5
  import { type GraphqlMiddlewareOperation } from './../../settings/index.js';
6
6
  import type { Mutation, Query } from '#nuxt-graphql-middleware/operation-types';
7
7
  export declare function isValidMutation(v?: string): v is keyof Mutation;
@@ -14,7 +14,7 @@ export function queryParamToVariables(query) {
14
14
  if (query.__variables && typeof query.__variables === "string") {
15
15
  return JSON.parse(query.__variables);
16
16
  }
17
- } catch (_e) {
17
+ } catch {
18
18
  }
19
19
  return query;
20
20
  }
@@ -1,5 +1,5 @@
1
1
  import type { H3Event } from 'h3';
2
- import type { GraphqlMiddlewareRequestContext } from '../../../types.js';
2
+ import type { GraphqlMiddlewareRequestContext } from '../../types.js';
3
3
  import type { GraphqlMiddlewareOperation } from '../../settings/index.js';
4
4
  type RequestBody = {
5
5
  query: string;
@@ -1,4 +1,4 @@
1
1
  import type { GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
2
2
  import type { GraphqlMiddlewareResponseUnion } from '#nuxt-graphql-middleware/response';
3
- import { type GraphqlMiddlewareServerOptions } from './../../types.js';
3
+ import type { GraphqlMiddlewareServerOptions } from './../types.js';
4
4
  export declare function defineGraphqlServerOptions<T extends object>(options: GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>): GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>;