@webiny/handler-graphql 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a

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.
Files changed (55) hide show
  1. package/ResolverDecoration.d.ts +6 -0
  2. package/ResolverDecoration.js +26 -0
  3. package/ResolverDecoration.js.map +1 -0
  4. package/builtInTypes/AnyScalar.js +1 -2
  5. package/builtInTypes/AnyScalar.js.map +1 -1
  6. package/builtInTypes/DateScalar.js +1 -2
  7. package/builtInTypes/DateScalar.js.map +1 -1
  8. package/builtInTypes/DateTimeScalar.js +1 -2
  9. package/builtInTypes/DateTimeScalar.js.map +1 -1
  10. package/builtInTypes/DateTimeZScalar.js +1 -2
  11. package/builtInTypes/DateTimeZScalar.js.map +1 -1
  12. package/builtInTypes/JsonScalar.js +1 -2
  13. package/builtInTypes/JsonScalar.js.map +1 -1
  14. package/builtInTypes/LongScalar.js +1 -2
  15. package/builtInTypes/LongScalar.js.map +1 -1
  16. package/builtInTypes/NumberScalar.js +1 -2
  17. package/builtInTypes/NumberScalar.js.map +1 -1
  18. package/builtInTypes/RefInputScalar.js +1 -2
  19. package/builtInTypes/RefInputScalar.js.map +1 -1
  20. package/builtInTypes/TimeScalar.js +1 -2
  21. package/builtInTypes/TimeScalar.js.map +1 -1
  22. package/builtInTypes/index.js.map +1 -1
  23. package/createGraphQLHandler.d.ts +3 -3
  24. package/createGraphQLHandler.js +9 -2
  25. package/createGraphQLHandler.js.map +1 -1
  26. package/createGraphQLSchema.d.ts +3 -3
  27. package/createGraphQLSchema.js +33 -11
  28. package/createGraphQLSchema.js.map +1 -1
  29. package/createResolverDecorator.d.ts +2 -0
  30. package/createResolverDecorator.js +12 -0
  31. package/createResolverDecorator.js.map +1 -0
  32. package/debugPlugins.d.ts +2 -2
  33. package/debugPlugins.js.map +1 -1
  34. package/errors.js.map +1 -1
  35. package/index.d.ts +7 -3
  36. package/index.js +52 -11
  37. package/index.js.map +1 -1
  38. package/interceptConsole.js.map +1 -1
  39. package/package.json +19 -22
  40. package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
  41. package/plugins/GraphQLSchemaPlugin.js +13 -2
  42. package/plugins/GraphQLSchemaPlugin.js.map +1 -1
  43. package/plugins/index.js.map +1 -1
  44. package/processRequestBody.d.ts +4 -5
  45. package/processRequestBody.js +14 -7
  46. package/processRequestBody.js.map +1 -1
  47. package/responses.js.map +1 -1
  48. package/types.d.ts +17 -10
  49. package/types.js.map +1 -1
  50. package/utils/index.d.ts +1 -0
  51. package/utils/index.js +18 -0
  52. package/utils/index.js.map +1 -0
  53. package/utils/resolve.d.ts +21 -0
  54. package/utils/resolve.js +28 -0
  55. package/utils/resolve.js.map +1 -0
package/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","NotFoundError","WebinyError","constructor","message","exports"],"sources":["errors.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport class NotFoundError extends WebinyError {\n constructor(message = \"Not found.\") {\n super(message, \"NOT_FOUND\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,aAAa,SAASC,cAAW,CAAC;EAC3CC,WAAWA,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","NotFoundError","WebinyError","constructor","message","exports"],"sources":["errors.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport class NotFoundError extends WebinyError {\n constructor(message = \"Not found.\") {\n super(message, \"NOT_FOUND\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,aAAa,SAASC,cAAW,CAAC;EAC3CC,WAAWA,CAACC,OAAO,GAAG,YAAY,EAAE;IAChC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { HandlerGraphQLOptions } from "./types";
1
+ import type { Plugin } from "@webiny/plugins/types";
2
+ import type { HandlerGraphQLOptions } from "./types";
2
3
  export * from "./errors";
3
4
  export * from "./responses";
5
+ export * from "./utils";
4
6
  export * from "./plugins";
5
- export { default as processRequestBody } from "./processRequestBody";
6
- declare const _default: (options?: HandlerGraphQLOptions) => import("@webiny/plugins/types").PluginCollection[];
7
+ export * from "./processRequestBody";
8
+ export * from "./createResolverDecorator";
9
+ export * from "./ResolverDecoration";
10
+ declare const _default: (options?: HandlerGraphQLOptions) => Plugin[];
7
11
  export default _default;
package/index.js CHANGED
@@ -4,16 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- var _exportNames = {
8
- processRequestBody: true
9
- };
7
+ var _exportNames = {};
10
8
  exports.default = void 0;
11
- Object.defineProperty(exports, "processRequestBody", {
12
- enumerable: true,
13
- get: function () {
14
- return _processRequestBody.default;
15
- }
16
- });
17
9
  var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
18
10
  var _errors = require("./errors");
19
11
  Object.keys(_errors).forEach(function (key) {
@@ -39,6 +31,18 @@ Object.keys(_responses).forEach(function (key) {
39
31
  }
40
32
  });
41
33
  });
34
+ var _utils = require("./utils");
35
+ Object.keys(_utils).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] === _utils[key]) return;
39
+ Object.defineProperty(exports, key, {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _utils[key];
43
+ }
44
+ });
45
+ });
42
46
  var _plugins = require("./plugins");
43
47
  Object.keys(_plugins).forEach(function (key) {
44
48
  if (key === "default" || key === "__esModule") return;
@@ -51,8 +55,45 @@ Object.keys(_plugins).forEach(function (key) {
51
55
  }
52
56
  });
53
57
  });
54
- var _processRequestBody = _interopRequireDefault(require("./processRequestBody"));
55
- var _default = (options = {}) => [(0, _createGraphQLHandler.default)(options)];
58
+ var _processRequestBody = require("./processRequestBody");
59
+ Object.keys(_processRequestBody).forEach(function (key) {
60
+ if (key === "default" || key === "__esModule") return;
61
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
62
+ if (key in exports && exports[key] === _processRequestBody[key]) return;
63
+ Object.defineProperty(exports, key, {
64
+ enumerable: true,
65
+ get: function () {
66
+ return _processRequestBody[key];
67
+ }
68
+ });
69
+ });
70
+ var _createResolverDecorator = require("./createResolverDecorator");
71
+ Object.keys(_createResolverDecorator).forEach(function (key) {
72
+ if (key === "default" || key === "__esModule") return;
73
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
74
+ if (key in exports && exports[key] === _createResolverDecorator[key]) return;
75
+ Object.defineProperty(exports, key, {
76
+ enumerable: true,
77
+ get: function () {
78
+ return _createResolverDecorator[key];
79
+ }
80
+ });
81
+ });
82
+ var _ResolverDecoration = require("./ResolverDecoration");
83
+ Object.keys(_ResolverDecoration).forEach(function (key) {
84
+ if (key === "default" || key === "__esModule") return;
85
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
86
+ if (key in exports && exports[key] === _ResolverDecoration[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _ResolverDecoration[key];
91
+ }
92
+ });
93
+ });
94
+ var _default = (options = {}) => {
95
+ return (0, _createGraphQLHandler.default)(options);
96
+ };
56
97
  exports.default = _default;
57
98
 
58
99
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_plugins","_processRequestBody","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\nexport { default as processRequestBody } from \"./processRequestBody\";\n\nexport default (options: HandlerGraphQLOptions = {}) => [createGraphQLHandler(options)];\n"],"mappings":";;;;;;;;;;;;;;;;AACA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,UAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,QAAA,GAAAf,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAY,QAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,QAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,QAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,mBAAA,GAAAjB,sBAAA,CAAAC,OAAA;AAAqE,IAAAiB,QAAA,GAEtDA,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,IAAAC,6BAAoB,EAACD,OAAO,CAAC,CAAC;AAAAR,OAAA,CAAAU,OAAA,GAAAH,QAAA"}
1
+ {"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_utils","_plugins","_processRequestBody","_createResolverDecorator","_ResolverDecoration","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport type { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./utils\";\nexport * from \"./plugins\";\nexport * from \"./processRequestBody\";\nexport * from \"./createResolverDecorator\";\nexport * from \"./ResolverDecoration\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,qBAAA,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AA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAa,wBAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,wBAAA,CAAAb,GAAA;IAAA;EAAA;AAAA;AACA,IAAAc,mBAAA,GAAAnB,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAgB,mBAAA,EAAAf,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAc,mBAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAM,mBAAA,CAAAd,GAAA;IAAA;EAAA;AAAA;AAAqC,IAAAe,QAAA,GAEtBA,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAO,IAAAC,6BAAoB,EAACD,OAAO,CAAC;AACxC,CAAC;AAAAX,OAAA,CAAAa,OAAA,GAAAH,QAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes","exports"],"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;AAMM,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;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes","exports"],"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;AAMM,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;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-graphql",
3
- "version": "0.0.0-unstable.de38392959",
3
+ "version": "0.0.0-unstable.e0bfc55d5a",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,37 +14,34 @@
14
14
  "Adrian Smijulj <adrian@webiny.com>"
15
15
  ],
16
16
  "dependencies": {
17
- "@babel/runtime": "7.22.6",
18
- "@graphql-tools/schema": "7.1.5",
19
- "@webiny/api": "0.0.0-unstable.de38392959",
20
- "@webiny/error": "0.0.0-unstable.de38392959",
21
- "@webiny/handler": "0.0.0-unstable.de38392959",
22
- "@webiny/plugins": "0.0.0-unstable.de38392959",
17
+ "@graphql-tools/merge": "9.0.8",
18
+ "@graphql-tools/resolvers-composition": "7.0.2",
19
+ "@graphql-tools/schema": "10.0.7",
20
+ "@graphql-tools/utils": "10.5.5",
21
+ "@webiny/api": "0.0.0-unstable.e0bfc55d5a",
22
+ "@webiny/error": "0.0.0-unstable.e0bfc55d5a",
23
+ "@webiny/handler": "0.0.0-unstable.e0bfc55d5a",
24
+ "@webiny/plugins": "0.0.0-unstable.e0bfc55d5a",
23
25
  "boolean": "3.2.0",
24
- "graphql": "15.8.0",
26
+ "graphql": "15.9.0",
25
27
  "graphql-scalars": "1.12.0",
26
28
  "graphql-tag": "2.12.6"
27
29
  },
28
30
  "devDependencies": {
29
- "@babel/cli": "7.22.6",
30
- "@babel/core": "7.22.8",
31
- "@babel/preset-env": "7.22.7",
32
- "@webiny/cli": "0.0.0-unstable.de38392959",
33
- "@webiny/handler-aws": "0.0.0-unstable.de38392959",
34
- "@webiny/project-utils": "0.0.0-unstable.de38392959",
35
- "jest": "29.5.0",
36
- "jest-mock-console": "1.3.0",
37
- "rimraf": "3.0.2",
38
- "ttypescript": "1.5.15",
39
- "typescript": "4.7.4"
31
+ "@webiny/handler-aws": "0.0.0-unstable.e0bfc55d5a",
32
+ "@webiny/project-utils": "0.0.0-unstable.e0bfc55d5a",
33
+ "jest": "29.7.0",
34
+ "jest-mock-console": "2.0.0",
35
+ "rimraf": "6.0.1",
36
+ "typescript": "5.3.3"
40
37
  },
41
38
  "publishConfig": {
42
39
  "access": "public",
43
40
  "directory": "dist"
44
41
  },
45
42
  "scripts": {
46
- "build": "yarn webiny run build",
47
- "watch": "yarn webiny run watch"
43
+ "build": "node ../cli/bin.js run build",
44
+ "watch": "node ../cli/bin.js run watch"
48
45
  },
49
- "gitHead": "de38392959f2692d1feb08945a3588cd80e4924c"
46
+ "gitHead": "e0bfc55d5a4d6a42b32e6558d9fb2eb6753e331b"
50
47
  }
@@ -1,13 +1,21 @@
1
+ import type { Context } from "@webiny/api/types";
1
2
  import { Plugin } from "@webiny/plugins";
2
- import { GraphQLSchemaDefinition, Resolvers, Types } from "../types";
3
- import { Context } from "@webiny/api/types";
3
+ import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types";
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?: Types;
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
- private config;
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>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.GraphQLSchemaPlugin = void 0;
6
+ exports.createGraphQLSchemaPlugin = exports.GraphQLSchemaPlugin = void 0;
7
7
  var _plugins = require("@webiny/plugins");
8
8
  class GraphQLSchemaPlugin extends _plugins.Plugin {
9
9
  static type = "graphql-schema";
@@ -14,10 +14,21 @@ class GraphQLSchemaPlugin extends _plugins.Plugin {
14
14
  get schema() {
15
15
  return {
16
16
  typeDefs: this.config.typeDefs || "",
17
- resolvers: this.config.resolvers
17
+ resolvers: this.config.resolvers,
18
+ resolverDecorators: this.config.resolverDecorators
18
19
  };
19
20
  }
21
+ isApplicable(context) {
22
+ if (this.config.isApplicable) {
23
+ return this.config.isApplicable(context);
24
+ }
25
+ return true;
26
+ }
20
27
  }
21
28
  exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
29
+ const createGraphQLSchemaPlugin = config => {
30
+ return new GraphQLSchemaPlugin(config);
31
+ };
32
+ exports.createGraphQLSchemaPlugin = createGraphQLSchemaPlugin;
22
33
 
23
34
  //# sourceMappingURL=GraphQLSchemaPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","exports"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers, Types } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: Types;\n resolvers?: Resolvers<TContext>;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context> extends Plugin {\n public static override readonly type: string = \"graphql-schema\";\n private 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 };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,mBAAmB,SAA6BC,eAAM,CAAC;EAChE,OAAgCC,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;IAC3B,CAAC;EACL;AACJ;AAACC,OAAA,CAAAR,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types\";\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,IAAAA,QAAA,GAAAC,OAAA;AAeO,MAAMC,mBAAmB,SACpBC,eAAM,CAElB;EACI,OAAgCC,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;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA;AAEM,MAAMY,yBAAyB,GAAiBR,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACO,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_GraphQLSchemaPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_GraphQLSchemaPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -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 _default: (requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult[] | ExecutionResult>;
5
- export default _default;
1
+ import type { ExecutionResult, GraphQLSchema } from "graphql";
2
+ import type { GraphQLRequestBody } from "./types";
3
+ import type { Context } from "@webiny/api/types";
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>[]>;
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.processRequestBody = void 0;
7
7
  var _graphql = require("graphql");
8
- const processRequestBody = async (body, schema, context) => {
8
+ const executeGraphQl = async (body, schema, context) => {
9
9
  const {
10
10
  query,
11
11
  variables,
@@ -16,7 +16,14 @@ const processRequestBody = async (body, schema, context) => {
16
16
  schema,
17
17
  context
18
18
  }));
19
- const result = await (0, _graphql.graphql)(schema, query, {}, context, variables, operationName);
19
+ const result = await (0, _graphql.graphql)({
20
+ schema,
21
+ source: query,
22
+ rootValue: {},
23
+ contextValue: context,
24
+ variableValues: variables,
25
+ operationName
26
+ });
20
27
  context.plugins.byType("graphql-after-query").forEach(pl => {
21
28
  pl.apply({
22
29
  result,
@@ -27,17 +34,17 @@ const processRequestBody = async (body, schema, context) => {
27
34
  });
28
35
  return result;
29
36
  };
30
- var _default = async (requestBody, schema, context) => {
37
+ const processRequestBody = async (requestBody, schema, context) => {
31
38
  if (Array.isArray(requestBody)) {
32
39
  const results = [];
33
40
  for (const body of requestBody) {
34
- const result = await processRequestBody(body, schema, context);
41
+ const result = await executeGraphQl(body, schema, context);
35
42
  results.push(result);
36
43
  }
37
44
  return results;
38
45
  }
39
- return await processRequestBody(requestBody, schema, context);
46
+ return await executeGraphQl(requestBody, schema, context);
40
47
  };
41
- exports.default = _default;
48
+ exports.processRequestBody = processRequestBody;
42
49
 
43
50
  //# sourceMappingURL=processRequestBody.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_graphql","require","processRequestBody","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","_default","requestBody","Array","isArray","results","push","exports","default"],"sources":["processRequestBody.ts"],"sourcesContent":["import { ExecutionResult, graphql, GraphQLSchema } from \"graphql\";\nimport { GraphQLAfterQueryPlugin, GraphQLBeforeQueryPlugin, GraphQLRequestBody } from \"~/types\";\nimport { Context } from \"@webiny/api/types\";\n\nconst processRequestBody = async (\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n) => {\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(schema, query, {}, context, variables, operationName);\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result;\n};\n\nexport default async (\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult[] | ExecutionResult> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult[] = [];\n for (const body of requestBody) {\n const result = await processRequestBody(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await processRequestBody(requestBody, schema, context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAIA,MAAMC,kBAAkB,GAAG,MAAAA,CACvBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KACf;EACD,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,MAAM,IAAAC,gBAAO,EAACX,MAAM,EAAEE,KAAK,EAAE,CAAC,CAAC,EAAED,OAAO,EAAEE,SAAS,EAAEC,aAAa,CAAC;EAElFH,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;AAAC,IAAAE,QAAA,GAEa,MAAAA,CACXC,WAAsD,EACtDb,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,IAAIa,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC5B,MAAMG,OAA0B,GAAG,EAAE;IACrC,KAAK,MAAMjB,IAAI,IAAIc,WAAW,EAAE;MAC5B,MAAMH,MAAM,GAAG,MAAMZ,kBAAkB,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;MAC9De,OAAO,CAACC,IAAI,CAACP,MAAM,CAAC;IACxB;IACA,OAAOM,OAAO;EAClB;EACA,OAAO,MAAMlB,kBAAkB,CAACe,WAAW,EAAEb,MAAM,EAAEC,OAAO,CAAC;AACjE,CAAC;AAAAiB,OAAA,CAAAC,OAAA,GAAAP,QAAA"}
1
+ {"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push","exports"],"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\";\nimport type { Context } from \"@webiny/api/types\";\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,IA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M,EAAEC,OAAO,CAAC;AACjF,CAAC;AAACqB,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/responses.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","exports","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;AAEM,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;AAACS,OAAA,CAAAR,aAAA,GAAAA,aAAA;AAEM,MAAMS,gBAAgB,SAAST,aAAa,CAAC;EAChDC,WAAWA,CAACJ,OAAe,EAAE;IACzB,KAAK,CAAC;MACFD,IAAI,EAAE,WAAW;MACjBC;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,MAAMC,iBAAiB,CAAC;EAU3BT,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACS,IAAI,GAAG,IAAI;IAChB,IAAI,CAACb,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;AAACS,OAAA,CAAAE,iBAAA,GAAAA,iBAAA;AAEM,MAAME,QAAQ,CAAU;EAI3BX,WAAWA,CAACH,IAAO,EAAE;IACjB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACS,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAI,QAAA,GAAAA,QAAA;AAEM,MAAMC,YAAY,CAAO;EAK5BZ,WAAWA,CAACH,IAAc,EAAEa,IAAQ,EAAE;IAClC,IAAI,CAACb,IAAI,GAAGgB,KAAK,CAACC,OAAO,CAACjB,IAAI,CAAC,GAAGA,IAAI,GAAG,EAAE;IAC3C,IAAI,CAACa,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACJ,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAK,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","exports","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;AAEM,MAAMC,aAAa,CAAC;EASvBC,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACJ,IAAI,GAAG,IAAI;IAEhB,MAAM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,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAACS,OAAA,CAAAE,iBAAA,GAAAA,iBAAA;AAEM,MAAME,QAAQ,CAAU;EAI3BX,WAAWA,CAACH,IAAO,EAAE;IACjB,IAAI,CAACA,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACS,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAI,QAAA,GAAAA,QAAA;AAEM,MAAMC,YAAY,CAAO;EAK5BZ,WAAWA,CAACH,IAAc,EAAEa,IAAQ,EAAE;IAClC,IAAI,CAACb,IAAI,GAAGgB,KAAK,CAACC,OAAO,CAACjB,IAAI,CAAC,GAAGA,IAAI,GAAG,EAAE;IAC3C,IAAI,CAACa,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAO;IAC7B,IAAI,CAACJ,KAAK,GAAG,IAAI;EACrB;AACJ;AAACC,OAAA,CAAAK,YAAA,GAAAA,YAAA","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";
3
+ import type { Context, GenericRecord } from "@webiny/api/types";
4
+ import type { RouteMethodPath } from "@webiny/handler/types";
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 declare type GraphQLFieldResolver<TSource = any, TArgs = any, TContext = Context> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;
14
- export declare type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);
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 declare type Resolvers<TContext> = GraphQLScalarType | GraphQLFieldResolver<any, Record<string, any>, TContext> | {
21
- [property: string]: Resolvers<TContext>;
22
- };
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[]>;
23
29
  export interface GraphQLSchemaDefinition<TContext> {
24
- typeDefs: Types;
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";
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// `GraphQLSchemaPlugin` types.\nexport type Types = string | string[] | (() => string | string[] | Promise<string | string[]>);\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> =\n | GraphQLScalarType\n | GraphQLFieldResolver<any, Record<string, any>, TContext>\n | { [property: string]: Resolvers<TContext> };\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: Types;\n resolvers?: Resolvers<TContext>;\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>;\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":""}
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\";\nimport type { Context, GenericRecord } from \"@webiny/api/types\";\nimport type { RouteMethodPath } from \"@webiny/handler/types\";\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> {\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>;\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":[]}
@@ -0,0 +1 @@
1
+ export * from "./resolve";
package/utils/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _resolve = require("./resolve");
7
+ Object.keys(_resolve).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _resolve[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _resolve[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_resolve","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./resolve\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "../responses";
2
+ import type { GenericRecord } from "@webiny/api/types";
3
+ export interface Meta {
4
+ totalCount: number;
5
+ hasMoreItems: boolean;
6
+ cursor: string | null;
7
+ }
8
+ export declare const emptyResolver: () => {};
9
+ interface ResolveCallable<T = GenericRecord> {
10
+ (): Promise<T>;
11
+ }
12
+ export declare const resolve: <T = GenericRecord>(fn: ResolveCallable<T>) => Promise<ErrorResponse | Response<Awaited<T>>>;
13
+ interface ResolveListCallable<T> {
14
+ (): Promise<IListResult<T>>;
15
+ }
16
+ interface IListResult<T = GenericRecord> {
17
+ items: T[];
18
+ meta: Meta;
19
+ }
20
+ export declare const resolveList: <T = GenericRecord>(fn: ResolveListCallable<T>) => Promise<ListErrorResponse | ListResponse<T, Meta>>;
21
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveList = exports.resolve = exports.emptyResolver = void 0;
7
+ var _responses = require("../responses");
8
+ const emptyResolver = () => ({});
9
+ exports.emptyResolver = emptyResolver;
10
+ const resolve = async fn => {
11
+ try {
12
+ return new _responses.Response(await fn());
13
+ } catch (ex) {
14
+ return new _responses.ErrorResponse(ex);
15
+ }
16
+ };
17
+ exports.resolve = resolve;
18
+ const resolveList = async fn => {
19
+ try {
20
+ const result = await fn();
21
+ return new _responses.ListResponse(result.items, result.meta);
22
+ } catch (ex) {
23
+ return new _responses.ListErrorResponse(ex);
24
+ }
25
+ };
26
+ exports.resolveList = resolveList;
27
+
28
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_responses","require","emptyResolver","exports","resolve","fn","Response","ex","ErrorResponse","resolveList","result","ListResponse","items","meta","ListErrorResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"~/responses\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport interface Meta {\n totalCount: number;\n hasMoreItems: boolean;\n cursor: string | null;\n}\n\nexport const emptyResolver = () => ({});\n\ninterface ResolveCallable<T = GenericRecord> {\n (): Promise<T>;\n}\n\nexport const resolve = async <T = GenericRecord>(fn: ResolveCallable<T>) => {\n try {\n return new Response(await fn());\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\ninterface ResolveListCallable<T> {\n (): Promise<IListResult<T>>;\n}\n\ninterface IListResult<T = GenericRecord> {\n items: T[];\n meta: Meta;\n}\n\nexport const resolveList = async <T = GenericRecord>(fn: ResolveListCallable<T>) => {\n try {\n const result = (await fn()) as IListResult<T>;\n return new ListResponse(result.items, result.meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAACC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAMjC,MAAME,OAAO,GAAG,MAA0BC,EAAsB,IAAK;EACxE,IAAI;IACA,OAAO,IAAIC,mBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,EAAE,EAAE;IACT,OAAO,IAAIC,wBAAa,CAACD,EAAE,CAAC;EAChC;AACJ,CAAC;AAACJ,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAWK,MAAMK,WAAW,GAAG,MAA0BJ,EAA0B,IAAK;EAChF,IAAI;IACA,MAAMK,MAAM,GAAI,MAAML,EAAE,CAAC,CAAoB;IAC7C,OAAO,IAAIM,uBAAY,CAACD,MAAM,CAACE,KAAK,EAAEF,MAAM,CAACG,IAAI,CAAC;EACtD,CAAC,CAAC,OAAON,EAAE,EAAE;IACT,OAAO,IAAIO,4BAAiB,CAACP,EAAE,CAAC;EACpC;AACJ,CAAC;AAACJ,OAAA,CAAAM,WAAA,GAAAA,WAAA","ignoreList":[]}