@lewebsimple/nuxt-graphql 0.5.0 → 0.5.2

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.
package/README.md CHANGED
@@ -93,13 +93,12 @@ export default defineNuxtConfig({
93
93
 
94
94
  ### Define schema(s) (local and/or remote)
95
95
 
96
- **Local schemas** must live under `server/` and export a `GraphQLSchema` as `schema`. You can use the provided `defineGraphQLSchema` helper for type-safety.
96
+ **Local schemas** must live under `server/` and export a `GraphQLSchema` as `schema`. You can use the auto-imported `defineGraphQLSchema` helper for type-safety.
97
97
 
98
98
  For the example configuration above, create [server/graphql/schema.ts](server/graphql/schema.ts):
99
99
 
100
100
  ```ts
101
101
  import { createSchema } from "graphql-yoga";
102
- import { defineGraphQLSchema } from "@lewebsimple/nuxt-graphql";
103
102
  import type { GraphQLContext } from "#graphql/context";
104
103
 
105
104
  const schema = createSchema<GraphQLContext>({
@@ -142,12 +141,11 @@ export default defineGraphQLSchema({ schema });
142
141
 
143
142
  ### Define GraphQL context factories (optional)
144
143
 
145
- Context factories are optional and run on the server in order. Their return types are merged into a single `GraphQLContext` type.
144
+ Context factories are optional and run on the server in order. Their return types are merged into a single `GraphQLContext` type. You can use the auto-imported `defineGraphQLContext` helper for type-safety.
146
145
 
147
146
  For example, create [server/graphql/context.ts](server/graphql/context.ts):
148
147
 
149
148
  ```ts
150
- import { defineGraphQLContext } from "@lewebsimple/nuxt-graphql";
151
149
  import { getUserSession } from "nuxt-auth-utils";
152
150
 
153
151
  export default defineGraphQLContext(async (event) => {
@@ -334,13 +332,11 @@ await invalidate();
334
332
 
335
333
  ### Remote executor hooks (optional, per remote)
336
334
 
337
- You can define custom logic around the remote executor for each remote schema by using the provided `defineRemoteExecutorHooks` helper.
335
+ You can define custom logic around the remote executor for each remote schema by using the auto-imported `defineRemoteExecutorHooks` helper.
338
336
 
339
337
  For the example configuration above, create [server/graphql/swapi-hooks.ts](server/graphql/swapi-hooks.ts):
340
338
 
341
339
  ```ts
342
- import { defineRemoteExecutorHooks } from "@lewebsimple/nuxt-graphql";
343
-
344
340
  export default defineRemoteExecutorHooks({
345
341
  onRequest(request) {
346
342
  // Dynamically inject headers
package/dist/module.d.mts CHANGED
@@ -1,8 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HeadersInput } from '../dist/runtime/shared/lib/headers.js';
3
3
  import { CacheConfig } from '../dist/runtime/shared/lib/cache-config.js';
4
- export { defineGraphQLContext } from '../dist/runtime/server/lib/context.js';
5
- export { defineRemoteExecutorHooks } from '../dist/runtime/server/lib/remote-executor.js';
6
4
 
7
5
  interface LocalSchemaDef {
8
6
  type: "local";
@@ -82,7 +80,6 @@ interface NuxtGraphQLModuleOptions {
82
80
  schemas?: Record<string, SchemaDef>;
83
81
  };
84
82
  }
85
-
86
83
  declare const _default: _nuxt_schema.NuxtModule<NuxtGraphQLModuleOptions, NuxtGraphQLModuleOptions, false>;
87
84
 
88
85
  export { _default as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-graphql",
3
3
  "configKey": "graphql",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -12,8 +12,6 @@ import * as typedDocumentNodePlugin from '@graphql-codegen/typed-document-node';
12
12
  import { mergeHeaders } from '../dist/runtime/shared/lib/headers.js';
13
13
  import { stitchSchemas } from '@graphql-tools/stitch';
14
14
  import { resolveCacheConfig } from '../dist/runtime/shared/lib/cache-config.js';
15
- export { defineGraphQLContext } from '../dist/runtime/server/lib/context.js';
16
- export { defineRemoteExecutorHooks } from '../dist/runtime/server/lib/remote-executor.js';
17
15
 
18
16
  const cyan = "\x1B[36m";
19
17
  const reset = "\x1B[0m";
@@ -58,7 +56,7 @@ async function renderFragmentsTemplate({ documents }) {
58
56
  }
59
57
  return [
60
58
  `export type {`,
61
- ...fragments.map((name) => ` ${name},`),
59
+ ...fragments.map((name) => ` ${name} as ${name}Fragment,`),
62
60
  `} from "./operations";`
63
61
  ].join("\n");
64
62
  }
@@ -1,2 +1,2 @@
1
- import { defineGraphQLContext } from "./context.js";
1
+ import { defineGraphQLContext } from "../utils/defineGraphQLContext.js";
2
2
  export default defineGraphQLContext(() => ({}));
@@ -1,5 +1,5 @@
1
1
  import { createSchema } from "graphql-yoga";
2
- import { defineGraphQLSchema } from "./schemas.js";
2
+ import { defineGraphQLSchema } from "../utils/defineGraphQLSchema.js";
3
3
  const schema = createSchema({
4
4
  typeDefs: (
5
5
  /* GraphQL */
@@ -1,17 +1,6 @@
1
- import type { ExecutionRequest, ExecutionResult, Executor } from "@graphql-tools/utils";
1
+ import type { Executor } from "@graphql-tools/utils";
2
2
  import { type HeadersInput } from "../../shared/lib/headers.js";
3
- export interface GraphQLRemoteExecHooks {
4
- onRequest?: (request: ExecutionRequest) => void | Promise<void>;
5
- onResult?: (result: ExecutionResult) => void | Promise<void>;
6
- onError?: (error: unknown) => void | Promise<void>;
7
- }
8
- /**
9
- * Define remote executor hooks with proper typing.
10
- *
11
- * @param hooks Hooks implementation.
12
- * @returns The same hooks object.
13
- */
14
- export declare function defineRemoteExecutorHooks(hooks: GraphQLRemoteExecHooks): GraphQLRemoteExecHooks;
3
+ import type { GraphQLRemoteExecHooks } from "../utils/defineRemoteExecutorHooks.js";
15
4
  type CreateRemoteExecutorInput = {
16
5
  url: string;
17
6
  headers?: HeadersInput;
@@ -1,8 +1,5 @@
1
1
  import { buildHTTPExecutor } from "@graphql-tools/executor-http";
2
2
  import { mergeHeaders } from "../../shared/lib/headers.js";
3
- export function defineRemoteExecutorHooks(hooks) {
4
- return hooks;
5
- }
6
3
  export function createRemoteExecutor({ url, headers, hooks }) {
7
4
  function getHeaders(request) {
8
5
  const extHeaders = request?.extensions?.headers || {};
@@ -0,0 +1,13 @@
1
+ import type { ExecutionRequest, ExecutionResult } from "@graphql-tools/utils";
2
+ export interface GraphQLRemoteExecHooks {
3
+ onRequest?: (request: ExecutionRequest) => void | Promise<void>;
4
+ onResult?: (result: ExecutionResult) => void | Promise<void>;
5
+ onError?: (error: unknown) => void | Promise<void>;
6
+ }
7
+ /**
8
+ * Define remote executor hooks with proper typing.
9
+ *
10
+ * @param hooks Hooks implementation.
11
+ * @returns The same hooks object.
12
+ */
13
+ export declare function defineRemoteExecutorHooks(hooks: GraphQLRemoteExecHooks): GraphQLRemoteExecHooks;
@@ -0,0 +1,3 @@
1
+ export function defineRemoteExecutorHooks(hooks) {
2
+ return hooks;
3
+ }
package/dist/types.d.mts CHANGED
@@ -4,10 +4,6 @@ import type { default as Module } from './module.mjs'
4
4
 
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
- export { type defineGraphQLContext } from '../dist/runtime/server/lib/context.js'
8
-
9
- export { type defineRemoteExecutorHooks } from '../dist/runtime/server/lib/remote-executor.js'
10
-
11
7
  export { default } from './module.mjs'
12
8
 
13
9
  export { type NuxtGraphQLModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lewebsimple/nuxt-graphql",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Opinionated Nuxt module for using GraphQL",
5
5
  "repository": "lewebsimple/nuxt-graphql",
6
6
  "license": "AGPL-3.0-only",