nuxt-graphql-middleware 5.0.0-alpha.4 → 5.0.0-alpha.6
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/client/200.html +7 -7
- package/dist/client/404.html +7 -7
- package/dist/client/_nuxt/{CZ2Qwgdk.js → B4KMzhZo.js} +1 -1
- package/dist/client/_nuxt/BawWjxPx.js +25 -0
- package/dist/client/_nuxt/BtHrwWER.js +1 -0
- package/dist/client/_nuxt/BvMfLM9s.js +1 -0
- package/dist/client/_nuxt/{GOrnHr4p.js → DkAo05uu.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/9b9c571e-ce30-465b-8174-06afbdca446b.json +1 -0
- package/dist/client/index.html +7 -7
- package/dist/module.d.mts +199 -159
- package/dist/module.d.ts +199 -159
- package/dist/module.json +2 -2
- package/dist/module.mjs +938 -591
- package/dist/runtime/components/CodeFrame.vue +61 -0
- package/dist/runtime/components/DevModeOverlay.vue +60 -0
- package/dist/runtime/components/ErrorExtensions.vue +23 -0
- package/dist/runtime/components/ErrorGroup.vue +89 -0
- package/dist/runtime/composables/nuxtApp.d.ts +2 -2
- package/dist/runtime/composables/nuxtApp.js +19 -18
- package/dist/runtime/composables/useAsyncGraphqlQuery.d.ts +7 -7
- package/dist/runtime/composables/useAsyncGraphqlQuery.js +10 -2
- package/dist/runtime/composables/useGraphqlMutation.d.ts +4 -4
- package/dist/runtime/composables/useGraphqlMutation.js +1 -1
- package/dist/runtime/composables/useGraphqlQuery.d.ts +4 -4
- package/dist/runtime/composables/useGraphqlQuery.js +1 -1
- package/dist/runtime/composables/useGraphqlState.d.ts +1 -1
- package/dist/runtime/composables/useGraphqlUploadMutation.d.ts +4 -4
- package/dist/runtime/composables/useGraphqlUploadMutation.js +2 -2
- package/dist/runtime/css/output.css +1 -0
- package/dist/runtime/helpers/composables.d.ts +17 -20
- package/dist/runtime/helpers/composables.js +0 -5
- package/dist/runtime/plugins/devMode.d.ts +2 -0
- package/dist/runtime/plugins/devMode.js +23 -0
- package/dist/runtime/plugins/provideState.d.ts +1 -1
- package/dist/runtime/{serverHandler → server/api}/debug.js +3 -7
- package/dist/runtime/server/api/mutation.js +28 -0
- package/dist/runtime/server/api/query.js +29 -0
- package/dist/runtime/server/api/upload.d.ts +2 -0
- package/dist/runtime/{serverHandler → server/api}/upload.js +13 -11
- package/dist/runtime/{serverHandler → server}/helpers/index.d.ts +8 -10
- package/dist/runtime/{serverHandler → server}/helpers/index.js +8 -25
- package/dist/runtime/server/utils/doGraphqlRequest.d.ts +18 -0
- package/dist/runtime/server/utils/doGraphqlRequest.js +67 -0
- package/dist/runtime/server/utils/index.d.ts +1 -1
- package/dist/runtime/server/utils/index.js +1 -1
- package/dist/runtime/server/utils/useGraphqlMutation.d.ts +4 -4
- package/dist/runtime/server/utils/useGraphqlQuery.d.ts +4 -4
- package/dist/runtime/serverOptions/defineGraphqlServerOptions.d.ts +3 -2
- package/dist/runtime/settings/index.d.ts +49 -4
- package/dist/runtime/settings/index.js +19 -7
- package/dist/runtime/types.d.ts +8 -2
- package/package.json +21 -9
- package/dist/client/_nuxt/BS583yk8.js +0 -25
- package/dist/client/_nuxt/DpxjPVZy.js +0 -1
- package/dist/client/_nuxt/builds/meta/106a09af-649a-473b-b0c7-0e4ce5709429.json +0 -1
- package/dist/client/_nuxt/exxdaCPN.js +0 -1
- package/dist/runtime/serverHandler/index.js +0 -78
- package/dist/runtime/serverHandler/tsconfig.json +0 -3
- /package/dist/runtime/{serverHandler → server/api}/debug.d.ts +0 -0
- /package/dist/runtime/{serverHandler/index.d.ts → server/api/mutation.d.ts} +0 -0
- /package/dist/runtime/{serverHandler/upload.d.ts → server/api/query.d.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
2
|
+
import {
|
|
3
|
+
queryParamToVariables,
|
|
4
|
+
extractRequestContext,
|
|
5
|
+
isValidQuery,
|
|
6
|
+
throwError
|
|
7
|
+
} from "./../helpers/index.js";
|
|
8
|
+
import { GraphqlMiddlewareOperation } from "./../../settings/index.js";
|
|
9
|
+
import { documents } from "#nuxt-graphql-middleware/documents";
|
|
10
|
+
import { doGraphqlRequest } from "../utils/doGraphqlRequest.js";
|
|
11
|
+
export default defineEventHandler(async (event) => {
|
|
12
|
+
const operationName = getRouterParam(event, "name");
|
|
13
|
+
if (!isValidQuery(operationName)) {
|
|
14
|
+
return throwError("Invalid query name.");
|
|
15
|
+
}
|
|
16
|
+
const operationDocument = documents.query[operationName];
|
|
17
|
+
const queryParams = getQuery(event);
|
|
18
|
+
const context = extractRequestContext(queryParams);
|
|
19
|
+
const variables = queryParamToVariables(queryParams);
|
|
20
|
+
return doGraphqlRequest(
|
|
21
|
+
{
|
|
22
|
+
query: operationDocument,
|
|
23
|
+
variables,
|
|
24
|
+
operation: GraphqlMiddlewareOperation.Query
|
|
25
|
+
},
|
|
26
|
+
context,
|
|
27
|
+
event
|
|
28
|
+
);
|
|
29
|
+
});
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineEventHandler,
|
|
3
3
|
readMultipartFormData,
|
|
4
|
-
getQuery
|
|
4
|
+
getQuery,
|
|
5
|
+
getRouterParam
|
|
5
6
|
} from "h3";
|
|
6
7
|
import {
|
|
7
8
|
getEndpoint,
|
|
8
9
|
getFetchOptions,
|
|
9
|
-
validateRequest,
|
|
10
10
|
onServerResponse,
|
|
11
11
|
onServerError,
|
|
12
12
|
throwError,
|
|
13
|
-
extractRequestContext
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
import { serverOptions } from "#graphql-middleware
|
|
13
|
+
extractRequestContext,
|
|
14
|
+
isValidMutation
|
|
15
|
+
} from "./../helpers/index.js";
|
|
16
|
+
import { documents } from "#nuxt-graphql-middleware/documents";
|
|
17
|
+
import { serverOptions } from "#nuxt-graphql-middleware/server-options";
|
|
18
18
|
import { useRuntimeConfig } from "#imports";
|
|
19
|
+
import { GraphqlMiddlewareOperation } from "../../settings/index.js";
|
|
19
20
|
function parseMultipart(data) {
|
|
20
21
|
const files = data.filter((v) => !!v.filename);
|
|
21
22
|
const variablesData = data.find((v) => v.name === "variables")?.data?.toString();
|
|
@@ -27,11 +28,12 @@ function parseMultipart(data) {
|
|
|
27
28
|
return { files, map, variables };
|
|
28
29
|
}
|
|
29
30
|
export default defineEventHandler(async (event) => {
|
|
30
|
-
const method = event.method;
|
|
31
31
|
const operation = GraphqlMiddlewareOperation.Mutation;
|
|
32
|
-
const operationName = event
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const operationName = getRouterParam(event, "name");
|
|
33
|
+
if (!isValidMutation(operationName)) {
|
|
34
|
+
return throwError("Invalid mutation name.");
|
|
35
|
+
}
|
|
36
|
+
const operationDocument = documents.mutation[operationName];
|
|
35
37
|
const multiPartData = await readMultipartFormData(event);
|
|
36
38
|
if (!multiPartData) {
|
|
37
39
|
return throwError("Failed to read multi part data.");
|
|
@@ -2,8 +2,10 @@ import { type QueryObject } from 'ufo';
|
|
|
2
2
|
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
|
-
import { GraphqlMiddlewareOperation } from './../../settings/index.js';
|
|
6
|
-
import {
|
|
5
|
+
import { type GraphqlMiddlewareOperation } from './../../settings/index.js';
|
|
6
|
+
import type { Mutation, Query } from '#nuxt-graphql-middleware/operations';
|
|
7
|
+
export declare function isValidMutation(v?: string): v is keyof Mutation;
|
|
8
|
+
export declare function isValidQuery(v?: string): v is keyof Query;
|
|
7
9
|
export declare function queryParamToVariables(query: QueryObject): any;
|
|
8
10
|
/**
|
|
9
11
|
* Extract the client context from the query params.
|
|
@@ -12,21 +14,17 @@ export declare function extractRequestContext(query: QueryObject): GraphqlMiddle
|
|
|
12
14
|
/**
|
|
13
15
|
* Get the URL of the GraphQL endpoint.
|
|
14
16
|
*/
|
|
15
|
-
export declare function getEndpoint(config: GraphqlMiddlewareRuntimeConfig, serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, operation: GraphqlMiddlewareOperation, operationName: string, context: GraphqlMiddlewareRequestContext<any>): string | Promise<string>;
|
|
17
|
+
export declare function getEndpoint(config: GraphqlMiddlewareRuntimeConfig, serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, operation: GraphqlMiddlewareOperation | null, operationName: string | null, context: GraphqlMiddlewareRequestContext<any> | null): string | Promise<string>;
|
|
16
18
|
/**
|
|
17
19
|
* Get the options for the $fetch request to the GraphQL server.
|
|
18
20
|
*/
|
|
19
|
-
export declare function getFetchOptions(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, operation: GraphqlMiddlewareOperation, operationName: string, context: GraphqlMiddlewareRequestContext<any>): FetchOptions | Promise<FetchOptions>;
|
|
21
|
+
export declare function getFetchOptions(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, operation: GraphqlMiddlewareOperation | null, operationName: string | null, context: GraphqlMiddlewareRequestContext<any> | null): FetchOptions | Promise<FetchOptions>;
|
|
20
22
|
export declare function throwError(statusMessage: string, statusCode?: number): never;
|
|
21
|
-
/**
|
|
22
|
-
* Assure that the request is valid.
|
|
23
|
-
*/
|
|
24
|
-
export declare function validateRequest(method?: string, operation?: GraphqlMiddlewareOperation | string, name?: string, documents?: Operations): void;
|
|
25
23
|
/**
|
|
26
24
|
* Handle GraphQL server response.
|
|
27
25
|
*/
|
|
28
|
-
export declare function onServerResponse(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, response: FetchResponse<any>, operation: string, operationName: string, context: GraphqlMiddlewareRequestContext<any>): any;
|
|
26
|
+
export declare function onServerResponse(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, response: FetchResponse<any>, operation: string | null, operationName: string | null, context: GraphqlMiddlewareRequestContext<any> | null): any;
|
|
29
27
|
/**
|
|
30
28
|
* Handle GraphQL server errors.
|
|
31
29
|
*/
|
|
32
|
-
export declare function onServerError(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, error: FetchError, operation: string, operationName: string, context: GraphqlMiddlewareRequestContext<any>): any;
|
|
30
|
+
export declare function onServerError(serverOptions: GraphqlMiddlewareServerOptions<any, any>, event: H3Event, error: FetchError, operation: string | null, operationName: string | null, context: GraphqlMiddlewareRequestContext<any> | null): any;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { createError } from "h3";
|
|
2
2
|
import {
|
|
3
|
-
CLIENT_CONTEXT_PREFIX
|
|
4
|
-
GraphqlMiddlewareOperation
|
|
3
|
+
CLIENT_CONTEXT_PREFIX
|
|
5
4
|
} from "./../../settings/index.js";
|
|
5
|
+
import { documents } from "#nuxt-graphql-middleware/documents";
|
|
6
|
+
export function isValidMutation(v) {
|
|
7
|
+
return !!v && Object.hasOwn(documents.mutation, v);
|
|
8
|
+
}
|
|
9
|
+
export function isValidQuery(v) {
|
|
10
|
+
return !!v && Object.hasOwn(documents.query, v);
|
|
11
|
+
}
|
|
6
12
|
export function queryParamToVariables(query) {
|
|
7
13
|
try {
|
|
8
14
|
if (query.__variables && typeof query.__variables === "string") {
|
|
@@ -61,29 +67,6 @@ export function throwError(statusMessage, statusCode = 400) {
|
|
|
61
67
|
statusMessage
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
|
-
export function validateRequest(method, operation, name, documents) {
|
|
65
|
-
if (method !== "POST" && method !== "GET") {
|
|
66
|
-
throwError("Method not allowed.", 405);
|
|
67
|
-
}
|
|
68
|
-
if (operation !== GraphqlMiddlewareOperation.Query && operation !== GraphqlMiddlewareOperation.Mutation) {
|
|
69
|
-
throwError("Unknown operation.");
|
|
70
|
-
}
|
|
71
|
-
if (method === "POST" && operation !== GraphqlMiddlewareOperation.Mutation) {
|
|
72
|
-
throwError("Queries must be a GET request.");
|
|
73
|
-
}
|
|
74
|
-
if (method === "GET" && operation !== GraphqlMiddlewareOperation.Query) {
|
|
75
|
-
throwError("Mutations must be a POST request.");
|
|
76
|
-
}
|
|
77
|
-
if (!name) {
|
|
78
|
-
throwError("Missing name for operation.");
|
|
79
|
-
}
|
|
80
|
-
if (!documents) {
|
|
81
|
-
throwError("Failed to load GraphQL documents", 500);
|
|
82
|
-
}
|
|
83
|
-
if (!documents[operation][name]) {
|
|
84
|
-
throwError(`Operation "${operation}" with name "${name}" not found.`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
70
|
export function onServerResponse(serverOptions, event, response, operation, operationName, context) {
|
|
88
71
|
if (serverOptions.onServerResponse) {
|
|
89
72
|
return serverOptions.onServerResponse(
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { GraphqlMiddlewareRequestContext } from '../../../types.js';
|
|
3
|
+
import type { GraphqlMiddlewareOperation } from '../../settings/index.js';
|
|
4
|
+
type RequestBody = {
|
|
5
|
+
query: string;
|
|
6
|
+
variables?: Record<string, any>;
|
|
7
|
+
operation?: GraphqlMiddlewareOperation;
|
|
8
|
+
operationName?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Perform a raw GraphQL request.
|
|
12
|
+
*
|
|
13
|
+
* @param body - The request.
|
|
14
|
+
* @param context - The client context.
|
|
15
|
+
* @param event - The H3 event. If not provided, the util will try to get the event using useEvent().
|
|
16
|
+
*/
|
|
17
|
+
export declare function doGraphqlRequest(body: RequestBody, context?: GraphqlMiddlewareRequestContext | null | undefined, providedEvent?: H3Event | null | undefined): Promise<any>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { serverOptions } from "#nuxt-graphql-middleware/server-options";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { useEvent } from "nitropack/runtime";
|
|
4
|
+
import {
|
|
5
|
+
getEndpoint,
|
|
6
|
+
getFetchOptions,
|
|
7
|
+
onServerError,
|
|
8
|
+
onServerResponse
|
|
9
|
+
} from "../helpers/index.js";
|
|
10
|
+
export async function doGraphqlRequest(body, context = null, providedEvent = null) {
|
|
11
|
+
const operationName = body.operationName || null;
|
|
12
|
+
const event = providedEvent ?? useEvent();
|
|
13
|
+
const runtimeConfig = useRuntimeConfig().graphqlMiddleware;
|
|
14
|
+
if (serverOptions.doGraphqlRequest) {
|
|
15
|
+
return serverOptions.doGraphqlRequest({
|
|
16
|
+
event,
|
|
17
|
+
operation: body.operation,
|
|
18
|
+
operationName: body.operationName,
|
|
19
|
+
operationDocument: body.query,
|
|
20
|
+
variables: body.variables || {},
|
|
21
|
+
context: context || {}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const endpoint = await getEndpoint(
|
|
25
|
+
runtimeConfig,
|
|
26
|
+
serverOptions,
|
|
27
|
+
event,
|
|
28
|
+
null,
|
|
29
|
+
operationName,
|
|
30
|
+
context || null
|
|
31
|
+
);
|
|
32
|
+
const fetchOptions = await getFetchOptions(
|
|
33
|
+
serverOptions,
|
|
34
|
+
event,
|
|
35
|
+
null,
|
|
36
|
+
body.operationName || null,
|
|
37
|
+
context
|
|
38
|
+
);
|
|
39
|
+
return $fetch.raw(endpoint, {
|
|
40
|
+
// @ts-expect-error Not yet been fixed in nitro.
|
|
41
|
+
method: "POST",
|
|
42
|
+
body: {
|
|
43
|
+
query: body.query,
|
|
44
|
+
variables: body.variables,
|
|
45
|
+
operationName: body.operationName
|
|
46
|
+
},
|
|
47
|
+
...fetchOptions
|
|
48
|
+
}).then((response) => {
|
|
49
|
+
return onServerResponse(
|
|
50
|
+
serverOptions,
|
|
51
|
+
event,
|
|
52
|
+
response,
|
|
53
|
+
null,
|
|
54
|
+
operationName,
|
|
55
|
+
context
|
|
56
|
+
);
|
|
57
|
+
}).catch((error) => {
|
|
58
|
+
return onServerError(
|
|
59
|
+
serverOptions,
|
|
60
|
+
event,
|
|
61
|
+
error,
|
|
62
|
+
null,
|
|
63
|
+
operationName,
|
|
64
|
+
context
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { FetchOptions } from 'ofetch';
|
|
2
|
-
import type { GraphqlResponse } from '#graphql-middleware
|
|
2
|
+
import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
3
3
|
export declare function performRequest<T>(operation: string, operationName: string, method: 'get' | 'post', options: FetchOptions): Promise<GraphqlResponse<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEndpoint } from "
|
|
1
|
+
import { getEndpoint } from "#nuxt-graphql-middleware/helpers";
|
|
2
2
|
export function performRequest(operation, operationName, method, options) {
|
|
3
3
|
return $fetch(getEndpoint(operation, operationName), {
|
|
4
4
|
...options,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GraphqlResponse } from '#graphql-middleware
|
|
2
|
-
import { type
|
|
3
|
-
import type {
|
|
1
|
+
import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
2
|
+
import { type GetMutationArgs, type MutationObjectArgs, type GetMutationResult } from './../../helpers/composables.js';
|
|
3
|
+
import type { Mutation } from '#nuxt-graphql-middleware/operations';
|
|
4
4
|
/**
|
|
5
5
|
* Performs a GraphQL mutation.
|
|
6
6
|
*/
|
|
7
|
-
export declare function useGraphqlMutation<
|
|
7
|
+
export declare function useGraphqlMutation<K extends keyof Mutation, R extends GetMutationResult<K>>(...args: GetMutationArgs<K> | [MutationObjectArgs<K>]): Promise<GraphqlResponse<R>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { GraphqlResponse } from '#graphql-middleware
|
|
2
|
-
import { type
|
|
3
|
-
import type {
|
|
1
|
+
import type { GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
2
|
+
import { type GetQueryArgs, type QueryObjectArgs, type GetQueryResult } from './../../helpers/composables.js';
|
|
3
|
+
import type { Query } from '#nuxt-graphql-middleware/operations';
|
|
4
4
|
/**
|
|
5
5
|
* Performs a GraphQL query.
|
|
6
6
|
*/
|
|
7
|
-
export declare function useGraphqlQuery<
|
|
7
|
+
export declare function useGraphqlQuery<K extends keyof Query, R extends GetQueryResult<K>>(...args: GetQueryArgs<K> | [QueryObjectArgs<K>]): Promise<GraphqlResponse<R>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { GraphqlClientContext } from '#graphql-middleware
|
|
1
|
+
import type { GraphqlClientContext } from '#nuxt-graphql-middleware/client-options';
|
|
2
|
+
import type { GraphqlMiddlewareResponseUnion } from '#nuxt-graphql-middleware/response';
|
|
2
3
|
import { type GraphqlMiddlewareServerOptions } from './../../types.js';
|
|
3
|
-
export declare function defineGraphqlServerOptions<T extends object>(options: GraphqlMiddlewareServerOptions<T, GraphqlClientContext>): GraphqlMiddlewareServerOptions<T, GraphqlClientContext>;
|
|
4
|
+
export declare function defineGraphqlServerOptions<T extends object>(options: GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>): GraphqlMiddlewareServerOptions<T, GraphqlMiddlewareResponseUnion, GraphqlClientContext>;
|
|
@@ -1,20 +1,65 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum Template {
|
|
2
2
|
/**
|
|
3
3
|
* Contains the TS definitions for all GraphQL queries, mutations and fragments.
|
|
4
4
|
*/
|
|
5
5
|
OperationTypes = "graphql-operations/index.d.ts",
|
|
6
|
+
/**
|
|
7
|
+
* Contains the TS definitions for all GraphQL queries, mutations and fragments.
|
|
8
|
+
*/
|
|
9
|
+
OperationTypesAll = "nuxt-graphql-middleware/operations.d.ts",
|
|
6
10
|
/**
|
|
7
11
|
* Contains the TS definitions for all GraphQL queries, mutations and fragments.
|
|
8
12
|
*/
|
|
9
13
|
Enums = "graphql-operations/enums.ts",
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Template for the middleware response types.
|
|
16
|
+
*/
|
|
17
|
+
ResponseTypes = "nuxt-graphql-middleware/response.d.ts",
|
|
18
|
+
/**
|
|
19
|
+
* Types for the generated endpoints.
|
|
20
|
+
*/
|
|
21
|
+
NitroTypes = "nuxt-graphql-middleware/nitro.d.ts",
|
|
22
|
+
/**
|
|
23
|
+
* Configuration template.
|
|
24
|
+
*/
|
|
25
|
+
Helpers = "nuxt-graphql-middleware/helpers.mjs",
|
|
26
|
+
/**
|
|
27
|
+
* Configuration template types.
|
|
28
|
+
*/
|
|
29
|
+
HelpersTypes = "nuxt-graphql-middleware/helpers.d.ts",
|
|
30
|
+
/**
|
|
31
|
+
* Exports a single opject containing the compiled queries and mutations.
|
|
12
32
|
*/
|
|
13
|
-
|
|
33
|
+
Documents = "nuxt-graphql-middleware/documents.mjs",
|
|
14
34
|
/**
|
|
15
35
|
* Exports a single opject containing the compiled queries and mutations.
|
|
16
36
|
*/
|
|
17
|
-
|
|
37
|
+
DocumentTypes = "nuxt-graphql-middleware/documents.d.ts",
|
|
38
|
+
/**
|
|
39
|
+
* Contains the source file paths for every operation.
|
|
40
|
+
*/
|
|
41
|
+
OperationSources = "nuxt-graphql-middleware/sources.mjs",
|
|
42
|
+
Types = "nuxt-graphql-middleware/types.d.ts",
|
|
43
|
+
/**
|
|
44
|
+
* The graphql-config file.
|
|
45
|
+
*/
|
|
46
|
+
GraphqlConfig = "nuxt-graphql-middleware/graphql.config.ts",
|
|
47
|
+
/**
|
|
48
|
+
* Imports and exports the user's server options file.
|
|
49
|
+
*/
|
|
50
|
+
ServerOptions = "nuxt-graphql-middleware/server-options.mjs",
|
|
51
|
+
/**
|
|
52
|
+
* Exports the server options types.
|
|
53
|
+
*/
|
|
54
|
+
ServerOptionsTypes = "nuxt-graphql-middleware/server-options.d.ts",
|
|
55
|
+
/**
|
|
56
|
+
* Imports and exports the user's client options file.
|
|
57
|
+
*/
|
|
58
|
+
ClientOptions = "nuxt-graphql-middleware/client-options.mjs",
|
|
59
|
+
/**
|
|
60
|
+
* Exports the client option specific types.
|
|
61
|
+
*/
|
|
62
|
+
ClientOptionsTypes = "nuxt-graphql-middleware/client-options.d.ts"
|
|
18
63
|
}
|
|
19
64
|
export declare enum GraphqlMiddlewareOperation {
|
|
20
65
|
Query = "query",
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
export var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export var Template = /* @__PURE__ */ ((Template2) => {
|
|
2
|
+
Template2["OperationTypes"] = "graphql-operations/index.d.ts";
|
|
3
|
+
Template2["OperationTypesAll"] = "nuxt-graphql-middleware/operations.d.ts";
|
|
4
|
+
Template2["Enums"] = "graphql-operations/enums.ts";
|
|
5
|
+
Template2["ResponseTypes"] = "nuxt-graphql-middleware/response.d.ts";
|
|
6
|
+
Template2["NitroTypes"] = "nuxt-graphql-middleware/nitro.d.ts";
|
|
7
|
+
Template2["Helpers"] = "nuxt-graphql-middleware/helpers.mjs";
|
|
8
|
+
Template2["HelpersTypes"] = "nuxt-graphql-middleware/helpers.d.ts";
|
|
9
|
+
Template2["Documents"] = "nuxt-graphql-middleware/documents.mjs";
|
|
10
|
+
Template2["DocumentTypes"] = "nuxt-graphql-middleware/documents.d.ts";
|
|
11
|
+
Template2["OperationSources"] = "nuxt-graphql-middleware/sources.mjs";
|
|
12
|
+
Template2["Types"] = "nuxt-graphql-middleware/types.d.ts";
|
|
13
|
+
Template2["GraphqlConfig"] = "nuxt-graphql-middleware/graphql.config.ts";
|
|
14
|
+
Template2["ServerOptions"] = "nuxt-graphql-middleware/server-options.mjs";
|
|
15
|
+
Template2["ServerOptionsTypes"] = "nuxt-graphql-middleware/server-options.d.ts";
|
|
16
|
+
Template2["ClientOptions"] = "nuxt-graphql-middleware/client-options.mjs";
|
|
17
|
+
Template2["ClientOptionsTypes"] = "nuxt-graphql-middleware/client-options.d.ts";
|
|
18
|
+
return Template2;
|
|
19
|
+
})(Template || {});
|
|
8
20
|
export var GraphqlMiddlewareOperation = /* @__PURE__ */ ((GraphqlMiddlewareOperation2) => {
|
|
9
21
|
GraphqlMiddlewareOperation2["Query"] = "query";
|
|
10
22
|
GraphqlMiddlewareOperation2["Mutation"] = "mutation";
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { FetchOptions, FetchContext } from 'ofetch';
|
|
2
|
-
import type { GraphqlResponse } from '#graphql-middleware
|
|
3
|
-
|
|
2
|
+
import type { GraphqlMiddlewareResponseUnion, GraphqlResponse } from '#nuxt-graphql-middleware/response';
|
|
3
|
+
export type OperationResponseError = {
|
|
4
|
+
operation: string;
|
|
5
|
+
operationName: string;
|
|
6
|
+
errors: GraphqlResponseError[];
|
|
7
|
+
stack?: string;
|
|
8
|
+
};
|
|
4
9
|
export type GraphqlResponseErrorLocation = {
|
|
5
10
|
line: number;
|
|
6
11
|
column: number;
|
|
@@ -9,6 +14,7 @@ export type GraphqlResponseError = {
|
|
|
9
14
|
message: string;
|
|
10
15
|
locations: GraphqlResponseErrorLocation[];
|
|
11
16
|
path: string[];
|
|
17
|
+
extensions?: Record<string, unknown>;
|
|
12
18
|
};
|
|
13
19
|
export type GraphqlServerResponse<T> = {
|
|
14
20
|
data: T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.6",
|
|
4
4
|
"description": "Module to perform GraphQL requests as a server middleware.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"prepack": "nuxt-module-build build && npm run client:build",
|
|
38
|
+
"prepack": "npm run styles:build && nuxt-module-build build && npm run client:build",
|
|
39
39
|
"dev": "nuxi dev playground --trace-warnings",
|
|
40
40
|
"dev:layers": "nuxi dev playground-layers --trace-warnings",
|
|
41
41
|
"debug": "nuxi dev playground --inspect",
|
|
42
42
|
"dev:build": "nuxi build playground",
|
|
43
43
|
"dev:layers:build": "nuxi build playground-layers",
|
|
44
|
-
"dev:prepare": "MODULE_BUILD=true nuxt-module-build build --stub && MODULE_BUILD=true nuxt-module-build prepare && nuxi prepare playground && nuxi prepare playground
|
|
44
|
+
"dev:prepare": "MODULE_BUILD=true nuxt-module-build build --stub && MODULE_BUILD=true nuxt-module-build prepare && nuxi prepare playground-layers && nuxi prepare playground",
|
|
45
45
|
"dev:start": "node ./playground/.output/server/index.mjs",
|
|
46
46
|
"client:build": "nuxi generate client",
|
|
47
47
|
"client:dev": "nuxi dev client --port 3300",
|
|
48
48
|
"typedoc": "typedoc --plugin typedoc-plugin-markdown --out foobar",
|
|
49
|
-
"typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
49
|
+
"typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit && cd ../playground-layers && vue-tsc --noEmit",
|
|
50
50
|
"docs:dev": "vitepress dev docs --port 5000",
|
|
51
51
|
"docs:build": "vitepress build docs",
|
|
52
52
|
"docs:serve": "vitepress serve docs --port 5000",
|
|
@@ -59,14 +59,17 @@
|
|
|
59
59
|
"test:ci": "vitest run",
|
|
60
60
|
"test:coverage": "vitest run --coverage",
|
|
61
61
|
"prettier": "prettier --check .",
|
|
62
|
-
"prettier:fix": "prettier --write ."
|
|
62
|
+
"prettier:fix": "prettier --write .",
|
|
63
|
+
"styles:build": "postcss ./css/index.css -o ./src/runtime/css/output.css",
|
|
64
|
+
"styles:watch": "postcss ./css/index.css -o ./src/runtime/css/output.css --watch"
|
|
63
65
|
},
|
|
64
66
|
"dependencies": {
|
|
67
|
+
"@clack/prompts": "^0.10.0",
|
|
65
68
|
"@graphql-codegen/cli": "^5.0.5",
|
|
66
69
|
"@graphql-codegen/schema-ast": "^4.1.0",
|
|
67
70
|
"@graphql-tools/utils": "^10.2.2",
|
|
68
71
|
"@nuxt/devtools-kit": "1.3.7",
|
|
69
|
-
"graphql-typescript-deluxe": "^0.0.
|
|
72
|
+
"graphql-typescript-deluxe": "^0.0.6",
|
|
70
73
|
"inquirer": "^9.3.2",
|
|
71
74
|
"minisearch": "^6.3.0",
|
|
72
75
|
"picocolors": "^1.0.1"
|
|
@@ -76,20 +79,29 @@
|
|
|
76
79
|
"@nuxt/devtools": "^1.3.7",
|
|
77
80
|
"@nuxt/devtools-ui-kit": "1.3.7",
|
|
78
81
|
"@nuxt/eslint": "^0.3.13",
|
|
79
|
-
"@nuxt/kit": "^3.
|
|
82
|
+
"@nuxt/kit": "^3.16.0",
|
|
80
83
|
"@nuxt/module-builder": "^0.8.4",
|
|
81
|
-
"@nuxt/schema": "^3.
|
|
84
|
+
"@nuxt/schema": "^3.16.0",
|
|
82
85
|
"@types/capture-console": "^1.0.5",
|
|
83
86
|
"@types/cli-table": "^0.3.4",
|
|
84
87
|
"@types/inquirer": "^9.0.7",
|
|
88
|
+
"@types/micromatch": "^4.0.9",
|
|
85
89
|
"cypress": "^13.12.0",
|
|
86
90
|
"eslint": "^8.57.0",
|
|
87
91
|
"eslint-config-prettier": "^9.1.0",
|
|
88
92
|
"eslint-plugin-prettier": "^5.1.3",
|
|
89
93
|
"jsdoc-to-markdown": "^8.0.1",
|
|
90
|
-
"nuxt": "^3.
|
|
94
|
+
"nuxt": "^3.16.0",
|
|
95
|
+
"postcss": "^8.5.3",
|
|
96
|
+
"postcss-cli": "^11.0.0",
|
|
97
|
+
"postcss-import": "^16.1.0",
|
|
98
|
+
"postcss-nested-import": "^1.3.0",
|
|
99
|
+
"postcss-replace": "^2.0.1",
|
|
100
|
+
"postcss-url": "^10.1.3",
|
|
91
101
|
"prettier": "^3.3.2",
|
|
92
102
|
"strip-ansi": "^7.1.0",
|
|
103
|
+
"tailwindcss": "^3.4.17",
|
|
104
|
+
"tailwindcss-scoped-preflight": "^3.4.10",
|
|
93
105
|
"typedoc": "^0.26.3",
|
|
94
106
|
"typedoc-plugin-markdown": "^4.1.1",
|
|
95
107
|
"vitepress": "^1.5.0",
|