nuxt-graphql-middleware 2.1.2 → 3.0.0-beta.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.
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +141 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +7020 -257
- package/dist/runtime/composables/index.d.ts +15 -0
- package/dist/runtime/composables/index.mjs +44 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +9 -0
- package/dist/runtime/serverHandler/helpers/index.d.ts +2 -0
- package/dist/runtime/serverHandler/helpers/index.mjs +4 -0
- package/dist/runtime/serverHandler/index.d.ts +2 -0
- package/dist/runtime/serverHandler/index.mjs +93 -0
- package/dist/types.d.ts +11 -0
- package/package.json +31 -47
- package/dist/plugin.mjs +0 -106
- package/dist/types/codegen.d.ts +0 -13
- package/dist/types/codegen.d.ts.map +0 -1
- package/dist/types/graphqlImport.d.ts +0 -2
- package/dist/types/graphqlImport.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/module.d.ts +0 -18
- package/dist/types/module.d.ts.map +0 -1
- package/dist/types/serverMiddleware.d.ts +0 -13
- package/dist/types/serverMiddleware.d.ts.map +0 -1
- package/dist/types/templates/plugin.d.ts +0 -26
- package/dist/types/templates/plugin.d.ts.map +0 -1
- package/module.cjs +0 -6
- package/types/index.d.ts +0 -32
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import { GraphqlMiddlewareState } from './../../types';
|
|
3
|
+
import type { GraphqlMiddlewareQuery, GraphqlMiddlewareMutation } from '#build/nuxt-graphql-middleware';
|
|
4
|
+
declare type GraphqlMiddlewareQueryName = keyof GraphqlMiddlewareQuery;
|
|
5
|
+
declare type GraphqlMiddlewareMutationName = keyof GraphqlMiddlewareMutation;
|
|
6
|
+
declare type GraphqlMiddlewareOperationMap = GraphqlMiddlewareQuery | GraphqlMiddlewareMutation;
|
|
7
|
+
declare type GetArgs<T extends GraphqlMiddlewareQueryName, M extends GraphqlMiddlewareOperationMap> = M[T][0] extends null ? [T] : M[T][1] extends false ? [T, M[T][0]] : [T, M[T][0]?];
|
|
8
|
+
declare type GraphqlResponse<T> = {
|
|
9
|
+
data: T;
|
|
10
|
+
};
|
|
11
|
+
declare type GetResult<T, M> = M[T] extends undefined ? undefined : GraphqlResponse<M[T][2]>;
|
|
12
|
+
export declare const useGraphqlState: () => Ref<GraphqlMiddlewareState>;
|
|
13
|
+
export declare function useGraphqlQuery<T extends GraphqlMiddlewareQueryName>(...args: GetArgs<T, GraphqlMiddlewareQuery>): Promise<GetResult<T, GraphqlMiddlewareQuery>>;
|
|
14
|
+
export declare function useGraphqlMutation<T extends GraphqlMiddlewareMutationName>(...args: GetArgs<T, GraphqlMiddlewareMutation>): Promise<GetResult<T, GraphqlMiddlewareMutation>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useNuxtApp, useRuntimeConfig } from "#imports";
|
|
2
|
+
function getEndpoint(operation, operationName) {
|
|
3
|
+
const config = useRuntimeConfig();
|
|
4
|
+
return `${config?.public?.["nuxt-graphql-middleware"]?.serverApiPrefix}/${operation}/${operationName}`;
|
|
5
|
+
}
|
|
6
|
+
export const useGraphqlState = () => {
|
|
7
|
+
const nuxtApp = useNuxtApp();
|
|
8
|
+
return nuxtApp?._graphql_middleware;
|
|
9
|
+
};
|
|
10
|
+
export function useGraphqlQuery(...args) {
|
|
11
|
+
const name = args[0];
|
|
12
|
+
if (typeof name !== "string") {
|
|
13
|
+
return Promise.reject(new Error("Invalid query name"));
|
|
14
|
+
}
|
|
15
|
+
const variables = args[1] || {};
|
|
16
|
+
let params = {};
|
|
17
|
+
const queryFallback = Object.keys(variables).some((key) => {
|
|
18
|
+
const valueType = typeof variables[key];
|
|
19
|
+
return valueType === "function" || valueType === "object";
|
|
20
|
+
});
|
|
21
|
+
if (queryFallback) {
|
|
22
|
+
params.__variables = JSON.stringify(variables);
|
|
23
|
+
} else {
|
|
24
|
+
params = variables;
|
|
25
|
+
}
|
|
26
|
+
const state = useGraphqlState();
|
|
27
|
+
return $fetch(getEndpoint("query", name), {
|
|
28
|
+
params,
|
|
29
|
+
...state.value.fetchOptions
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function useGraphqlMutation(...args) {
|
|
33
|
+
const state = useGraphqlState();
|
|
34
|
+
const name = args[0];
|
|
35
|
+
const body = args[1] || {};
|
|
36
|
+
if (typeof name !== "string") {
|
|
37
|
+
return Promise.reject(new Error("Invalid mutation name"));
|
|
38
|
+
}
|
|
39
|
+
return $fetch(getEndpoint("mutation", name), {
|
|
40
|
+
method: "post",
|
|
41
|
+
body,
|
|
42
|
+
...state.value.fetchOptions
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineEventHandler,
|
|
3
|
+
createError,
|
|
4
|
+
getQuery,
|
|
5
|
+
getMethod,
|
|
6
|
+
readBody
|
|
7
|
+
} from "h3";
|
|
8
|
+
import { loadNuxtConfig } from "@nuxt/kit";
|
|
9
|
+
import { useRuntimeConfig } from "#imports";
|
|
10
|
+
import operations from "#graphql-documents";
|
|
11
|
+
var GraphqlMiddlewareOperation = /* @__PURE__ */ ((GraphqlMiddlewareOperation2) => {
|
|
12
|
+
GraphqlMiddlewareOperation2["Query"] = "query";
|
|
13
|
+
GraphqlMiddlewareOperation2["Mutation"] = "mutation";
|
|
14
|
+
return GraphqlMiddlewareOperation2;
|
|
15
|
+
})(GraphqlMiddlewareOperation || {});
|
|
16
|
+
let moduleConfig = null;
|
|
17
|
+
function getModuleConfig() {
|
|
18
|
+
if (moduleConfig) {
|
|
19
|
+
return Promise.resolve(moduleConfig);
|
|
20
|
+
}
|
|
21
|
+
const { graphqlMiddleware } = useRuntimeConfig();
|
|
22
|
+
return loadNuxtConfig({
|
|
23
|
+
cwd: graphqlMiddleware.rootDir
|
|
24
|
+
}).then((v) => {
|
|
25
|
+
moduleConfig = v.graphqlMiddleware;
|
|
26
|
+
return v.graphqlMiddleware;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function queryParamToVariables(query) {
|
|
30
|
+
try {
|
|
31
|
+
if (query.__variables && typeof query.__variables === "string") {
|
|
32
|
+
return JSON.parse(query.__variables);
|
|
33
|
+
}
|
|
34
|
+
} catch (_e) {
|
|
35
|
+
}
|
|
36
|
+
return query;
|
|
37
|
+
}
|
|
38
|
+
function getEndpoint(moduleConfig2, event, operation, operationName) {
|
|
39
|
+
if (typeof moduleConfig2.graphqlEndpoint === "string") {
|
|
40
|
+
return moduleConfig2.graphqlEndpoint;
|
|
41
|
+
}
|
|
42
|
+
return moduleConfig2.graphqlEndpoint(event, operation, operationName);
|
|
43
|
+
}
|
|
44
|
+
function getFetchOptions(moduleConfig2, event, operation, operationName) {
|
|
45
|
+
if (typeof moduleConfig2.serverFetchOptions === "function") {
|
|
46
|
+
return moduleConfig2.serverFetchOptions(event, operation, operationName) || {};
|
|
47
|
+
} else if (typeof moduleConfig2.serverFetchOptions === "object") {
|
|
48
|
+
return moduleConfig2.serverFetchOptions;
|
|
49
|
+
}
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
export default defineEventHandler(async (event) => {
|
|
53
|
+
const method = getMethod(event);
|
|
54
|
+
const operation = event.context.params.operation;
|
|
55
|
+
if (method === "POST" && operation !== "mutation" /* Mutation */) {
|
|
56
|
+
throw createError({
|
|
57
|
+
statusCode: 400,
|
|
58
|
+
statusMessage: "Mutations must be a POST request."
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (method === "GET" && operation !== "query" /* Query */) {
|
|
62
|
+
throw createError({
|
|
63
|
+
statusCode: 400,
|
|
64
|
+
statusMessage: "Queries must be a GET request."
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const name = event.context.params.name;
|
|
68
|
+
const query = operations[operation][name];
|
|
69
|
+
if (!query) {
|
|
70
|
+
throw createError({
|
|
71
|
+
statusCode: 400,
|
|
72
|
+
statusMessage: `Operation "${operation}" with name "${name} not found."`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const config = await getModuleConfig();
|
|
76
|
+
const endpoint = getEndpoint(config, event, operation, name);
|
|
77
|
+
const fetchOptions = getFetchOptions(config, event, operation, name);
|
|
78
|
+
const variables = operation === "query" /* Query */ ? queryParamToVariables(getQuery(event)) : readBody(event);
|
|
79
|
+
return $fetch(endpoint, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
body: {
|
|
82
|
+
query,
|
|
83
|
+
variables
|
|
84
|
+
},
|
|
85
|
+
...fetchOptions
|
|
86
|
+
}).catch((err) => {
|
|
87
|
+
throw createError({
|
|
88
|
+
statusCode: 500,
|
|
89
|
+
statusMessage: "Couldn't execute GraphQL query.",
|
|
90
|
+
data: err && "message" in err ? err.mess : err
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions, ModuleHooks } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['graphqlMiddleware']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['graphqlMiddleware']?: ModuleOptions }
|
|
7
|
+
interface NuxtHooks extends ModuleHooks {}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export { default } from './module'
|
package/package.json
CHANGED
|
@@ -1,65 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Module to perform GraphQL requests as a server middleware.",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/dulnan/nuxt-graphql-middleware.git"
|
|
8
|
-
},
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
9
4
|
"license": "MIT",
|
|
10
|
-
"
|
|
11
|
-
"name": "Jan Hug",
|
|
12
|
-
"email": "me@dulnan.net",
|
|
13
|
-
"url": "https://dulnan.net"
|
|
14
|
-
},
|
|
5
|
+
"type": "module",
|
|
15
6
|
"exports": {
|
|
16
7
|
".": {
|
|
17
8
|
"import": "./dist/module.mjs",
|
|
18
|
-
"require": "./module.cjs"
|
|
19
|
-
}
|
|
20
|
-
"./dist/*": "./dist/*"
|
|
9
|
+
"require": "./dist/module.cjs"
|
|
10
|
+
}
|
|
21
11
|
},
|
|
22
|
-
"main": "./module.cjs",
|
|
23
|
-
"types": "./types
|
|
12
|
+
"main": "./dist/module.cjs",
|
|
13
|
+
"types": "./dist/types.d.ts",
|
|
24
14
|
"files": [
|
|
25
|
-
"
|
|
26
|
-
"module.cjs",
|
|
27
|
-
"dist/*.js",
|
|
28
|
-
"dist/*.mjs",
|
|
29
|
-
"dist/*.d.ts",
|
|
30
|
-
"dist/types/*"
|
|
15
|
+
"dist"
|
|
31
16
|
],
|
|
32
17
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"dev": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
18
|
+
"prepack": "nuxt-module-build",
|
|
19
|
+
"dev": "nuxi dev playground",
|
|
20
|
+
"dev:build": "nuxi build playground",
|
|
21
|
+
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
|
22
|
+
"typedoc": "typedoc --plugin typedoc-plugin-markdown --out foobar",
|
|
23
|
+
"docs:dev": "vitepress dev docs --port 5000",
|
|
24
|
+
"docs:build": "vitepress build docs",
|
|
25
|
+
"docs:serve": "vitepress serve docs --port 5000"
|
|
37
26
|
},
|
|
38
27
|
"dependencies": {
|
|
39
|
-
"@graphql-codegen/cli": "^2.
|
|
40
|
-
"@graphql-codegen/schema-ast": "^2.
|
|
41
|
-
"@graphql-codegen/typescript": "^2.
|
|
42
|
-
"@graphql-codegen/typescript-
|
|
43
|
-
"@graphql-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"graphql-request": "^3.6.1"
|
|
28
|
+
"@graphql-codegen/cli": "^2.11.8",
|
|
29
|
+
"@graphql-codegen/schema-ast": "^2.5.1",
|
|
30
|
+
"@graphql-codegen/typescript": "^2.7.3",
|
|
31
|
+
"@graphql-codegen/typescript-generic-sdk": "^3.0.1",
|
|
32
|
+
"@graphql-codegen/typescript-operations": "^2.5.3",
|
|
33
|
+
"@graphql-fragment-import/lib": "^2.0.0",
|
|
34
|
+
"@nuxt/kit": "^3.0.0-rc.8"
|
|
47
35
|
},
|
|
48
36
|
"devDependencies": {
|
|
49
|
-
"@nuxt/
|
|
37
|
+
"@nuxt/module-builder": "latest",
|
|
50
38
|
"@nuxtjs/eslint-config-typescript": "latest",
|
|
51
|
-
"@types/mkdirp": "^1.0.2",
|
|
52
|
-
"@types/node": "^16.11.10",
|
|
53
|
-
"consola": "^2.15.3",
|
|
54
39
|
"eslint": "latest",
|
|
55
|
-
"eslint-config-prettier": "
|
|
56
|
-
"eslint-plugin-prettier": "
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"vue": "^2.6.14"
|
|
40
|
+
"eslint-config-prettier": "^8.5.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
42
|
+
"jsdoc-to-markdown": "^7.1.1",
|
|
43
|
+
"nuxt": "^3.0.0-rc.8",
|
|
44
|
+
"prettier": "^2.7.1",
|
|
45
|
+
"typedoc": "^0.23.14",
|
|
46
|
+
"typedoc-plugin-markdown": "^3.13.5",
|
|
47
|
+
"vitepress": "^1.0.0-alpha.13"
|
|
64
48
|
}
|
|
65
49
|
}
|
package/dist/plugin.mjs
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const IS_DEV = process.env.NODE_ENV === "development";
|
|
2
|
-
function log(action, path, message) {
|
|
3
|
-
if (IS_DEV) {
|
|
4
|
-
console.log(`[API - ${action}] ${message}: ${path}`);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
class GraphqlMiddlewarePlugin {
|
|
8
|
-
constructor(baseURL, headers, useCache, context) {
|
|
9
|
-
this.baseURL = baseURL;
|
|
10
|
-
this.headers = headers || {};
|
|
11
|
-
this.context = context;
|
|
12
|
-
if (useCache) {
|
|
13
|
-
this.cache = new Map();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
getPluginHeaderValue() {
|
|
17
|
-
return {
|
|
18
|
-
"Nuxt-Graphql-Middleware-Route": this.context?.route?.fullPath || ""
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
beforeRequest(fn) {
|
|
22
|
-
this.beforeRequestFn = fn;
|
|
23
|
-
}
|
|
24
|
-
clearCache() {
|
|
25
|
-
if (this.cache) {
|
|
26
|
-
this.cache.clear();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
query(name, variables, headers = {}) {
|
|
30
|
-
const params = new URLSearchParams({
|
|
31
|
-
name,
|
|
32
|
-
variables: JSON.stringify(variables || {})
|
|
33
|
-
});
|
|
34
|
-
const url = this.baseURL + "/query?" + params.toString();
|
|
35
|
-
if (this.cache?.has(url)) {
|
|
36
|
-
log("query", url, "Loading from cache");
|
|
37
|
-
return Promise.resolve(this.cache.get(url));
|
|
38
|
-
}
|
|
39
|
-
log("query", url, "Fetching");
|
|
40
|
-
const defaultOptions = {
|
|
41
|
-
method: "GET",
|
|
42
|
-
credentials: "include",
|
|
43
|
-
headers: {
|
|
44
|
-
"Content-Type": "application/json",
|
|
45
|
-
...headers,
|
|
46
|
-
...this.headers,
|
|
47
|
-
...this.getPluginHeaderValue()
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return this.doBeforeRequest(defaultOptions).then((fetchOptions) => {
|
|
51
|
-
return fetch(url, fetchOptions).then((response) => {
|
|
52
|
-
if (response.ok) {
|
|
53
|
-
return response.json();
|
|
54
|
-
}
|
|
55
|
-
throw new Error("Server Error");
|
|
56
|
-
}).then((data) => {
|
|
57
|
-
if (this.cache && this.cache.size > 30) {
|
|
58
|
-
const key = this.cache.keys().next().value;
|
|
59
|
-
this.cache.delete(key);
|
|
60
|
-
}
|
|
61
|
-
this.cache?.set(url, data);
|
|
62
|
-
return data;
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
doBeforeRequest(fetchOptions) {
|
|
67
|
-
if (!this.beforeRequestFn) {
|
|
68
|
-
return Promise.resolve(fetchOptions);
|
|
69
|
-
}
|
|
70
|
-
return Promise.resolve(this.beforeRequestFn(this.context, fetchOptions));
|
|
71
|
-
}
|
|
72
|
-
mutate(name, variables, headers = {}) {
|
|
73
|
-
const params = new URLSearchParams({
|
|
74
|
-
name
|
|
75
|
-
});
|
|
76
|
-
let defaultOptions = {
|
|
77
|
-
method: "POST",
|
|
78
|
-
credentials: "include",
|
|
79
|
-
headers: {
|
|
80
|
-
"Content-Type": "application/json",
|
|
81
|
-
...headers,
|
|
82
|
-
...this.headers,
|
|
83
|
-
...this.getPluginHeaderValue()
|
|
84
|
-
},
|
|
85
|
-
body: JSON.stringify(variables)
|
|
86
|
-
};
|
|
87
|
-
return this.doBeforeRequest(defaultOptions).then((fetchOptions) => {
|
|
88
|
-
return fetch(this.baseURL + "/mutate?" + params.toString(), fetchOptions).then((response) => response.json());
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const graphqlMiddlewarePlugin = (context, inject) => {
|
|
93
|
-
const namespace = "<%= options.namespace || '' %>";
|
|
94
|
-
const port = process?.env?.NUXT_PORT || "<%= options.port %>";
|
|
95
|
-
const cacheInBrowser = false;
|
|
96
|
-
const cacheInServer = false;
|
|
97
|
-
let baseURL = namespace;
|
|
98
|
-
if (process.server) {
|
|
99
|
-
baseURL = "http://localhost:" + port + namespace;
|
|
100
|
-
}
|
|
101
|
-
const useCache = process.server && cacheInServer || process.client && cacheInBrowser;
|
|
102
|
-
const plugin = new GraphqlMiddlewarePlugin(baseURL, context.req?.headers, useCache, context);
|
|
103
|
-
inject("graphql", plugin);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export { GraphqlMiddlewarePlugin, graphqlMiddlewarePlugin as default };
|
package/dist/types/codegen.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface GraphqlMiddlewareCodegenConfig {
|
|
2
|
-
enabled?: boolean;
|
|
3
|
-
skipSchemaDownload?: boolean;
|
|
4
|
-
resolvedQueriesPath: string;
|
|
5
|
-
schemaOutputPath: string;
|
|
6
|
-
typesOutputPath: string;
|
|
7
|
-
schemaOptions: any;
|
|
8
|
-
}
|
|
9
|
-
export default function (graphqlServer: string, options: GraphqlMiddlewareCodegenConfig): {
|
|
10
|
-
generateSchema: () => Promise<any>;
|
|
11
|
-
generateTypes: () => Promise<any>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/codegen.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,CAAC,OAAO,WACZ,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,8BAA8B;;;EAoDxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlImport.d.ts","sourceRoot":"","sources":["../../src/graphqlImport.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OASnD"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
package/dist/types/module.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Module } from '@nuxt/types';
|
|
2
|
-
import { GraphqlMiddlewarePluginConfig } from './templates/plugin';
|
|
3
|
-
import { GraphqlServerMiddlewareConfig } from './serverMiddleware';
|
|
4
|
-
import { GraphqlMiddlewareCodegenConfig } from './codegen';
|
|
5
|
-
export interface GraphqlMiddlewareConfig {
|
|
6
|
-
graphqlServer: string;
|
|
7
|
-
typescript?: GraphqlMiddlewareCodegenConfig;
|
|
8
|
-
endpointNamespace?: string;
|
|
9
|
-
debug: boolean;
|
|
10
|
-
queries: Record<string, string>;
|
|
11
|
-
mutations: Record<string, string>;
|
|
12
|
-
outputPath: string;
|
|
13
|
-
plugin?: GraphqlMiddlewarePluginConfig;
|
|
14
|
-
server?: GraphqlServerMiddlewareConfig;
|
|
15
|
-
}
|
|
16
|
-
declare const graphqlMiddleware: Module;
|
|
17
|
-
export default graphqlMiddleware;
|
|
18
|
-
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAyB,EACvB,6BAA6B,EAC9B,MAAM,oBAAoB,CAAA;AAE3B,OAAgB,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAA;AAMnE,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,8BAA8B,CAAA;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,6BAA6B,CAAA;IACtC,MAAM,CAAC,EAAE,6BAA6B,CAAA;CACvC;AAiED,QAAA,MAAM,iBAAiB,EAAE,MAgKxB,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Request, RequestHandler } from 'express';
|
|
2
|
-
export interface GraphqlServerMiddlewareConfig {
|
|
3
|
-
middleware?: RequestHandler;
|
|
4
|
-
fetchOptions?: any;
|
|
5
|
-
buildHeaders?: (req: Request, name: string, type: string) => any;
|
|
6
|
-
buildEndpoint?: (req: Request) => string;
|
|
7
|
-
onQueryResponse?: any;
|
|
8
|
-
onQueryError?: any;
|
|
9
|
-
onMutationResponse?: any;
|
|
10
|
-
onMutationError?: any;
|
|
11
|
-
}
|
|
12
|
-
export default function createServerMiddleware(graphqlServer: string, queries: Map<string, any>, mutations: Map<string, any>, config?: GraphqlServerMiddlewareConfig): import("express-serve-static-core").Express;
|
|
13
|
-
//# sourceMappingURL=serverMiddleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serverMiddleware.d.ts","sourceRoot":"","sources":["../../src/serverMiddleware.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,SAAS,CAAA;AAcpE,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,YAAY,CAAC,EAAE,GAAG,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAA;IAChE,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAA;IACxC,eAAe,CAAC,EAAE,GAAG,CAAA;IACrB,YAAY,CAAC,EAAE,GAAG,CAAA;IAClB,kBAAkB,CAAC,EAAE,GAAG,CAAA;IACxB,eAAe,CAAC,EAAE,GAAG,CAAA;CACtB;AAkBD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,CAAC,EAAE,6BAA6B,+CA0FvC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Context, Plugin } from '@nuxt/types';
|
|
2
|
-
export interface GraphqlMiddlewarePluginConfig {
|
|
3
|
-
enabled?: boolean;
|
|
4
|
-
port?: number;
|
|
5
|
-
cacheInBrowser?: boolean;
|
|
6
|
-
cacheInServer?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare class GraphqlMiddlewarePlugin {
|
|
9
|
-
baseURL: string;
|
|
10
|
-
headers: any;
|
|
11
|
-
beforeRequestFn: Function | undefined;
|
|
12
|
-
cache?: Map<string, any>;
|
|
13
|
-
context: any;
|
|
14
|
-
constructor(baseURL: string, headers: any, useCache: boolean, context: Context);
|
|
15
|
-
getPluginHeaderValue(): {
|
|
16
|
-
'Nuxt-Graphql-Middleware-Route': any;
|
|
17
|
-
};
|
|
18
|
-
beforeRequest(fn: Function): void;
|
|
19
|
-
clearCache(): void;
|
|
20
|
-
query(name: string, variables?: any, headers?: any): Promise<any>;
|
|
21
|
-
doBeforeRequest(fetchOptions: Record<string, any>): Promise<any>;
|
|
22
|
-
mutate(name: string, variables?: any, headers?: any): Promise<any>;
|
|
23
|
-
}
|
|
24
|
-
declare const graphqlMiddlewarePlugin: Plugin;
|
|
25
|
-
export default graphqlMiddlewarePlugin;
|
|
26
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/templates/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAW7C,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,qBAAa,uBAAuB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,GAAG,CAAA;IACZ,eAAe,EAAE,QAAQ,GAAG,SAAS,CAAA;IACrC,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;gBAGV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO;IAUlB,oBAAoB;;;IAMpB,aAAa,CAAC,EAAE,EAAE,QAAQ;IAI1B,UAAU;IASV,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,GAAE,GAAQ;IA+CtD,eAAe,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAWjD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,GAAE,GAAQ;CAuBxD;AAED,QAAA,MAAM,uBAAuB,EAAE,MAyB9B,CAAA;AAED,eAAe,uBAAuB,CAAA"}
|
package/module.cjs
DELETED
package/types/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { GraphqlMiddlewarePlugin } from '../dist/types/templates/plugin'
|
|
2
|
-
import { GraphqlMiddlewareConfig } from '../dist/types/module'
|
|
3
|
-
|
|
4
|
-
declare module 'vue/types/vue' {
|
|
5
|
-
interface Vue {
|
|
6
|
-
readonly $graphql: GraphqlMiddlewarePlugin
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare module 'vuex/types/index' {
|
|
11
|
-
interface Store<S> {
|
|
12
|
-
readonly $graphql: GraphqlMiddlewarePlugin
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module '@nuxt/types' {
|
|
17
|
-
interface NuxtAppOptions {
|
|
18
|
-
readonly $graphql: GraphqlMiddlewarePlugin
|
|
19
|
-
}
|
|
20
|
-
interface Context {
|
|
21
|
-
readonly $graphql: GraphqlMiddlewarePlugin
|
|
22
|
-
}
|
|
23
|
-
interface Configuration {
|
|
24
|
-
graphqlMiddleware?: GraphqlMiddlewareConfig
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare module '@nuxt/schema' {
|
|
29
|
-
interface NuxtConfig {
|
|
30
|
-
graphqlMiddleware?: GraphqlMiddlewareConfig
|
|
31
|
-
}
|
|
32
|
-
}
|