@graphql-tools/executor-yoga 1.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/cjs/index.js +31 -0
- package/cjs/package.json +1 -0
- package/esm/index.js +27 -0
- package/package.json +60 -0
- package/typings/index.d.cts +3 -0
- package/typings/index.d.ts +3 -0
package/cjs/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useExecutor = void 0;
|
|
4
|
+
const wrap_1 = require("@graphql-tools/wrap");
|
|
5
|
+
const executor_envelop_1 = require("@graphql-tools/executor-envelop");
|
|
6
|
+
function useExecutor(executor) {
|
|
7
|
+
let schema;
|
|
8
|
+
return {
|
|
9
|
+
onPluginInit({ addPlugin }) {
|
|
10
|
+
addPlugin(
|
|
11
|
+
// @ts-expect-error TODO: fix typings
|
|
12
|
+
(0, executor_envelop_1.useExecutor)(executor));
|
|
13
|
+
},
|
|
14
|
+
onRequestParse() {
|
|
15
|
+
return {
|
|
16
|
+
async onRequestParseDone() {
|
|
17
|
+
if (!schema) {
|
|
18
|
+
schema = await (0, wrap_1.schemaFromExecutor)(executor);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
onEnveloped({ setSchema }) {
|
|
24
|
+
if (!schema) {
|
|
25
|
+
throw new Error(`You provide a promise of a schema but it hasn't been resolved yet. Make sure you use this plugin with GraphQL Yoga.`);
|
|
26
|
+
}
|
|
27
|
+
setSchema(schema);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.useExecutor = useExecutor;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { schemaFromExecutor } from '@graphql-tools/wrap';
|
|
2
|
+
import { useExecutor as useEnvelopExecutor } from '@graphql-tools/executor-envelop';
|
|
3
|
+
export function useExecutor(executor) {
|
|
4
|
+
let schema;
|
|
5
|
+
return {
|
|
6
|
+
onPluginInit({ addPlugin }) {
|
|
7
|
+
addPlugin(
|
|
8
|
+
// @ts-expect-error TODO: fix typings
|
|
9
|
+
useEnvelopExecutor(executor));
|
|
10
|
+
},
|
|
11
|
+
onRequestParse() {
|
|
12
|
+
return {
|
|
13
|
+
async onRequestParseDone() {
|
|
14
|
+
if (!schema) {
|
|
15
|
+
schema = await schemaFromExecutor(executor);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
onEnveloped({ setSchema }) {
|
|
21
|
+
if (!schema) {
|
|
22
|
+
throw new Error(`You provide a promise of a schema but it hasn't been resolved yet. Make sure you use this plugin with GraphQL Yoga.`);
|
|
23
|
+
}
|
|
24
|
+
setSchema(schema);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphql-tools/executor-yoga",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"graphql": "^15.2.0 || ^16.0.0",
|
|
8
|
+
"graphql-yoga": "^3.5.1"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@graphql-tools/wrap": "^9.3.5",
|
|
12
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
13
|
+
"tslib": "^2.3.1"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "ardatan/graphql-tools",
|
|
18
|
+
"directory": "packages/executors/yoga"
|
|
19
|
+
},
|
|
20
|
+
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"typings": "typings/index.d.ts",
|
|
25
|
+
"typescript": {
|
|
26
|
+
"definition": "typings/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./typings/index.d.cts",
|
|
33
|
+
"default": "./cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./typings/index.d.ts",
|
|
37
|
+
"default": "./esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"./*": {
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./typings/*.d.cts",
|
|
47
|
+
"default": "./cjs/*.js"
|
|
48
|
+
},
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./typings/*.d.ts",
|
|
51
|
+
"default": "./esm/*.js"
|
|
52
|
+
},
|
|
53
|
+
"default": {
|
|
54
|
+
"types": "./typings/*.d.ts",
|
|
55
|
+
"default": "./esm/*.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"./package.json": "./package.json"
|
|
59
|
+
}
|
|
60
|
+
}
|