@lewebsimple/nuxt-graphql 0.1.13 → 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 +93 -91
  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 +2 -2
  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.13",
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";
@@ -175,7 +176,7 @@ function formatDefinitions(defs) {
175
176
  return defs.map((def) => `${colorOf(def)}${def.name}${reset}`).join(`${dim} / ${reset}`);
176
177
  }
177
178
  async function runCodegen(options) {
178
- const { sdl, documents, operationsFile, schemasFile, scalars, generates: customGenerates } = options;
179
+ const { schema, documents, operationsFile, schemasFile, scalars, generates: customGenerates } = options;
179
180
  if (documents.length === 0) {
180
181
  logger.warn("No GraphQL documents found");
181
182
  return;
@@ -202,6 +203,8 @@ async function runCodegen(options) {
202
203
  try {
203
204
  const generates = {
204
205
  [operationsFile]: {
206
+ schema,
207
+ documents,
205
208
  plugins: ["typescript", "typescript-operations", "typed-document-node"],
206
209
  config: {
207
210
  useTypeImports: true,
@@ -217,6 +220,8 @@ async function runCodegen(options) {
217
220
  };
218
221
  if (schemasFile) {
219
222
  generates[schemasFile] = {
223
+ schema,
224
+ documents,
220
225
  plugins: ["typescript-validation-schema"],
221
226
  config: {
222
227
  schema: "zodv4",
@@ -236,7 +241,7 @@ async function runCodegen(options) {
236
241
  Object.assign(generates, customGenerates);
237
242
  }
238
243
  }
239
- await generate({ schema: sdl, documents, generates, silent: true, errorsOnly: true }, true);
244
+ await generate({ generates, silent: true, errorsOnly: true }, true);
240
245
  logger.success(`Generated types for ${documents.length} document(s)`);
241
246
  } catch (error) {
242
247
  logger.error("GraphQL codegen failed:", error instanceof Error ? error.message : error);
@@ -249,7 +254,6 @@ const module$1 = defineNuxtModule({
249
254
  configKey: "graphql"
250
255
  },
251
256
  defaults: {
252
- endpoint: "/api/graphql",
253
257
  codegen: {
254
258
  pattern: "**/*.gql",
255
259
  schemaOutput: "server/graphql/schema.graphql"
@@ -257,11 +261,6 @@ const module$1 = defineNuxtModule({
257
261
  },
258
262
  async setup(options, nuxt) {
259
263
  const { resolve } = createResolver(import.meta.url);
260
- if (options.endpoint) {
261
- if (!options.endpoint.startsWith("/")) {
262
- logger.warn("GraphQL endpoint should start with '/' (e.g., '/api/graphql')");
263
- }
264
- }
265
264
  const { rootDir, serverDir } = nuxt.options;
266
265
  const layerDirs = [
267
266
  ...getLayerDirectories(nuxt),
@@ -271,102 +270,105 @@ const module$1 = defineNuxtModule({
271
270
  const layerRootDirs = layerDirs.map(({ root }) => root);
272
271
  const schemaPath = await findSingleFile(layerServerDirs, "graphql/schema.{ts,mjs}", true);
273
272
  const contextPath = await findSingleFile(layerServerDirs, "graphql/context.{ts,mjs}") || resolve("./runtime/server/graphql/default-context.ts");
274
- nuxt.hook("nitro:config", (config) => {
275
- config.alias ||= {};
276
- config.alias["#graphql/schema"] = schemaPath;
277
- config.alias["#graphql/context"] = contextPath;
278
- });
279
- const endpoint = options.endpoint ?? "/api/graphql";
280
- addServerTemplate({
281
- filename: "graphql/yoga-handler",
282
- getContents: () => readFileSync(resolve("./templates/yoga-handler.mjs"), "utf-8").replace("{{endpoint}}", endpoint)
283
- });
284
- addServerHandler({ route: endpoint, handler: "graphql/yoga-handler" });
285
- nuxt.hook("listen", (_, { url }) => {
286
- logger.success(`GraphQL Yoga ready at ${cyan}${url.replace(/\/$/, "")}${endpoint}${reset}`);
287
- });
288
- nuxt.options.runtimeConfig.public.graphql = {
289
- endpoint,
290
- headers: options.headers || {},
291
- cache: {
292
- enabled: options.cache?.enabled ?? false,
293
- ttl: options.cache?.ttl ?? 6e4,
294
- storage: options.cache?.storage ?? "memory"
295
- }
296
- };
297
273
  const codegenPattern = options.codegen?.pattern ?? "**/*.gql";
298
274
  const graphqlrcFile = join(rootDir, ".graphqlrc");
299
275
  const operationsFile = join(nuxt.options.buildDir, "graphql/operations.ts");
300
276
  const registryFile = join(nuxt.options.buildDir, "graphql/registry.ts");
301
- const schemasFile = join(nuxt.options.buildDir, "graphql/schemas.ts");
302
- nuxt.options.alias["#graphql/operations"] = operationsFile;
303
- nuxt.options.alias["#graphql/registry"] = registryFile;
304
- nuxt.options.alias["#graphql/schemas"] = schemasFile;
277
+ const zodSchemasFile = join(nuxt.options.buildDir, "graphql/zod.ts");
305
278
  const schemaOutput = options.codegen?.schemaOutput ?? "server/graphql/schema.graphql";
306
279
  if (schemaOutput && !schemaOutput.endsWith(".graphql")) {
307
280
  logger.warn(`Schema output '${schemaOutput}' should have .graphql extension.`);
308
281
  }
309
282
  const schemaFile = join(rootDir, schemaOutput);
310
- const generate = async () => {
311
- const [sdl, documents] = await Promise.all([
312
- loadGraphQLSchema(schemaPath),
313
- findMultipleFiles(layerRootDirs, codegenPattern)
314
- ]);
315
- const docs = documents.map((document) => ({ path: document, content: readFileSync(document, "utf-8") }));
316
- const analysis = analyzeGraphQLDocuments(docs);
317
- for (const doc of docs) {
318
- const relativePath = doc.path.startsWith(rootDir) ? doc.path.slice(rootDir.length + 1) : doc.path;
319
- const defs = analysis.byFile.get(doc.path) ?? [];
320
- logger.info(`${cyan}${relativePath}${reset} [${formatDefinitions(defs)}]`);
321
- }
322
- await runCodegen({
323
- sdl,
324
- documents,
325
- operationsFile,
326
- schemasFile,
327
- scalars: options.codegen?.scalars,
328
- 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;
329
288
  });
330
- if (writeFileIfChanged(schemaFile, sdl)) {
331
- logger.info(`GraphQL schema saved to ${cyan}${schemaOutput}${reset}`);
332
- }
333
- const graphqlrc = {
334
- schema: relative(rootDir, schemaFile),
335
- 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
+ }
336
308
  };
337
- if (options.codegen?.scalars) {
338
- graphqlrc.scalars = options.codegen.scalars;
339
- }
340
- if (writeFileIfChanged(graphqlrcFile, JSON.stringify(graphqlrc, null, 2))) {
341
- logger.info(`GraphQL config saved to ${cyan}.graphqlrc${reset}`);
342
- }
343
- if (writeFileIfChanged(registryFile, generateRegistryByTypeSource(analysis.operationsByType))) {
344
- logger.info(`GraphQL registry saved to ${cyan}${relative(rootDir, registryFile)}${reset}`);
345
- }
346
309
  };
347
- nuxt.hook("prepare:types", async ({ references }) => {
348
- await generate();
349
- if (existsSync(operationsFile)) references.push({ path: operationsFile });
350
- if (existsSync(registryFile)) references.push({ path: registryFile });
351
- if (existsSync(schemasFile)) references.push({ path: schemasFile });
352
- });
353
- if (nuxt.options.dev) {
354
- nuxt.hook("builder:watch", async (event, path) => {
355
- if (path.endsWith(".gql")) {
356
- 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}`);
357
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 });
358
353
  });
359
- }
360
- addImportsDir(resolve("./runtime/composables"));
361
- addServerImportsDir(resolve("./runtime/server/utils"));
362
- addPlugin(resolve("./runtime/plugins/graphql"));
363
- addTypeTemplate({
364
- filename: "types/graphql-client.d.ts",
365
- getContents: () => readFileSync(resolve("./runtime/types/graphql-client.d.ts"), "utf-8")
366
- });
367
- nuxt.hook("prepare:types", ({ references }) => {
368
- references.push({ path: "./types/graphql-client.d.ts" });
369
- });
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();
370
372
  }
371
373
  });
372
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.13",
3
+ "version": "0.2.0",
4
4
  "description": "Opinionated Nuxt module for using GraphQL",
5
5
  "repository": "lewebsimple/nuxt-graphql",
6
6
  "license": "MIT",
@@ -57,7 +57,7 @@
57
57
  "@nuxt/eslint-config": "^1.12.1",
58
58
  "@nuxt/module-builder": "^1.0.2",
59
59
  "@nuxt/schema": "^4.2.2",
60
- "@nuxt/test-utils": "^3.21.0",
60
+ "@nuxt/test-utils": "^3.22.0",
61
61
  "@types/node": "latest",
62
62
  "@vitest/coverage-v8": "^4.0.16",
63
63
  "changelogen": "^0.6.2",
@@ -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