nuxt-graphql-middleware 4.3.2 → 5.0.0-alpha.1
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/dist/module.d.mts +3 -29
- package/dist/module.d.ts +3 -29
- package/dist/module.json +1 -1
- package/dist/module.mjs +456 -716
- package/dist/runtime/composables/useAsyncGraphqlQuery.d.ts +25 -9
- package/dist/runtime/serverHandler/debug.js +2 -2
- package/dist/runtime/serverHandler/helpers/index.d.ts +2 -2
- package/dist/runtime/serverHandler/index.js +3 -3
- package/dist/runtime/serverHandler/upload.js +3 -3
- package/dist/runtime/settings/index.d.ts +2 -2
- package/dist/runtime/settings/index.js +2 -2
- package/dist/runtime/types.d.ts +5 -0
- package/package.json +11 -8
- package/dist/client/200.html +0 -11
- package/dist/client/404.html +0 -11
- package/dist/client/_nuxt/B4FhP7a6.js +0 -1
- package/dist/client/_nuxt/CH4m2wxh.js +0 -25
- package/dist/client/_nuxt/CPd6XBwJ.js +0 -1
- package/dist/client/_nuxt/GKcsigNx.js +0 -1
- package/dist/client/_nuxt/VR7nYXIq.js +0 -2
- package/dist/client/_nuxt/builds/latest.json +0 -1
- package/dist/client/_nuxt/builds/meta/681c6bf3-56ef-4ca6-8973-d750fea9d239.json +0 -1
- package/dist/client/_nuxt/entry.D9ltLgme.css +0 -1
- package/dist/client/_nuxt/error-404.SWzu_puR.css +0 -1
- package/dist/client/_nuxt/error-500.Bkv_zTjr.css +0 -1
- package/dist/client/_nuxt/index.D19Q16VT.css +0 -1
- package/dist/client/index.html +0 -11
|
@@ -6,19 +6,35 @@ import type { GraphqlMiddlewareQuery } from '#nuxt-graphql-middleware/generated-
|
|
|
6
6
|
import type { GraphqlResponse } from '#graphql-middleware-server-options-build';
|
|
7
7
|
import type { RequestCacheOptions } from '#graphql-middleware/types';
|
|
8
8
|
import type { AsyncData, AsyncDataOptions, NuxtError } from '#app';
|
|
9
|
-
type
|
|
9
|
+
import type { DefaultAsyncDataValue } from 'nuxt/app/defaults';
|
|
10
|
+
type AsyncGraphqlQueryOptions<FetchOptions, ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DefaultAsyncDataValue> = AsyncDataOptions<ResT, DataT, PickKeys, DefaultT> & {
|
|
11
|
+
/**
|
|
12
|
+
* Control how the GraphQL response can be cached.
|
|
13
|
+
*/
|
|
10
14
|
graphqlCaching?: RequestCacheOptions;
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Options for the fetch call to the GraphQL middleware endpoint.
|
|
17
|
+
*/
|
|
18
|
+
fetchOptions?: FetchOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Additional client context.
|
|
21
|
+
*
|
|
22
|
+
* These values override the values defined globally in defineGraphqlClientOptions().
|
|
23
|
+
*/
|
|
12
24
|
clientContext?: Partial<GraphqlClientContext>;
|
|
13
25
|
};
|
|
14
|
-
|
|
15
|
-
* Wrapper for useAsyncData to perform a single GraphQL query.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useAsyncGraphqlQuery<Name extends GraphqlMiddlewareQueryName, VarType extends GraphqlMiddlewareQuery[Name][0], VarsOptional extends GraphqlMiddlewareQuery[Name][1], ResponseType extends GraphqlResponse<GraphqlMiddlewareQuery[Name][2]>, F extends FetchOptions<'json'>, DefaultT = ResponseType, Keys extends KeysOf<DefaultT> = KeysOf<DefaultT>>(name: Name, ...args: VarsOptional extends true ? [
|
|
26
|
+
export declare function useAsyncGraphqlQuery<Name extends GraphqlMiddlewareQueryName, VarType extends GraphqlMiddlewareQuery[Name][0], VarsOptional extends GraphqlMiddlewareQuery[Name][1], ResT extends GraphqlResponse<GraphqlMiddlewareQuery[Name][2]>, FetchO extends FetchOptions<'json'>, NuxtErrorDataT = unknown, DataT = ResT, DefaultT = undefined, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: VarsOptional extends true ? [
|
|
18
27
|
(undefined | null | Record<string, never> | VarType | Ref<VarType>)?,
|
|
19
|
-
AsyncGraphqlQueryOptions<
|
|
28
|
+
AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>?
|
|
20
29
|
] : [
|
|
21
30
|
VarType | Ref<VarType>,
|
|
22
|
-
(undefined | null | AsyncGraphqlQueryOptions<
|
|
23
|
-
]): AsyncData<PickFrom<
|
|
31
|
+
(undefined | null | AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>)?
|
|
32
|
+
]): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
|
|
33
|
+
export declare function useAsyncGraphqlQuery<Name extends GraphqlMiddlewareQueryName, VarType extends GraphqlMiddlewareQuery[Name][0], VarsOptional extends GraphqlMiddlewareQuery[Name][1], ResT extends GraphqlResponse<GraphqlMiddlewareQuery[Name][2]>, FetchO extends FetchOptions<'json'>, NuxtErrorDataT = unknown, DataT = ResT, DefaultT = DataT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>>(name: Name, ...args: VarsOptional extends true ? [
|
|
34
|
+
(undefined | null | Record<string, never> | VarType | Ref<VarType>)?,
|
|
35
|
+
AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>?
|
|
36
|
+
] : [
|
|
37
|
+
VarType | Ref<VarType>,
|
|
38
|
+
(undefined | null | AsyncGraphqlQueryOptions<FetchO, ResT, DataT, PickKeys, DefaultT>)?
|
|
39
|
+
]): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
|
|
24
40
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from "h3";
|
|
2
|
-
import {
|
|
2
|
+
import { operations } from "#graphql-documents";
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
4
|
export default defineEventHandler(() => {
|
|
5
5
|
function getEndpoint(operation, operationName) {
|
|
@@ -8,7 +8,7 @@ export default defineEventHandler(() => {
|
|
|
8
8
|
}
|
|
9
9
|
let body = "<h1>nuxt-graphql-middleware debug</h1>";
|
|
10
10
|
body += "<table><tbody>";
|
|
11
|
-
Object.entries(
|
|
11
|
+
Object.entries(operations).forEach(([operationType, items]) => {
|
|
12
12
|
Object.entries(items).forEach(([operationName, operation]) => {
|
|
13
13
|
body += "<tr>";
|
|
14
14
|
body += `<td style="font-size: 1.5rem">${operationType}</td>`;
|
|
@@ -3,7 +3,7 @@ import type { H3Event } from 'h3';
|
|
|
3
3
|
import type { FetchOptions, FetchResponse, FetchError } from 'ofetch';
|
|
4
4
|
import type { GraphqlMiddlewareRequestContext, GraphqlMiddlewareRuntimeConfig, GraphqlMiddlewareServerOptions } from './../../../types.js';
|
|
5
5
|
import { GraphqlMiddlewareOperation } from './../../settings/index.js';
|
|
6
|
-
import { type
|
|
6
|
+
import { type Operations } from '#graphql-documents';
|
|
7
7
|
export declare function queryParamToVariables(query: QueryObject): any;
|
|
8
8
|
/**
|
|
9
9
|
* Extract the client context from the query params.
|
|
@@ -21,7 +21,7 @@ export declare function throwError(statusMessage: string, statusCode?: number):
|
|
|
21
21
|
/**
|
|
22
22
|
* Assure that the request is valid.
|
|
23
23
|
*/
|
|
24
|
-
export declare function validateRequest(method?: string, operation?: GraphqlMiddlewareOperation | string, name?: string, documents?:
|
|
24
|
+
export declare function validateRequest(method?: string, operation?: GraphqlMiddlewareOperation | string, name?: string, documents?: Operations): void;
|
|
25
25
|
/**
|
|
26
26
|
* Handle GraphQL server response.
|
|
27
27
|
*/
|
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
extractRequestContext
|
|
10
10
|
} from "./helpers/index.js";
|
|
11
11
|
import { GraphqlMiddlewareOperation } from "./../settings/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { operations } from "#graphql-documents";
|
|
13
13
|
import { serverOptions } from "#graphql-middleware-server-options-build";
|
|
14
14
|
import { useRuntimeConfig } from "#imports";
|
|
15
15
|
export default defineEventHandler(async (event) => {
|
|
16
16
|
const method = event.method;
|
|
17
17
|
const operation = event.context?.params?.operation;
|
|
18
18
|
const operationName = event.context?.params?.name;
|
|
19
|
-
validateRequest(method, operation, operationName,
|
|
20
|
-
const operationDocument =
|
|
19
|
+
validateRequest(method, operation, operationName, operations);
|
|
20
|
+
const operationDocument = operations[operation][operationName];
|
|
21
21
|
const queryParams = getQuery(event);
|
|
22
22
|
const context = extractRequestContext(queryParams);
|
|
23
23
|
const variables = operation === GraphqlMiddlewareOperation.Query ? queryParamToVariables(queryParams) : await readBody(event);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
extractRequestContext
|
|
14
14
|
} from "./helpers/index.js";
|
|
15
15
|
import { GraphqlMiddlewareOperation } from "./../settings/index.js";
|
|
16
|
-
import {
|
|
16
|
+
import { operations } from "#graphql-documents";
|
|
17
17
|
import { serverOptions } from "#graphql-middleware-server-options-build";
|
|
18
18
|
import { useRuntimeConfig } from "#imports";
|
|
19
19
|
function parseMultipart(data) {
|
|
@@ -30,8 +30,8 @@ export default defineEventHandler(async (event) => {
|
|
|
30
30
|
const method = event.method;
|
|
31
31
|
const operation = GraphqlMiddlewareOperation.Mutation;
|
|
32
32
|
const operationName = event.context?.params?.name;
|
|
33
|
-
validateRequest(method, operation, operationName,
|
|
34
|
-
const operationDocument =
|
|
33
|
+
validateRequest(method, operation, operationName, operations);
|
|
34
|
+
const operationDocument = operations[operation][operationName];
|
|
35
35
|
const multiPartData = await readMultipartFormData(event);
|
|
36
36
|
if (!multiPartData) {
|
|
37
37
|
return throwError("Failed to read multi part data.");
|
|
@@ -2,7 +2,7 @@ export declare enum GraphqlMiddlewareTemplate {
|
|
|
2
2
|
/**
|
|
3
3
|
* Contains the TS definitions for all GraphQL queries, mutations and fragments.
|
|
4
4
|
*/
|
|
5
|
-
OperationTypes = "graphql-operations.
|
|
5
|
+
OperationTypes = "graphql-operations.ts",
|
|
6
6
|
/**
|
|
7
7
|
* Signature for the GraphQL composable arguments and return types.
|
|
8
8
|
*/
|
|
@@ -10,7 +10,7 @@ export declare enum GraphqlMiddlewareTemplate {
|
|
|
10
10
|
/**
|
|
11
11
|
* Exports a single opject containing the compiled queries and mutations.
|
|
12
12
|
*/
|
|
13
|
-
Documents = "graphql-documents.mjs"
|
|
13
|
+
Documents = "nuxt-graphql-middleware/graphql-documents.mjs"
|
|
14
14
|
}
|
|
15
15
|
export declare enum GraphqlMiddlewareOperation {
|
|
16
16
|
Query = "query",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var GraphqlMiddlewareTemplate = /* @__PURE__ */ ((GraphqlMiddlewareTemplate2) => {
|
|
2
|
-
GraphqlMiddlewareTemplate2["OperationTypes"] = "graphql-operations.
|
|
2
|
+
GraphqlMiddlewareTemplate2["OperationTypes"] = "graphql-operations.ts";
|
|
3
3
|
GraphqlMiddlewareTemplate2["ComposableContext"] = "nuxt-graphql-middleware/generated-types.d.ts";
|
|
4
|
-
GraphqlMiddlewareTemplate2["Documents"] = "graphql-documents.mjs";
|
|
4
|
+
GraphqlMiddlewareTemplate2["Documents"] = "nuxt-graphql-middleware/graphql-documents.mjs";
|
|
5
5
|
return GraphqlMiddlewareTemplate2;
|
|
6
6
|
})(GraphqlMiddlewareTemplate || {});
|
|
7
7
|
export var GraphqlMiddlewareOperation = /* @__PURE__ */ ((GraphqlMiddlewareOperation2) => {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface GraphqlMiddlewareState {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export type RequestCacheOptions = {
|
|
23
|
+
/**
|
|
24
|
+
* Allow caching on the client.
|
|
25
|
+
*
|
|
26
|
+
* Caching is only enabled when `clientCache.enabled` is set to `true` in the module options.
|
|
27
|
+
*/
|
|
23
28
|
client?: boolean;
|
|
24
29
|
};
|
|
25
30
|
export type ContextType = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.1",
|
|
4
4
|
"description": "Module to perform GraphQL requests as a server middleware.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"prepack": "nuxt-module-build build
|
|
38
|
+
"prepack": "nuxt-module-build build",
|
|
39
|
+
"prepack_": "nuxt-module-build build && npm run client:build",
|
|
39
40
|
"dev": "nuxi dev playground --trace-warnings",
|
|
40
41
|
"dev:layers": "nuxi dev playground-layers --trace-warnings",
|
|
41
42
|
"debug": "nuxi dev playground --inspect",
|
|
@@ -62,14 +63,15 @@
|
|
|
62
63
|
"prettier:fix": "prettier --write ."
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@graphql-codegen/cli": "^5.0.
|
|
66
|
+
"@graphql-codegen/cli": "^5.0.5",
|
|
66
67
|
"@graphql-codegen/schema-ast": "^4.1.0",
|
|
67
|
-
"@graphql-codegen/typescript": "^4.
|
|
68
|
+
"@graphql-codegen/typescript": "^4.1.3",
|
|
68
69
|
"@graphql-codegen/typescript-generic-sdk": "^4.0.1",
|
|
69
|
-
"@graphql-codegen/typescript-operations": "^4.
|
|
70
|
+
"@graphql-codegen/typescript-operations": "^4.4.1",
|
|
70
71
|
"@graphql-tools/utils": "^10.2.2",
|
|
71
72
|
"@nuxt/devtools-kit": "1.3.7",
|
|
72
|
-
"
|
|
73
|
+
"dependency-graph": "^1.0.0",
|
|
74
|
+
"graphql-typescript-deluxe": "^0.0.1",
|
|
73
75
|
"inquirer": "^9.3.2",
|
|
74
76
|
"minisearch": "^6.3.0",
|
|
75
77
|
"picocolors": "^1.0.1"
|
|
@@ -79,8 +81,9 @@
|
|
|
79
81
|
"@nuxt/devtools": "^1.3.7",
|
|
80
82
|
"@nuxt/devtools-ui-kit": "1.3.7",
|
|
81
83
|
"@nuxt/eslint": "^0.3.13",
|
|
84
|
+
"@nuxt/kit": "^3.15.4",
|
|
82
85
|
"@nuxt/module-builder": "^0.8.4",
|
|
83
|
-
"@nuxt/schema": "^3.
|
|
86
|
+
"@nuxt/schema": "^3.15.4",
|
|
84
87
|
"@types/capture-console": "^1.0.5",
|
|
85
88
|
"@types/cli-table": "^0.3.4",
|
|
86
89
|
"@types/inquirer": "^9.0.7",
|
|
@@ -89,7 +92,7 @@
|
|
|
89
92
|
"eslint-config-prettier": "^9.1.0",
|
|
90
93
|
"eslint-plugin-prettier": "^5.1.3",
|
|
91
94
|
"jsdoc-to-markdown": "^8.0.1",
|
|
92
|
-
"nuxt": "^3.
|
|
95
|
+
"nuxt": "^3.15.4",
|
|
93
96
|
"prettier": "^3.3.2",
|
|
94
97
|
"strip-ansi": "^7.1.0",
|
|
95
98
|
"typedoc": "^0.26.3",
|
package/dist/client/200.html
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
-
<link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.D9ltLgme.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CH4m2wxh.js">
|
|
5
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-404.SWzu_puR.css">
|
|
6
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/GKcsigNx.js">
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/B4FhP7a6.js">
|
|
8
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-500.Bkv_zTjr.css">
|
|
9
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CPd6XBwJ.js">
|
|
10
|
-
<script type="module" src="/__nuxt-graphql-middleware/_nuxt/CH4m2wxh.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},1734444332573,false]</script>
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"681c6bf3-56ef-4ca6-8973-d750fea9d239",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
-
<link rel="stylesheet" href="/__nuxt-graphql-middleware/_nuxt/entry.D9ltLgme.css">
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CH4m2wxh.js">
|
|
5
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-404.SWzu_puR.css">
|
|
6
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/GKcsigNx.js">
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/B4FhP7a6.js">
|
|
8
|
-
<link rel="prefetch" as="style" crossorigin href="/__nuxt-graphql-middleware/_nuxt/error-500.Bkv_zTjr.css">
|
|
9
|
-
<link rel="prefetch" as="script" crossorigin href="/__nuxt-graphql-middleware/_nuxt/CPd6XBwJ.js">
|
|
10
|
-
<script type="module" src="/__nuxt-graphql-middleware/_nuxt/CH4m2wxh.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},1734444332573,false]</script>
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-graphql-middleware",buildId:"681c6bf3-56ef-4ca6-8973-d750fea9d239",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as o,r as u,D as f,E as d,e as v,F as l,G as i,H as h,I as m}from"./CH4m2wxh.js";function U(t,a={}){const e=a.head||o();if(e)return e.ssr?e.push(t,a):p(e,t,a)}function p(t,a,e={}){const s=u(!1),n=u({});f(()=>{n.value=s.value?{}:h(a)});const r=t.push(n.value,e);return d(n,c=>{r.patch(c)}),m()&&(v(()=>{r.dispose()}),l(()=>{s.value=!0}),i(()=>{s.value=!1})),r}export{U as u};
|