nuxt-graphql-middleware 3.0.0-beta.3 → 3.0.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/README.md +5 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +13 -2
- package/dist/runtime/serverHandler/helpers/index.d.ts +1 -1
- package/dist/runtime/serverHandler/helpers/index.mjs +1 -1
- package/dist/runtime/serverHandler/index.mjs +1 -1
- package/dist/runtime/settings/index.d.ts +18 -0
- package/dist/runtime/settings/index.mjs +11 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -58,3 +58,8 @@ console.log(data.allFilms.films)
|
|
|
58
58
|
Alternatively you can also call
|
|
59
59
|
`http://localhost:3000/api/graphql_middleware/query/films` to get the same
|
|
60
60
|
result.
|
|
61
|
+
|
|
62
|
+
## Nuxt 2
|
|
63
|
+
|
|
64
|
+
The 3.x releases are only compatible with Nuxt 3. The [2.x branch](https://github.com/dulnan/nuxt-graphql-middleware/tree/2.x) and releases
|
|
65
|
+
on npm are compatible with Nuxt 2.
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
1
2
|
import { defu } from 'defu';
|
|
2
3
|
import { useLogger, resolveAlias, resolveFiles, defineNuxtModule, createResolver, addImportsDir, addTemplate, addServerHandler, updateTemplates } from '@nuxt/kit';
|
|
3
4
|
import inquirer from 'inquirer';
|
|
@@ -16,7 +17,7 @@ import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
|
16
17
|
import { pascalCase } from 'change-case-all';
|
|
17
18
|
|
|
18
19
|
const name = "nuxt-graphql-middleware";
|
|
19
|
-
const version = "3.0.0
|
|
20
|
+
const version = "3.0.0";
|
|
20
21
|
|
|
21
22
|
var GraphqlMiddlewareTemplate = /* @__PURE__ */ ((GraphqlMiddlewareTemplate2) => {
|
|
22
23
|
GraphqlMiddlewareTemplate2["OperationTypes"] = "graphql-operations.d.ts";
|
|
@@ -337,7 +338,7 @@ function validateDocuments(schema, documents, srcDir) {
|
|
|
337
338
|
}
|
|
338
339
|
document.isValid = document.errors.length === 0;
|
|
339
340
|
} catch (e) {
|
|
340
|
-
document.errors =
|
|
341
|
+
document.errors = [e];
|
|
341
342
|
document.isValid = false;
|
|
342
343
|
}
|
|
343
344
|
}
|
|
@@ -403,6 +404,8 @@ const module = defineNuxtModule({
|
|
|
403
404
|
const srcDir = nuxt.options.srcDir;
|
|
404
405
|
const srcResolver = createResolver(srcDir).resolve;
|
|
405
406
|
const schemaPath = await getSchemaPath(options, srcResolver);
|
|
407
|
+
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
|
|
408
|
+
nuxt.options.build.transpile.push(runtimeDir);
|
|
406
409
|
const ctx = {
|
|
407
410
|
templates: []
|
|
408
411
|
};
|
|
@@ -505,6 +508,14 @@ declare module '#graphql-documents' {
|
|
|
505
508
|
handler: moduleResolver("./runtime/serverHandler/index"),
|
|
506
509
|
route: options.serverApiPrefix + "/:operation/:name"
|
|
507
510
|
});
|
|
511
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
512
|
+
nitroConfig.externals = defu(
|
|
513
|
+
typeof nitroConfig.externals === "object" ? nitroConfig.externals : {},
|
|
514
|
+
{
|
|
515
|
+
inline: [moduleResolver("./runtime")]
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
});
|
|
508
519
|
if (nuxt.options.dev) {
|
|
509
520
|
nuxt.hook("nitro:build:before", (nitro) => {
|
|
510
521
|
nuxt.hook("builder:watch", async (event, path) => {
|
|
@@ -2,7 +2,7 @@ import { QueryObject } from 'ufo';
|
|
|
2
2
|
import type { H3Event } from 'h3';
|
|
3
3
|
import type { FetchOptions } from 'ofetch';
|
|
4
4
|
import type { GraphqlMiddlewareConfig } from './../../../types';
|
|
5
|
-
import { GraphqlMiddlewareOperation } from '
|
|
5
|
+
import { GraphqlMiddlewareOperation } from './../../settings';
|
|
6
6
|
export declare function queryParamToVariables(query: QueryObject): any;
|
|
7
7
|
/**
|
|
8
8
|
* Get the URL of the GraphQL endpoint.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createError } from "h3";
|
|
2
|
-
import { GraphqlMiddlewareOperation } from "
|
|
2
|
+
import { GraphqlMiddlewareOperation } from "./../../settings/index.mjs";
|
|
3
3
|
export function queryParamToVariables(query) {
|
|
4
4
|
try {
|
|
5
5
|
if (query.__variables && typeof query.__variables === "string") {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
validateRequest
|
|
13
13
|
} from "./helpers";
|
|
14
14
|
import { getModuleConfig } from "./helpers/getModuleConfig.mjs";
|
|
15
|
-
import { GraphqlMiddlewareOperation } from "
|
|
15
|
+
import { GraphqlMiddlewareOperation } from "./../settings/index.mjs";
|
|
16
16
|
import { documents } from "#graphql-documents";
|
|
17
17
|
export default defineEventHandler(async (event) => {
|
|
18
18
|
const method = getMethod(event);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum GraphqlMiddlewareTemplate {
|
|
2
|
+
/**
|
|
3
|
+
* Contains the TS definitions for all GraphQL queries, mutations and fragments.
|
|
4
|
+
*/
|
|
5
|
+
OperationTypes = "graphql-operations.d.ts",
|
|
6
|
+
/**
|
|
7
|
+
* Signature for the GraphQL composable arguments and return types.
|
|
8
|
+
*/
|
|
9
|
+
ComposableContext = "nuxt-graphql-middleware.d.ts",
|
|
10
|
+
/**
|
|
11
|
+
* Exports a single opject containing the compiled queries and mutations.
|
|
12
|
+
*/
|
|
13
|
+
Documents = "graphql-documents.mjs"
|
|
14
|
+
}
|
|
15
|
+
export declare enum GraphqlMiddlewareOperation {
|
|
16
|
+
Query = "query",
|
|
17
|
+
Mutation = "mutation"
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var GraphqlMiddlewareTemplate = /* @__PURE__ */ ((GraphqlMiddlewareTemplate2) => {
|
|
2
|
+
GraphqlMiddlewareTemplate2["OperationTypes"] = "graphql-operations.d.ts";
|
|
3
|
+
GraphqlMiddlewareTemplate2["ComposableContext"] = "nuxt-graphql-middleware.d.ts";
|
|
4
|
+
GraphqlMiddlewareTemplate2["Documents"] = "graphql-documents.mjs";
|
|
5
|
+
return GraphqlMiddlewareTemplate2;
|
|
6
|
+
})(GraphqlMiddlewareTemplate || {});
|
|
7
|
+
export var GraphqlMiddlewareOperation = /* @__PURE__ */ ((GraphqlMiddlewareOperation2) => {
|
|
8
|
+
GraphqlMiddlewareOperation2["Query"] = "query";
|
|
9
|
+
GraphqlMiddlewareOperation2["Mutation"] = "mutation";
|
|
10
|
+
return GraphqlMiddlewareOperation2;
|
|
11
|
+
})(GraphqlMiddlewareOperation || {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-graphql-middleware",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
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
|
+
},
|
|
4
9
|
"license": "MIT",
|
|
5
10
|
"type": "module",
|
|
6
11
|
"exports": {
|
|
@@ -60,7 +65,7 @@
|
|
|
60
65
|
"strip-ansi": "^7.0.1",
|
|
61
66
|
"typedoc": "^0.23.21",
|
|
62
67
|
"typedoc-plugin-markdown": "^3.14.0",
|
|
63
|
-
"vitepress": "^1.0.0-alpha.
|
|
68
|
+
"vitepress": "^1.0.0-alpha.30",
|
|
64
69
|
"vitest": "^0.25.3"
|
|
65
70
|
}
|
|
66
71
|
}
|