@webiny/handler-graphql 0.0.0-unstable.ecd8734205 → 0.0.0-unstable.f6dc066313
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 +9 -5
- package/ResolverDecoration.d.ts +6 -0
- package/ResolverDecoration.js +19 -0
- package/ResolverDecoration.js.map +1 -0
- package/builtInTypes/AnyScalar.d.ts +1 -1
- package/builtInTypes/AnyScalar.js +4 -9
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.d.ts +1 -1
- package/builtInTypes/DateScalar.js +10 -13
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.d.ts +1 -1
- package/builtInTypes/DateTimeScalar.js +10 -13
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.d.ts +1 -1
- package/builtInTypes/DateTimeZScalar.js +10 -16
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/IconScalar.d.ts +10 -0
- package/builtInTypes/IconScalar.js +93 -0
- package/builtInTypes/IconScalar.js.map +1 -0
- package/builtInTypes/JsonScalar.d.ts +1 -1
- package/builtInTypes/JsonScalar.js +3 -8
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +48 -8
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.d.ts +1 -1
- package/builtInTypes/NumberScalar.js +14 -21
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +40 -18
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.d.ts +1 -1
- package/builtInTypes/TimeScalar.js +11 -17
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.d.ts +10 -9
- package/builtInTypes/index.js +11 -103
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.d.ts +3 -3
- package/createGraphQLHandler.js +43 -34
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +4 -2
- package/createGraphQLSchema.js +78 -45
- package/createGraphQLSchema.js.map +1 -1
- package/createRequestBody.d.ts +2 -0
- package/createRequestBody.js +26 -0
- package/createRequestBody.js.map +1 -0
- package/createResolverDecorator.d.ts +2 -0
- package/createResolverDecorator.js +5 -0
- package/createResolverDecorator.js.map +1 -0
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js +6 -11
- package/debugPlugins.js.map +1 -1
- package/errors.js +4 -10
- package/errors.js.map +1 -1
- package/exports/api/graphql.d.ts +2 -0
- package/exports/api/graphql.js +4 -0
- package/exports/api/graphql.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.d.ts +16 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js +64 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaBuilder.js.map +1 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.d.ts +13 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js +29 -0
- package/features/GraphQLSchemaBuilder/GraphQLSchemaComposer.js.map +1 -0
- package/features/GraphQLSchemaBuilder/abstractions.d.ts +34 -0
- package/features/GraphQLSchemaBuilder/abstractions.js +5 -0
- package/features/GraphQLSchemaBuilder/abstractions.js.map +1 -0
- package/features/GraphQLSchemaBuilder/feature.d.ts +1 -0
- package/features/GraphQLSchemaBuilder/feature.js +10 -0
- package/features/GraphQLSchemaBuilder/feature.js.map +1 -0
- package/graphql/abstractions.core.d.ts +11 -0
- package/graphql/abstractions.core.js +10 -0
- package/graphql/abstractions.core.js.map +1 -0
- package/graphql/abstractions.d.ts +2 -0
- package/graphql/abstractions.js +4 -0
- package/graphql/abstractions.js.map +1 -0
- package/graphql/abstractions.public.d.ts +19 -0
- package/graphql/abstractions.public.js +12 -0
- package/graphql/abstractions.public.js.map +1 -0
- package/index.d.ts +10 -5
- package/index.js +12 -46
- package/index.js.map +1 -1
- package/interceptConsole.js +8 -13
- package/interceptConsole.js.map +1 -1
- package/package.json +23 -26
- package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
- package/plugins/GraphQLSchemaPlugin.js +16 -14
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +2 -15
- package/plugins/index.js.map +1 -1
- package/processRequestBody.d.ts +4 -5
- package/processRequestBody.js +15 -13
- package/processRequestBody.js.map +1 -1
- package/responses.js +7 -28
- package/responses.js.map +1 -1
- package/types.d.ts +20 -13
- package/types.js +2 -4
- package/types.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +3 -0
- package/utils/index.js.map +1 -0
- package/utils/resolve.d.ts +21 -0
- package/utils/resolve.js +19 -0
- package/utils/resolve.js.map +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains abstraction for use by third party developers.
|
|
3
|
+
*/
|
|
4
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* GraphQLSchemaFactory
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const GraphQLSchemaFactory = createAbstraction("GraphQLSchemaFactory");
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=abstractions.public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GraphQLSchemaFactory"],"sources":["abstractions.public.ts"],"sourcesContent":["/**\n * This file contains abstraction for use by third party developers.\n */\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n Resolvers as IResolvers,\n TypeDefs as ITypeDefs,\n ResolverDecorators as IResolverDecorators\n} from \"~/types.js\";\nimport type { GraphQLSchemaBuilder } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport interface IGraphQLSchema {\n typeDefs?: ITypeDefs;\n resolvers?: IResolvers<any>;\n resolverDecorators?: IResolverDecorators;\n}\n\n/**\n * GraphQLSchemaFactory\n */\nexport interface IGraphQLSchemaFactory {\n execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;\n}\n\nexport const GraphQLSchemaFactory =\n createAbstraction<IGraphQLSchemaFactory>(\"GraphQLSchemaFactory\");\n\nexport namespace GraphQLSchemaFactory {\n export type Interface = IGraphQLSchemaFactory;\n export type SchemaBuilder = GraphQLSchemaBuilder.Interface;\n export type Return = Promise<GraphQLSchemaBuilder.Interface>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAcvD;AACA;AACA;;AAKA,OAAO,MAAMC,oBAAoB,GAC7BD,iBAAiB,CAAwB,sBAAsB,CAAC","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
|
+
import type { HandlerGraphQLOptions } from "./types.js";
|
|
3
|
+
export * from "./errors.js";
|
|
4
|
+
export * from "./responses.js";
|
|
5
|
+
export * from "./utils/index.js";
|
|
6
|
+
export * from "./plugins/index.js";
|
|
7
|
+
export * from "./processRequestBody.js";
|
|
8
|
+
export * from "./createResolverDecorator.js";
|
|
9
|
+
export * from "./ResolverDecoration.js";
|
|
10
|
+
declare const _default: (options?: HandlerGraphQLOptions) => Plugin[];
|
|
6
11
|
export default _default;
|
package/index.js
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import createGraphQLHandler from "./createGraphQLHandler.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./responses.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
export * from "./plugins/index.js";
|
|
6
|
+
export * from "./processRequestBody.js";
|
|
7
|
+
export * from "./createResolverDecorator.js";
|
|
8
|
+
export * from "./ResolverDecoration.js";
|
|
9
|
+
export default (options = {}) => {
|
|
10
|
+
return createGraphQLHandler(options);
|
|
11
|
+
};
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {};
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
|
|
10
|
-
var _errors = require("./errors");
|
|
11
|
-
Object.keys(_errors).forEach(function (key) {
|
|
12
|
-
if (key === "default" || key === "__esModule") return;
|
|
13
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
-
if (key in exports && exports[key] === _errors[key]) return;
|
|
15
|
-
Object.defineProperty(exports, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return _errors[key];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
var _responses = require("./responses");
|
|
23
|
-
Object.keys(_responses).forEach(function (key) {
|
|
24
|
-
if (key === "default" || key === "__esModule") return;
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
-
if (key in exports && exports[key] === _responses[key]) return;
|
|
27
|
-
Object.defineProperty(exports, key, {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () {
|
|
30
|
-
return _responses[key];
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
var _plugins = require("./plugins");
|
|
35
|
-
Object.keys(_plugins).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
-
if (key in exports && exports[key] === _plugins[key]) return;
|
|
39
|
-
Object.defineProperty(exports, key, {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return _plugins[key];
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
|
|
47
|
-
exports.default = _default;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createGraphQLHandler","options"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { HandlerGraphQLOptions } from \"./types.js\";\nimport createGraphQLHandler from \"./createGraphQLHandler.js\";\n\nexport * from \"./errors.js\";\nexport * from \"./responses.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./processRequestBody.js\";\nexport * from \"./createResolverDecorator.js\";\nexport * from \"./ResolverDecoration.js\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":"AAEA,OAAOA,oBAAoB;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,eAAe,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAOD,oBAAoB,CAACC,OAAO,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/interceptConsole.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.interceptConsole = void 0;
|
|
7
1
|
const consoleMethods = ["assert", "debug", "dir", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "warn"];
|
|
8
2
|
const originalMethods = {};
|
|
9
3
|
const skipOriginal = ["table"];
|
|
10
4
|
const restoreOriginalMethods = () => {
|
|
11
5
|
for (const method of consoleMethods) {
|
|
12
|
-
// @ts-
|
|
6
|
+
// @ts-expect-error
|
|
13
7
|
console[method] = originalMethods[method];
|
|
14
8
|
}
|
|
15
9
|
};
|
|
16
|
-
const interceptConsole = callback => {
|
|
17
|
-
// @ts-
|
|
10
|
+
export const interceptConsole = callback => {
|
|
11
|
+
// @ts-expect-error
|
|
18
12
|
if (console["__WEBINY__"] === true) {
|
|
19
13
|
restoreOriginalMethods();
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
// @ts-
|
|
16
|
+
// @ts-expect-error
|
|
23
17
|
console["__WEBINY__"] = true;
|
|
24
18
|
for (const method of consoleMethods) {
|
|
25
|
-
// @ts-
|
|
19
|
+
// @ts-expect-error
|
|
26
20
|
originalMethods[method] = console[method];
|
|
27
|
-
// @ts-
|
|
21
|
+
// @ts-expect-error
|
|
28
22
|
console[method] = (...args) => {
|
|
29
23
|
callback(method, args);
|
|
30
24
|
if (skipOriginal.includes(method)) {
|
|
@@ -34,4 +28,5 @@ const interceptConsole = callback => {
|
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
30
|
};
|
|
37
|
-
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=interceptConsole.js.map
|
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-
|
|
1
|
+
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-expect-error\n console[method] = originalMethods[method];\n }\n};\n\ninterface InterceptConsoleCallable {\n (method: string, args: any[]): void;\n}\n\nexport const interceptConsole = (callback: InterceptConsoleCallable) => {\n // @ts-expect-error\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-expect-error\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-expect-error\n originalMethods[method] = console[method];\n // @ts-expect-error\n console[method] = (...args) => {\n callback(method, args);\n if (skipOriginal.includes(method)) {\n return;\n }\n originalMethods[method](...args);\n };\n }\n};\n"],"mappings":"AAAA,MAAMA,cAAc,GAAG,CACnB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,CACT;AAED,MAAMC,eAAoC,GAAG,CAAC,CAAC;AAC/C,MAAMC,YAAsB,GAAG,CAAC,OAAO,CAAC;AAExC,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACjC,KAAK,MAAMC,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAK,OAAO,CAACD,MAAM,CAAC,GAAGH,eAAe,CAACG,MAAM,CAAC;EAC7C;AACJ,CAAC;AAMD,OAAO,MAAME,gBAAgB,GAAIC,QAAkC,IAAK;EACpE;EACA,IAAIF,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE;IAChCF,sBAAsB,CAAC,CAAC;EAC5B;;EAEA;EACAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;EAE5B,KAAK,MAAMD,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAC,eAAe,CAACG,MAAM,CAAC,GAAGC,OAAO,CAACD,MAAM,CAAC;IACzC;IACAC,OAAO,CAACD,MAAM,CAAC,GAAG,CAAC,GAAGI,IAAI,KAAK;MAC3BD,QAAQ,CAACH,MAAM,EAAEI,IAAI,CAAC;MACtB,IAAIN,YAAY,CAACO,QAAQ,CAACL,MAAM,CAAC,EAAE;QAC/B;MACJ;MACAH,eAAe,CAACG,MAAM,CAAC,CAAC,GAAGI,IAAI,CAAC;IACpC,CAAC;EACL;AACJ,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.f6dc066313",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
@@ -14,37 +15,33 @@
|
|
|
14
15
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
16
|
],
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@graphql-tools/
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
18
|
+
"@graphql-tools/merge": "9.1.7",
|
|
19
|
+
"@graphql-tools/resolvers-composition": "7.0.26",
|
|
20
|
+
"@graphql-tools/schema": "10.0.31",
|
|
21
|
+
"@graphql-tools/utils": "11.0.0",
|
|
22
|
+
"@webiny/api": "0.0.0-unstable.f6dc066313",
|
|
23
|
+
"@webiny/di": "0.2.3",
|
|
24
|
+
"@webiny/error": "0.0.0-unstable.f6dc066313",
|
|
25
|
+
"@webiny/feature": "0.0.0-unstable.f6dc066313",
|
|
26
|
+
"@webiny/handler": "0.0.0-unstable.f6dc066313",
|
|
27
|
+
"@webiny/plugins": "0.0.0-unstable.f6dc066313",
|
|
28
|
+
"@webiny/utils": "0.0.0-unstable.f6dc066313",
|
|
23
29
|
"boolean": "3.2.0",
|
|
24
|
-
"graphql": "
|
|
25
|
-
"graphql-scalars": "1.
|
|
26
|
-
"graphql-tag": "2.12.6"
|
|
30
|
+
"graphql": "16.13.0",
|
|
31
|
+
"graphql-scalars": "1.25.0",
|
|
32
|
+
"graphql-tag": "2.12.6",
|
|
33
|
+
"zod": "3.25.76"
|
|
27
34
|
},
|
|
28
35
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"@webiny/project-utils": "^0.0.0-unstable.ecd8734205",
|
|
35
|
-
"jest": "^28.1.0",
|
|
36
|
-
"jest-mock-console": "^1.0.0",
|
|
37
|
-
"rimraf": "^3.0.2",
|
|
38
|
-
"ttypescript": "^1.5.13",
|
|
39
|
-
"typescript": "4.7.4"
|
|
36
|
+
"@webiny/build-tools": "0.0.0-unstable.f6dc066313",
|
|
37
|
+
"@webiny/handler-aws": "0.0.0-unstable.f6dc066313",
|
|
38
|
+
"rimraf": "6.1.3",
|
|
39
|
+
"typescript": "5.9.3",
|
|
40
|
+
"vitest": "4.0.18"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public",
|
|
43
44
|
"directory": "dist"
|
|
44
45
|
},
|
|
45
|
-
"
|
|
46
|
-
"build": "yarn webiny run build",
|
|
47
|
-
"watch": "yarn webiny run watch"
|
|
48
|
-
},
|
|
49
|
-
"gitHead": "ecd8734205e0e21ae04076c28ff9806dad07a730"
|
|
46
|
+
"gitHead": "f6dc066313ddce5339d2aacec3aa84e61232689b"
|
|
50
47
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Context } from "@webiny/api/types.js";
|
|
1
2
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { GraphQLSchemaDefinition, Resolvers,
|
|
3
|
-
|
|
3
|
+
import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types.js";
|
|
4
|
+
export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
5
|
+
schema: GraphQLSchemaDefinition<TContext>;
|
|
6
|
+
isApplicable: (context: TContext) => boolean;
|
|
7
|
+
}
|
|
4
8
|
export interface GraphQLSchemaPluginConfig<TContext> {
|
|
5
|
-
typeDefs?:
|
|
9
|
+
typeDefs?: TypeDefs;
|
|
6
10
|
resolvers?: Resolvers<TContext>;
|
|
11
|
+
resolverDecorators?: ResolverDecorators;
|
|
12
|
+
isApplicable?: (context: TContext) => boolean;
|
|
7
13
|
}
|
|
8
|
-
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
14
|
+
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin implements IGraphQLSchemaPlugin<TContext> {
|
|
9
15
|
static readonly type: string;
|
|
10
|
-
|
|
16
|
+
protected config: GraphQLSchemaPluginConfig<TContext>;
|
|
11
17
|
constructor(config: GraphQLSchemaPluginConfig<TContext>);
|
|
12
18
|
get schema(): GraphQLSchemaDefinition<TContext>;
|
|
19
|
+
isApplicable(context: TContext): boolean;
|
|
13
20
|
}
|
|
21
|
+
export declare const createGraphQLSchemaPlugin: <T = Context>(config: GraphQLSchemaPluginConfig<T>) => GraphQLSchemaPlugin<T>;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.GraphQLSchemaPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _plugins = require("@webiny/plugins");
|
|
10
|
-
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
export class GraphQLSchemaPlugin extends Plugin {
|
|
3
|
+
static type = "graphql-schema";
|
|
11
4
|
constructor(config) {
|
|
12
5
|
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "config", void 0);
|
|
14
6
|
this.config = config;
|
|
15
7
|
}
|
|
16
8
|
get schema() {
|
|
17
9
|
return {
|
|
18
10
|
typeDefs: this.config.typeDefs || "",
|
|
19
|
-
resolvers: this.config.resolvers
|
|
11
|
+
resolvers: this.config.resolvers,
|
|
12
|
+
resolverDecorators: this.config.resolverDecorators
|
|
20
13
|
};
|
|
21
14
|
}
|
|
15
|
+
isApplicable(context) {
|
|
16
|
+
if (this.config.isApplicable) {
|
|
17
|
+
return this.config.isApplicable(context);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export const createGraphQLSchemaPlugin = config => {
|
|
23
|
+
return new GraphQLSchemaPlugin(config);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GraphQLSchemaPlugin","
|
|
1
|
+
{"version":3,"names":["Plugin","GraphQLSchemaPlugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types.js\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types.js\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers,\n resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,iBAAiB;AAexC,OAAO,MAAMC,mBAAmB,SACpBD,MAAM,CAElB;EACI,OAAgCE,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG,SAAS;MAChCC,kBAAkB,EAAE,IAAI,CAACJ,MAAM,CAACI;IACpC,CAAC;EACL;EAEAC,YAAYA,CAACC,OAAiB,EAAW;IACrC,IAAI,IAAI,CAACN,MAAM,CAACK,YAAY,EAAE;MAC1B,OAAO,IAAI,CAACL,MAAM,CAACK,YAAY,CAACC,OAAO,CAAC;IAC5C;IACA,OAAO,IAAI;EACf;AACJ;AAEA,OAAO,MAAMC,yBAAyB,GAAiBP,MAAoC,IAAK;EAC5F,OAAO,IAAIH,mBAAmB,CAAIG,MAAM,CAAC;AAC7C,CAAC","ignoreList":[]}
|
package/plugins/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./GraphQLSchemaPlugin";
|
|
1
|
+
export * from "./GraphQLSchemaPlugin.js";
|
package/plugins/index.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "./GraphQLSchemaPlugin.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _GraphQLSchemaPlugin = require("./GraphQLSchemaPlugin");
|
|
7
|
-
Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _GraphQLSchemaPlugin[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _GraphQLSchemaPlugin[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
package/processRequestBody.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
|
-
import { GraphQLRequestBody } from "./types";
|
|
3
|
-
import { Context } from "@webiny/api/types";
|
|
4
|
-
declare const
|
|
5
|
-
export default _default;
|
|
1
|
+
import type { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { GraphQLRequestBody } from "./types.js";
|
|
3
|
+
import type { Context } from "@webiny/api/types.js";
|
|
4
|
+
export declare const processRequestBody: <TData = Record<string, any>, TExtensions = Record<string, any>>(requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>>;
|
package/processRequestBody.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _graphql = require("graphql");
|
|
8
|
-
const processRequestBody = async (body, schema, context) => {
|
|
1
|
+
import { graphql } from "graphql";
|
|
2
|
+
const executeGraphQl = async (body, schema, context) => {
|
|
9
3
|
const {
|
|
10
4
|
query,
|
|
11
5
|
variables,
|
|
@@ -16,7 +10,14 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
16
10
|
schema,
|
|
17
11
|
context
|
|
18
12
|
}));
|
|
19
|
-
const result = await
|
|
13
|
+
const result = await graphql({
|
|
14
|
+
schema,
|
|
15
|
+
source: query,
|
|
16
|
+
rootValue: {},
|
|
17
|
+
contextValue: context,
|
|
18
|
+
variableValues: variables,
|
|
19
|
+
operationName
|
|
20
|
+
});
|
|
20
21
|
context.plugins.byType("graphql-after-query").forEach(pl => {
|
|
21
22
|
pl.apply({
|
|
22
23
|
result,
|
|
@@ -27,15 +28,16 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
27
28
|
});
|
|
28
29
|
return result;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
+
export const processRequestBody = async (requestBody, schema, context) => {
|
|
31
32
|
if (Array.isArray(requestBody)) {
|
|
32
33
|
const results = [];
|
|
33
34
|
for (const body of requestBody) {
|
|
34
|
-
const result = await
|
|
35
|
+
const result = await executeGraphQl(body, schema, context);
|
|
35
36
|
results.push(result);
|
|
36
37
|
}
|
|
37
38
|
return results;
|
|
38
39
|
}
|
|
39
|
-
return await
|
|
40
|
+
return await executeGraphQl(requestBody, schema, context);
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=processRequestBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["graphql","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push"],"sources":["processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\n const { query, variables, operationName } = body;\n\n context.plugins\n .byType<GraphQLBeforeQueryPlugin>(\"graphql-before-query\")\n .forEach(pl => pl.apply({ body, schema, context }));\n\n const result = await graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\n};\n\nexport const processRequestBody = async <\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n>(\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult<TData, TExtensions>[] = [];\n for (const body of requestBody) {\n const result = await executeGraphQl<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,SAAS;AAQjC,MAAMC,cAAc,GAAG,MAAAA,CACnBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,MAAM;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGL,IAAI;EAEhDE,OAAO,CAACI,OAAO,CACVC,MAAM,CAA2B,sBAAsB,CAAC,CACxDC,OAAO,CAACC,EAAE,IAAIA,EAAE,CAACC,KAAK,CAAC;IAAEV,IAAI;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC,CAAC;EAEvD,MAAMS,MAAM,GAAG,MAAMb,OAAO,CAAC;IACzBG,MAAM;IACNW,MAAM,EAAET,KAAK;IACbU,SAAS,EAAE,CAAC,CAAC;IACbC,YAAY,EAAEZ,OAAO;IACrBa,cAAc,EAAEX,SAAS;IACzBC;EACJ,CAAC,CAAC;EAEFH,OAAO,CAACI,OAAO,CAACC,MAAM,CAA0B,qBAAqB,CAAC,CAACC,OAAO,CAACC,EAAE,IAAI;IACjFA,EAAE,CAACC,KAAK,CAAC;MAAEC,MAAM;MAAEX,IAAI;MAAEC,MAAM;MAAEC;IAAQ,CAAC,CAAC;EAC/C,CAAC,CAAC;EAEF,OAAOS,MAAM;AACjB,CAAC;AAED,OAAO,MAAMK,kBAAkB,GAAG,MAAAA,CAI9BC,WAAsD,EACtDhB,MAAqB,EACrBC,OAAgB,KACuE;EACvF,IAAIgB,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA8C,GAAG,EAAE;IACzD,KAAK,MAAMpB,IAAI,IAAIiB,WAAW,EAAE;MAC5B,MAAMN,MAAM,GAAG,MAAMZ,cAAc,CAAqBC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC9EkB,OAAO,CAACC,IAAI,CAACV,MAAM,CAAC;IACxB;IACA,OAAOS,OAAO;EAClB;EACA,OAAO,MAAMrB,cAAc,CAAqBkB,WAAW,EAAEhB,MAAM,EAAEC,OAAO,CAAC;AACjF,CAAC","ignoreList":[]}
|
package/responses.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
1
|
const defaultParams = {
|
|
10
2
|
code: "",
|
|
11
3
|
message: "",
|
|
12
4
|
data: null,
|
|
13
5
|
stack: null
|
|
14
6
|
};
|
|
15
|
-
class ErrorResponse {
|
|
7
|
+
export class ErrorResponse {
|
|
16
8
|
constructor(params) {
|
|
17
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
18
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
19
9
|
this.data = null;
|
|
20
10
|
const debug = process.env.DEBUG === "true";
|
|
21
11
|
|
|
@@ -32,8 +22,7 @@ class ErrorResponse {
|
|
|
32
22
|
};
|
|
33
23
|
}
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
class NotFoundResponse extends ErrorResponse {
|
|
25
|
+
export class NotFoundResponse extends ErrorResponse {
|
|
37
26
|
constructor(message) {
|
|
38
27
|
super({
|
|
39
28
|
code: "NOT_FOUND",
|
|
@@ -41,12 +30,8 @@ class NotFoundResponse extends ErrorResponse {
|
|
|
41
30
|
});
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
|
|
45
|
-
class ListErrorResponse {
|
|
33
|
+
export class ListErrorResponse {
|
|
46
34
|
constructor(params) {
|
|
47
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
48
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
49
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
50
35
|
this.meta = null;
|
|
51
36
|
this.data = null;
|
|
52
37
|
const debug = process.env.DEBUG === "true";
|
|
@@ -64,24 +49,18 @@ class ListErrorResponse {
|
|
|
64
49
|
};
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
|
-
|
|
68
|
-
class Response {
|
|
52
|
+
export class Response {
|
|
69
53
|
constructor(data) {
|
|
70
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
71
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
72
54
|
this.data = data;
|
|
73
55
|
this.error = null;
|
|
74
56
|
}
|
|
75
57
|
}
|
|
76
|
-
|
|
77
|
-
class ListResponse {
|
|
58
|
+
export class ListResponse {
|
|
78
59
|
constructor(data, meta) {
|
|
79
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
80
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
81
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
82
60
|
this.data = Array.isArray(data) ? data : [];
|
|
83
61
|
this.meta = meta || {};
|
|
84
62
|
this.error = null;
|
|
85
63
|
}
|
|
86
64
|
}
|
|
87
|
-
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=responses.js.map
|
package/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":"AAOA,MAAMA,aAA4C,GAAG;EACjDC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE;AACX,CAAC;AAED,OAAO,MAAMC,aAAa,CAAC;EASvBC,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACJ,IAAI,GAAG,IAAI;IAEhB,MAAMK,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIP,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAII,KAAK,IAAID,MAAM,CAACH,KAAK,EAAE;MACvBA,KAAK,GAAGG,MAAM,CAACH,KAAK;IACxB;IAEA,IAAI,CAACQ,KAAK,GAAG;MACTX,IAAI,EAAEM,MAAM,CAACN,IAAI,IAAID,aAAa,CAACC,IAAI;MACvCC,OAAO,EAAEK,MAAM,CAACL,OAAO,IAAIF,aAAa,CAACE,OAAO;MAChDC,IAAI,EAAEI,MAAM,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAEA,OAAO,MAAMS,gBAAgB,SAASR,aAAa,CAAC;EAChDC,WAAWA,CAACJ,OAAe,EAAE;IACzB,KAAK,CAAC;MACFD,IAAI,EAAE,WAAW;MACjBC;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMY,iBAAiB,CAAC;EAU3BR,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACQ,IAAI,GAAG,IAAI;IAChB,IAAI,CAACZ,IAAI,GAAG,IAAI;IAEhB,MAAMK,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIP,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAII,KAAK,IAAID,MAAM,CAACH,KAAK,EAAE;MACvBA,KAAK,GAAGG,MAAM,CAACH,KAAK;IACxB;IAEA,IAAI,CAACQ,KAAK,GAAG;MACTX,IAAI,EAAEM,MAAM,CAACN,IAAI,IAAID,aAAa,CAACC,IAAI;MACvCC,OAAO,EAAEK,MAAM,CAACL,OAAO,IAAIF,aAAa,CAACE,OAAO;MAChDC,IAAI,EAAEI,MAAM,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAEA,OAAO,MAAMY,QAAQ,CAAU;EAI3BV,WAAWA,CAACH,IAAO,EAAE;IACjB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACS,KAAK,GAAG,IAAI;EACrB;AACJ;AAEA,OAAO,MAAMK,YAAY,CAAO;EAK5BX,WAAWA,CAACH,IAAc,EAAEY,IAAQ,EAAE;IAClC,IAAI,CAACZ,IAAI,GAAGe,KAAK,CAACC,OAAO,CAAChB,IAAI,CAAC,GAAGA,IAAI,GAAG,EAAE;IAC3C,IAAI,CAACY,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACH,KAAK,GAAG,IAAI;EACrB;AACJ","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
-
import { Context } from "@webiny/api/types";
|
|
4
|
-
import { RouteMethodPath } from "@webiny/handler/types";
|
|
1
|
+
import type { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { Plugin } from "@webiny/plugins/types.js";
|
|
3
|
+
import type { Context, GenericRecord } from "@webiny/api/types.js";
|
|
4
|
+
import type { RouteMethodPath } from "@webiny/handler/types.js";
|
|
5
|
+
import type { ResolversComposition } from "@graphql-tools/resolvers-composition";
|
|
6
|
+
import type { IResolvers, TypeSource } from "@graphql-tools/utils";
|
|
5
7
|
export interface GraphQLScalarPlugin extends Plugin {
|
|
6
8
|
type: "graphql-scalar";
|
|
7
9
|
scalar: GraphQLScalarType;
|
|
@@ -10,19 +12,24 @@ export interface HandlerGraphQLOptions {
|
|
|
10
12
|
path?: RouteMethodPath;
|
|
11
13
|
debug?: boolean | string;
|
|
12
14
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
+
export type GraphQLFieldResolver<TSource = any, TArgs = any, TContext = Context> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `TypeDefs` instead.
|
|
18
|
+
*/
|
|
19
|
+
export type Types = TypeDefs;
|
|
20
|
+
export type TypeDefs = TypeSource;
|
|
15
21
|
export interface GraphQLSchemaPluginTypeArgs {
|
|
16
22
|
context?: any;
|
|
17
23
|
args?: any;
|
|
18
24
|
source?: any;
|
|
19
25
|
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export interface GraphQLSchemaDefinition<TContext> {
|
|
24
|
-
typeDefs:
|
|
26
|
+
export type Resolvers<TContext> = IResolvers<any, TContext>;
|
|
27
|
+
export type ResolverDecorator<TSource = any, TContext = any, TArgs = any> = ResolversComposition<GraphQLFieldResolver<TSource, TContext, TArgs>>;
|
|
28
|
+
export type ResolverDecorators = GenericRecord<string, ResolverDecorator[]>;
|
|
29
|
+
export interface GraphQLSchemaDefinition<TContext = any> {
|
|
30
|
+
typeDefs: TypeDefs;
|
|
25
31
|
resolvers?: Resolvers<TContext>;
|
|
32
|
+
resolverDecorators?: ResolverDecorators;
|
|
26
33
|
}
|
|
27
34
|
export interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {
|
|
28
35
|
type: "graphql-schema";
|
|
@@ -30,8 +37,8 @@ export interface GraphQLSchemaPlugin<TContext extends Context = Context> extends
|
|
|
30
37
|
}
|
|
31
38
|
export interface GraphQLRequestBody {
|
|
32
39
|
query: string;
|
|
33
|
-
variables
|
|
34
|
-
operationName
|
|
40
|
+
variables?: Record<string, any> | null;
|
|
41
|
+
operationName?: string;
|
|
35
42
|
}
|
|
36
43
|
export interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {
|
|
37
44
|
type: "graphql-before-query";
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { Context, GenericRecord } from \"@webiny/api/types.js\";\nimport type { RouteMethodPath } from \"@webiny/handler/types.js\";\nimport type { ResolversComposition } from \"@graphql-tools/resolvers-composition\";\nimport type { IResolvers, TypeSource } from \"@graphql-tools/utils\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n/**\n * @deprecated Use `TypeDefs` instead.\n */\nexport type Types = TypeDefs;\nexport type TypeDefs = TypeSource;\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> = IResolvers<any, TContext>;\n\nexport type ResolverDecorator<TSource = any, TContext = any, TArgs = any> = ResolversComposition<\n GraphQLFieldResolver<TSource, TContext, TArgs>\n>;\n\nexport type ResolverDecorators = GenericRecord<string, ResolverDecorator[]>;\n\nexport interface GraphQLSchemaDefinition<TContext = any> {\n typeDefs: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables?: Record<string, any> | null;\n operationName?: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":"","ignoreList":[]}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./resolve.js";
|
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./resolve.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|