@lewebsimple/nuxt-graphql 0.1.14 → 0.2.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 (37) hide show
  1. package/README.md +0 -2
  2. package/dist/module.d.mts +1 -2
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +87 -89
  5. package/dist/runtime/{composables → app/composables}/useGraphQLCache.d.ts +1 -1
  6. package/dist/runtime/{composables → app/composables}/useGraphQLMutation.d.ts +1 -1
  7. package/dist/runtime/{composables → app/composables}/useGraphQLQuery.d.ts +1 -1
  8. package/dist/runtime/{composables → app/composables}/useGraphQLSubscription.d.ts +1 -1
  9. package/dist/runtime/app/plugins/graphql.d.ts +31 -0
  10. package/dist/runtime/{plugins → app/plugins}/graphql.js +1 -0
  11. package/dist/runtime/server/api/graphql-handler.d.ts +2 -0
  12. package/dist/{templates/yoga-handler.mjs → runtime/server/api/graphql-handler.js} +3 -22
  13. package/dist/runtime/server/lib/constants.d.ts +1 -0
  14. package/dist/runtime/server/lib/constants.js +1 -0
  15. package/dist/runtime/server/lib/create-yoga.d.ts +1 -0
  16. package/dist/runtime/server/lib/create-yoga.js +17 -0
  17. package/dist/runtime/server/lib/logger.d.ts +2 -0
  18. package/dist/runtime/server/lib/logger.js +2 -0
  19. package/dist/runtime/server/utils/useServerGraphQLMutation.d.ts +1 -1
  20. package/dist/runtime/server/utils/useServerGraphQLQuery.d.ts +1 -1
  21. package/dist/runtime/server/yoga-handler.d.ts +1 -0
  22. package/dist/runtime/server/yoga-handler.js +1 -0
  23. package/package.json +1 -1
  24. package/dist/runtime/plugins/graphql.d.ts +0 -10
  25. package/dist/runtime/types/graphql-client.d.ts +0 -28
  26. package/dist/runtime/utils/helpers.d.ts +0 -1
  27. package/dist/runtime/utils/helpers.js +0 -0
  28. /package/dist/runtime/{composables → app/composables}/useGraphQLCache.js +0 -0
  29. /package/dist/runtime/{composables → app/composables}/useGraphQLMutation.js +0 -0
  30. /package/dist/runtime/{composables → app/composables}/useGraphQLQuery.js +0 -0
  31. /package/dist/runtime/{composables → app/composables}/useGraphQLSubscription.js +0 -0
  32. /package/dist/runtime/{utils → app/utils}/graphql-cache.d.ts +0 -0
  33. /package/dist/runtime/{utils → app/utils}/graphql-cache.js +0 -0
  34. /package/dist/runtime/{utils → app/utils}/graphql-error.d.ts +0 -0
  35. /package/dist/runtime/{utils → app/utils}/graphql-error.js +0 -0
  36. /package/dist/runtime/server/{graphql → lib}/default-context.d.ts +0 -0
  37. /package/dist/runtime/server/{graphql → lib}/default-context.js +0 -0
package/README.md CHANGED
@@ -30,8 +30,6 @@ Optionnally adjust options in your Nuxt config. The defaults shown below:
30
30
  export default defineNuxtConfig({
31
31
  modules: ["@lewebsimple/nuxt-graphql"],
32
32
  graphql: {
33
- // GraphQL HTTP endpoint served by Yoga
34
- endpoint: "/api/graphql",
35
33
  // Codegen controls document scanning and outputs
36
34
  codegen: {
37
35
  enabled: true,
package/dist/module.d.mts CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { GraphQLCacheConfig } from '../dist/runtime/utils/graphql-cache.js';
2
+ import { GraphQLCacheConfig } from '../dist/runtime/app/utils/graphql-cache.js';
3
3
  import { CodegenConfig } from '@graphql-codegen/cli';
4
4
 
5
5
  interface ModuleOptions {
6
- endpoint?: string;
7
6
  headers?: Record<string, string>;
8
7
  cache?: Partial<GraphQLCacheConfig>;
9
8
  codegen?: {
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lewebsimple/nuxt-graphql",
3
3
  "configKey": "graphql",
4
- "version": "0.1.14",
4
+ "version": "0.2.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { useLogger, defineNuxtModule, createResolver, getLayerDirectories, addServerTemplate, addServerHandler, addImportsDir, addServerImportsDir, addPlugin, addTypeTemplate } from '@nuxt/kit';
1
+ import { useLogger, defineNuxtModule, createResolver, getLayerDirectories, addServerHandler, addImportsDir, addServerImportsDir, addPlugin } from '@nuxt/kit';
2
2
  import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { join, dirname, relative } from 'node:path';
4
4
  import { glob } from 'tinyglobby';
5
5
  import { generate } from '@graphql-codegen/cli';
6
6
  import { parse, Kind } from 'graphql';
7
+ import { GRAPHQL_ENDPOINT } from '../dist/runtime/server/lib/constants.js';
7
8
 
8
9
  const logger = useLogger("@lewebsimple/nuxt-graphql");
9
10
  const blue = "\x1B[34m";
@@ -253,7 +254,6 @@ const module$1 = defineNuxtModule({
253
254
  configKey: "graphql"
254
255
  },
255
256
  defaults: {
256
- endpoint: "/api/graphql",
257
257
  codegen: {
258
258
  pattern: "**/*.gql",
259
259
  schemaOutput: "server/graphql/schema.graphql"
@@ -261,11 +261,6 @@ const module$1 = defineNuxtModule({
261
261
  },
262
262
  async setup(options, nuxt) {
263
263
  const { resolve } = createResolver(import.meta.url);
264
- if (options.endpoint) {
265
- if (!options.endpoint.startsWith("/")) {
266
- logger.warn("GraphQL endpoint should start with '/' (e.g., '/api/graphql')");
267
- }
268
- }
269
264
  const { rootDir, serverDir } = nuxt.options;
270
265
  const layerDirs = [
271
266
  ...getLayerDirectories(nuxt),
@@ -275,102 +270,105 @@ const module$1 = defineNuxtModule({
275
270
  const layerRootDirs = layerDirs.map(({ root }) => root);
276
271
  const schemaPath = await findSingleFile(layerServerDirs, "graphql/schema.{ts,mjs}", true);
277
272
  const contextPath = await findSingleFile(layerServerDirs, "graphql/context.{ts,mjs}") || resolve("./runtime/server/graphql/default-context.ts");
278
- nuxt.hook("nitro:config", (config) => {
279
- config.alias ||= {};
280
- config.alias["#graphql/schema"] = schemaPath;
281
- config.alias["#graphql/context"] = contextPath;
282
- });
283
- const endpoint = options.endpoint ?? "/api/graphql";
284
- addServerTemplate({
285
- filename: "graphql/yoga-handler",
286
- getContents: () => readFileSync(resolve("./templates/yoga-handler.mjs"), "utf-8").replace("{{endpoint}}", endpoint)
287
- });
288
- addServerHandler({ route: endpoint, handler: "graphql/yoga-handler" });
289
- nuxt.hook("listen", (_, { url }) => {
290
- logger.success(`GraphQL Yoga ready at ${cyan}${url.replace(/\/$/, "")}${endpoint}${reset}`);
291
- });
292
- nuxt.options.runtimeConfig.public.graphql = {
293
- endpoint,
294
- headers: options.headers || {},
295
- cache: {
296
- enabled: options.cache?.enabled ?? false,
297
- ttl: options.cache?.ttl ?? 6e4,
298
- storage: options.cache?.storage ?? "memory"
299
- }
300
- };
301
273
  const codegenPattern = options.codegen?.pattern ?? "**/*.gql";
302
274
  const graphqlrcFile = join(rootDir, ".graphqlrc");
303
275
  const operationsFile = join(nuxt.options.buildDir, "graphql/operations.ts");
304
276
  const registryFile = join(nuxt.options.buildDir, "graphql/registry.ts");
305
- const schemasFile = join(nuxt.options.buildDir, "graphql/schemas.ts");
306
- nuxt.options.alias["#graphql/operations"] = operationsFile;
307
- nuxt.options.alias["#graphql/registry"] = registryFile;
308
- nuxt.options.alias["#graphql/schemas"] = schemasFile;
277
+ const zodSchemasFile = join(nuxt.options.buildDir, "graphql/zod.ts");
309
278
  const schemaOutput = options.codegen?.schemaOutput ?? "server/graphql/schema.graphql";
310
279
  if (schemaOutput && !schemaOutput.endsWith(".graphql")) {
311
280
  logger.warn(`Schema output '${schemaOutput}' should have .graphql extension.`);
312
281
  }
313
282
  const schemaFile = join(rootDir, schemaOutput);
314
- const generate = async () => {
315
- const [schema, documents] = await Promise.all([
316
- loadGraphQLSchema(schemaPath),
317
- findMultipleFiles(layerRootDirs, codegenPattern)
318
- ]);
319
- const docs = documents.map((document) => ({ path: document, content: readFileSync(document, "utf-8") }));
320
- const analysis = analyzeGraphQLDocuments(docs);
321
- for (const doc of docs) {
322
- const relativePath = doc.path.startsWith(rootDir) ? doc.path.slice(rootDir.length + 1) : doc.path;
323
- const defs = analysis.byFile.get(doc.path) ?? [];
324
- logger.info(`${cyan}${relativePath}${reset} [${formatDefinitions(defs)}]`);
325
- }
326
- await runCodegen({
327
- schema,
328
- documents,
329
- operationsFile,
330
- schemasFile,
331
- scalars: options.codegen?.scalars,
332
- generates: options.codegen?.generates
283
+ const setupAliases = () => {
284
+ nuxt.hook("nitro:config", (config) => {
285
+ config.alias ||= {};
286
+ config.alias["#graphql/schema"] = schemaPath;
287
+ config.alias["#graphql/context"] = contextPath;
333
288
  });
334
- if (writeFileIfChanged(schemaFile, schema)) {
335
- logger.info(`GraphQL schema saved to ${cyan}${schemaOutput}${reset}`);
336
- }
337
- const graphqlrc = {
338
- schema: relative(rootDir, schemaFile),
339
- documents: codegenPattern
289
+ nuxt.options.alias["#graphql/operations"] = operationsFile;
290
+ nuxt.options.alias["#graphql/registry"] = registryFile;
291
+ nuxt.options.alias["#graphql/zod"] = zodSchemasFile;
292
+ };
293
+ const setupHandler = () => {
294
+ addServerHandler({ route: GRAPHQL_ENDPOINT, handler: resolve("./runtime/server/api/graphql-handler") });
295
+ nuxt.hook("listen", (_, { url }) => {
296
+ logger.success(`GraphQL Yoga ready at ${cyan}${url.replace(/\/$/, "")}${GRAPHQL_ENDPOINT}${reset}`);
297
+ });
298
+ };
299
+ const setupRuntimeConfig = () => {
300
+ nuxt.options.runtimeConfig.public.graphql = {
301
+ endpoint: GRAPHQL_ENDPOINT,
302
+ headers: options.headers || {},
303
+ cache: {
304
+ enabled: options.cache?.enabled ?? false,
305
+ ttl: options.cache?.ttl ?? 6e4,
306
+ storage: options.cache?.storage ?? "memory"
307
+ }
340
308
  };
341
- if (options.codegen?.scalars) {
342
- graphqlrc.scalars = options.codegen.scalars;
343
- }
344
- if (writeFileIfChanged(graphqlrcFile, JSON.stringify(graphqlrc, null, 2))) {
345
- logger.info(`GraphQL config saved to ${cyan}.graphqlrc${reset}`);
346
- }
347
- if (writeFileIfChanged(registryFile, generateRegistryByTypeSource(analysis.operationsByType))) {
348
- logger.info(`GraphQL registry saved to ${cyan}${relative(rootDir, registryFile)}${reset}`);
349
- }
350
309
  };
351
- nuxt.hook("prepare:types", async ({ references }) => {
352
- await generate();
353
- if (existsSync(operationsFile)) references.push({ path: operationsFile });
354
- if (existsSync(registryFile)) references.push({ path: registryFile });
355
- if (existsSync(schemasFile)) references.push({ path: schemasFile });
356
- });
357
- if (nuxt.options.dev) {
358
- nuxt.hook("builder:watch", async (event, path) => {
359
- if (path.endsWith(".gql")) {
360
- await generate();
310
+ const setupCodegen = () => {
311
+ const generate = async () => {
312
+ const [schema, documents] = await Promise.all([
313
+ loadGraphQLSchema(schemaPath),
314
+ findMultipleFiles(layerRootDirs, codegenPattern)
315
+ ]);
316
+ const docs = documents.map((document) => ({ path: document, content: readFileSync(document, "utf-8") }));
317
+ const analysis = analyzeGraphQLDocuments(docs);
318
+ for (const doc of docs) {
319
+ const relativePath = doc.path.startsWith(rootDir) ? doc.path.slice(rootDir.length + 1) : doc.path;
320
+ const defs = analysis.byFile.get(doc.path) ?? [];
321
+ logger.info(`${cyan}${relativePath}${reset} [${formatDefinitions(defs)}]`);
322
+ }
323
+ await runCodegen({
324
+ schema,
325
+ documents,
326
+ operationsFile,
327
+ schemasFile: zodSchemasFile,
328
+ scalars: options.codegen?.scalars,
329
+ generates: options.codegen?.generates
330
+ });
331
+ if (writeFileIfChanged(schemaFile, schema)) {
332
+ logger.info(`GraphQL schema saved to ${cyan}${schemaOutput}${reset}`);
333
+ }
334
+ const graphqlrc = {
335
+ schema: relative(rootDir, schemaFile),
336
+ documents: codegenPattern
337
+ };
338
+ if (options.codegen?.scalars) {
339
+ graphqlrc.scalars = options.codegen.scalars;
340
+ }
341
+ if (writeFileIfChanged(graphqlrcFile, JSON.stringify(graphqlrc, null, 2))) {
342
+ logger.info(`GraphQL config saved to ${cyan}.graphqlrc${reset}`);
361
343
  }
344
+ if (writeFileIfChanged(registryFile, generateRegistryByTypeSource(analysis.operationsByType))) {
345
+ logger.info(`GraphQL registry saved to ${cyan}${relative(rootDir, registryFile)}${reset}`);
346
+ }
347
+ };
348
+ nuxt.hook("prepare:types", async ({ references }) => {
349
+ await generate();
350
+ if (existsSync(operationsFile)) references.push({ path: operationsFile });
351
+ if (existsSync(registryFile)) references.push({ path: registryFile });
352
+ if (existsSync(zodSchemasFile)) references.push({ path: zodSchemasFile });
362
353
  });
363
- }
364
- addImportsDir(resolve("./runtime/composables"));
365
- addServerImportsDir(resolve("./runtime/server/utils"));
366
- addPlugin(resolve("./runtime/plugins/graphql"));
367
- addTypeTemplate({
368
- filename: "types/graphql-client.d.ts",
369
- getContents: () => readFileSync(resolve("./runtime/types/graphql-client.d.ts"), "utf-8")
370
- });
371
- nuxt.hook("prepare:types", ({ references }) => {
372
- references.push({ path: "./types/graphql-client.d.ts" });
373
- });
354
+ if (nuxt.options.dev) {
355
+ nuxt.hook("builder:watch", async (event, path) => {
356
+ if (path.endsWith(".gql")) {
357
+ await generate();
358
+ }
359
+ });
360
+ }
361
+ };
362
+ const setupAppRuntime = () => {
363
+ addImportsDir(resolve("./runtime/app/composables"));
364
+ addServerImportsDir(resolve("./runtime/server/utils"));
365
+ addPlugin(resolve("./runtime/app/plugins/graphql"));
366
+ };
367
+ setupAliases();
368
+ setupHandler();
369
+ setupRuntimeConfig();
370
+ setupCodegen();
371
+ setupAppRuntime();
374
372
  }
375
373
  });
376
374
 
@@ -5,6 +5,6 @@ import type { QueryName, QueryVariables } from "#graphql/registry";
5
5
  * @returns Object with enabled flag and invalidate function
6
6
  */
7
7
  export declare function useGraphQLCache(): {
8
- enabled: any;
8
+ enabled: boolean;
9
9
  invalidate: <N extends QueryName>(operationName?: N, variables?: QueryVariables<N>) => Promise<void>;
10
10
  };
@@ -1,5 +1,5 @@
1
1
  import { type MutationName, type MutationResult, type MutationVariables } from "#graphql/registry";
2
- import type { IsEmptyObject } from "../utils/helpers.js";
2
+ import type { IsEmptyObject } from "../../../helpers/is-empty-object.js";
3
3
  /**
4
4
  * Client-side GraphQL mutation composable
5
5
  *
@@ -1,7 +1,7 @@
1
1
  import type { AsyncData, AsyncDataOptions } from "#app";
2
2
  import { type QueryName, type QueryResult, type QueryVariables } from "#graphql/registry";
3
3
  import { type CacheOptions } from "../utils/graphql-cache.js";
4
- import type { IsEmptyObject } from "../utils/helpers.js";
4
+ import type { IsEmptyObject } from "../../../helpers/is-empty-object.js";
5
5
  export interface UseGraphQLQueryOptions<T> extends AsyncDataOptions<T> {
6
6
  cache?: CacheOptions | false;
7
7
  headers?: HeadersInit;
@@ -1,7 +1,7 @@
1
1
  import { type MaybeRefOrGetter, type Ref } from "vue";
2
2
  import { type SubscriptionName, type SubscriptionResult, type SubscriptionVariables } from "#graphql/registry";
3
3
  import { type GraphQLClientError } from "../utils/graphql-error.js";
4
- import type { IsEmptyObject } from "../utils/helpers.js";
4
+ import type { IsEmptyObject } from "../../../helpers/is-empty-object.js";
5
5
  export type UseGraphQLSubscriptionReturn<N extends SubscriptionName> = {
6
6
  data: Ref<SubscriptionResult<N> | null>;
7
7
  error: Ref<GraphQLClientError | null>;
@@ -0,0 +1,31 @@
1
+ import { GraphQLClient } from "graphql-request";
2
+ import { type Client as SSEClient } from "graphql-sse";
3
+ import { type GraphQLClientError } from "../utils/graphql-error.js";
4
+ import type { GraphQLCacheConfig } from "../utils/graphql-cache.js";
5
+ declare const _default: import("#app").Plugin<{
6
+ graphql: () => GraphQLClient;
7
+ graphqlSSE: () => SSEClient;
8
+ }> & import("#app").ObjectPlugin<{
9
+ graphql: () => GraphQLClient;
10
+ graphqlSSE: () => SSEClient;
11
+ }>;
12
+ export default _default;
13
+ declare module "#app" {
14
+ interface NuxtApp {
15
+ $graphql: () => GraphQLClient;
16
+ $graphqlSSE: () => SSEClient;
17
+ }
18
+ interface RuntimeNuxtHooks {
19
+ "graphql:error": (error: GraphQLClientError) => void;
20
+ }
21
+ }
22
+ declare module "nuxt/schema" {
23
+ interface PublicRuntimeConfig {
24
+ graphql: {
25
+ endpoint: string;
26
+ headers: Record<string, string>;
27
+ cache: GraphQLCacheConfig;
28
+ };
29
+ }
30
+ }
31
+ export {};
@@ -39,3 +39,4 @@ export default defineNuxtPlugin((nuxtApp) => {
39
39
  }
40
40
  };
41
41
  });
42
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
2
+ export default _default;
@@ -1,33 +1,14 @@
1
- import { createYoga } from "graphql-yoga";
2
1
  import { defineEventHandler, toWebRequest, sendWebResponse, createError } from "h3";
3
- import { schema } from "#graphql/schema";
2
+ import { logger } from "../lib/logger.js";
3
+ import { getYoga } from "../lib/create-yoga.js";
4
4
  import { createContext } from "#graphql/context";
5
- import { useLogger } from "@nuxt/kit";
6
-
7
- let yoga = null;
8
-
9
- function getYoga() {
10
- if (!yoga) {
11
- yoga = createYoga({
12
- schema,
13
- graphqlEndpoint: "{{endpoint}}",
14
- fetchAPI: globalThis,
15
- graphiql: process.env.NODE_ENV !== "production",
16
- subscriptions: { protocol: "SSE" },
17
- });
18
- }
19
- return yoga;
20
- }
21
-
22
5
  export default defineEventHandler(async (event) => {
23
- const logger = useLogger();
24
6
  try {
25
7
  const request = toWebRequest(event);
26
8
  const context = await createContext(event);
27
9
  const response = await getYoga().handleRequest(request, context);
28
10
  return sendWebResponse(event, response);
29
- }
30
- catch (error) {
11
+ } catch (error) {
31
12
  const message = error instanceof Error ? error.message : String(error);
32
13
  logger.error("GraphQL Server Error:", message);
33
14
  throw createError({ statusCode: 500, message: "GraphQL server error" });
@@ -0,0 +1 @@
1
+ export declare const GRAPHQL_ENDPOINT = "/api/graphql";
@@ -0,0 +1 @@
1
+ export const GRAPHQL_ENDPOINT = "/api/graphql";
@@ -0,0 +1 @@
1
+ export declare function getYoga(): import("graphql-yoga").YogaServerInstance<Record<string, any>, Record<string, any>>;
@@ -0,0 +1,17 @@
1
+ import { createYoga } from "graphql-yoga";
2
+ import { schema } from "#graphql/schema";
3
+ import { GRAPHQL_ENDPOINT } from "./constants.js";
4
+ let yoga = null;
5
+ export function getYoga() {
6
+ if (!yoga) {
7
+ yoga = createYoga({
8
+ schema,
9
+ graphqlEndpoint: GRAPHQL_ENDPOINT,
10
+ fetchAPI: globalThis,
11
+ graphiql: process.env.NODE_ENV !== "production",
12
+ // @ts-expect-error Subscriptions type missing in module context
13
+ subscriptions: { protocol: "SSE" }
14
+ });
15
+ }
16
+ return yoga;
17
+ }
@@ -0,0 +1,2 @@
1
+ import { consola } from "consola";
2
+ export declare const logger: consola.ConsolaInstance;
@@ -0,0 +1,2 @@
1
+ import { consola } from "consola";
2
+ export const logger = consola.withTag("graphql");
@@ -1,6 +1,6 @@
1
1
  import type { H3Event } from "h3";
2
2
  import { type MutationName, type MutationResult, type MutationVariables } from "#graphql/registry";
3
- import type { IsEmptyObject } from "../../utils/helpers.js";
3
+ import type { IsEmptyObject } from "../../../helpers/is-empty-object.js";
4
4
  /**
5
5
  * Server-side GraphQL mutation composable
6
6
  *
@@ -1,6 +1,6 @@
1
1
  import type { H3Event } from "h3";
2
2
  import { type QueryName, type QueryResult, type QueryVariables } from "#graphql/registry";
3
- import type { IsEmptyObject } from "../../utils/helpers.js";
3
+ import type { IsEmptyObject } from "../../../helpers/is-empty-object.js";
4
4
  /**
5
5
  * Server-side GraphQL query composable
6
6
  *
@@ -0,0 +1 @@
1
+ export { default } from "./api/graphql-handler.js";
@@ -0,0 +1 @@
1
+ export { default } from "./api/graphql-handler.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lewebsimple/nuxt-graphql",
3
- "version": "0.1.14",
3
+ "version": "0.2.0",
4
4
  "description": "Opinionated Nuxt module for using GraphQL",
5
5
  "repository": "lewebsimple/nuxt-graphql",
6
6
  "license": "MIT",
@@ -1,10 +0,0 @@
1
- import { GraphQLClient } from "graphql-request";
2
- import { type Client as SSEClient } from "graphql-sse";
3
- declare const _default: import("nuxt/app").Plugin<{
4
- graphql: () => GraphQLClient;
5
- graphqlSSE: () => SSEClient;
6
- }> & import("nuxt/app").ObjectPlugin<{
7
- graphql: () => GraphQLClient;
8
- graphqlSSE: () => SSEClient;
9
- }>;
10
- export default _default;
@@ -1,28 +0,0 @@
1
- import type { GraphQLClient } from "graphql-request";
2
- import type { Client as SSEClient } from "graphql-sse";
3
- import type { GraphQLClientError } from "../utils/graphql-error";
4
-
5
- // Extend NuxtApp with GraphQL clients
6
- declare module "#app" {
7
- interface NuxtApp {
8
- $graphql: () => GraphQLClient;
9
- $graphqlSSE: () => SSEClient;
10
- }
11
-
12
- interface RuntimeNuxtHooks {
13
- "graphql:error": (error: GraphQLClientError) => void;
14
- }
15
- }
16
-
17
- // Extend Nuxt runtime config with GraphQL options
18
- declare module "nuxt/schema" {
19
- interface PublicRuntimeConfig {
20
- graphql: {
21
- endpoint: string;
22
- headers: Record<string, string>;
23
- cache: GraphQLCacheConfig;
24
- };
25
- }
26
- }
27
-
28
- export { };
@@ -1 +0,0 @@
1
- export type IsEmptyObject<T> = T extends Record<string, never> ? true : keyof T extends never ? true : false;
File without changes