@webiny/api 3.0.2-next.0 → 5.31.0-beta.1

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/Context.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Context as ContextInterface } from "./types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { PluginCollection } from "@webiny/plugins/types";
4
+ export interface ContextParams {
5
+ plugins?: PluginCollection;
6
+ WEBINY_VERSION: string;
7
+ }
8
+ export declare class Context implements ContextInterface {
9
+ _result: any;
10
+ args: any;
11
+ readonly plugins: PluginsContainer;
12
+ readonly WEBINY_VERSION: string;
13
+ private readonly waiters;
14
+ constructor(params: ContextParams);
15
+ getResult(): any;
16
+ hasResult(): boolean;
17
+ setResult(value: any): void;
18
+ waitFor<T extends ContextInterface = ContextInterface>(obj: string | string[], cb: (context: T) => void): void;
19
+ }
package/Context.js ADDED
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Context = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class Context {
15
+ constructor(params) {
16
+ (0, _defineProperty2.default)(this, "_result", void 0);
17
+ (0, _defineProperty2.default)(this, "args", void 0);
18
+ (0, _defineProperty2.default)(this, "plugins", void 0);
19
+ (0, _defineProperty2.default)(this, "WEBINY_VERSION", void 0);
20
+ (0, _defineProperty2.default)(this, "waiters", []);
21
+ const {
22
+ plugins,
23
+ WEBINY_VERSION
24
+ } = params;
25
+ this.plugins = new _plugins.PluginsContainer(plugins || []);
26
+ this.WEBINY_VERSION = WEBINY_VERSION;
27
+ }
28
+
29
+ getResult() {
30
+ return this._result;
31
+ }
32
+
33
+ hasResult() {
34
+ return !!this._result;
35
+ }
36
+
37
+ setResult(value) {
38
+ this._result = value;
39
+ }
40
+
41
+ waitFor(obj, cb) {
42
+ const initialTargets = Array.isArray(obj) ? obj : [obj];
43
+ const targets = [];
44
+ /**
45
+ * We go only through the first level properties
46
+ */
47
+
48
+ for (const key in initialTargets) {
49
+ const target = initialTargets[key];
50
+ /**
51
+ * If property already exists, there is no need to wait for it, so we just continue the loop.
52
+ * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.
53
+ */
54
+
55
+ if (this[target]) {
56
+ continue;
57
+ } else if (typeof target !== "string") {
58
+ continue;
59
+ }
60
+ /**
61
+ * Since there is no property, we must define it with its setter and getter.
62
+ * We could not know when it got defined otherwise.
63
+ */
64
+
65
+
66
+ Object.defineProperty(this, target, {
67
+ /**
68
+ * Setter sets the given value to this object.
69
+ * We cannot set it on exact property name it is defined because it would go into loop of setting itself.
70
+ * And that is why we add __ around the property name.
71
+ */
72
+ set: value => {
73
+ const newTargetKey = `__${target}__`;
74
+ this[newTargetKey] = value;
75
+ /**
76
+ * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.
77
+ */
78
+
79
+ for (const waiter of this.waiters) {
80
+ if (waiter.targets.includes(target) === false) {
81
+ continue;
82
+ }
83
+ /**
84
+ * Remove currently set property so we know if there are any more to be waited for.
85
+ */
86
+
87
+
88
+ waiter.targets = waiter.targets.filter(t => t !== target);
89
+ /**
90
+ * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.
91
+ */
92
+
93
+ if (waiter.targets.length > 0) {
94
+ continue;
95
+ }
96
+ /**
97
+ * And if there is nothing more to be waited for, we execute the callable.
98
+ * Note that this callable is not async.
99
+ */
100
+
101
+
102
+ waiter.cb(this);
103
+ }
104
+ },
105
+
106
+ /**
107
+ * As we have set property with __ around it, we must get it as well.
108
+ */
109
+ get: () => {
110
+ const newTargetKey = `__${target}__`;
111
+ return this[newTargetKey];
112
+ },
113
+ configurable: false
114
+ });
115
+ /**
116
+ * We add the target to be awaited.
117
+ */
118
+
119
+ targets.push(target);
120
+ }
121
+ /**
122
+ * If there are no targets to be awaited, just fire the callable.
123
+ */
124
+
125
+
126
+ if (targets.length === 0) {
127
+ cb(this);
128
+ return;
129
+ }
130
+ /**
131
+ * Otherwise add the waiter for the target properties.
132
+ */
133
+
134
+
135
+ this.waiters.push({
136
+ targets,
137
+
138
+ /**
139
+ * TODO @ts-refactor
140
+ * Problem with possible subtype initialization
141
+ */
142
+ // @ts-ignore
143
+ cb
144
+ });
145
+ }
146
+
147
+ }
148
+
149
+ exports.Context = Context;
package/Context.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Context","constructor","params","plugins","WEBINY_VERSION","PluginsContainer","getResult","_result","hasResult","setResult","value","waitFor","obj","cb","initialTargets","Array","isArray","targets","key","target","Object","defineProperty","set","newTargetKey","waiter","waiters","includes","filter","t","length","get","configurable","push"],"sources":["Context.ts"],"sourcesContent":["import { Context as ContextInterface } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\ninterface Waiter {\n targets: string[];\n cb: (context: ContextInterface) => void;\n}\n\nexport interface ContextParams {\n plugins?: PluginCollection;\n WEBINY_VERSION: string;\n}\nexport class Context implements ContextInterface {\n public _result: any;\n public args: any;\n public readonly plugins: PluginsContainer;\n public readonly WEBINY_VERSION: string;\n\n private readonly waiters: Waiter[] = [];\n\n public constructor(params: ContextParams) {\n const { plugins, WEBINY_VERSION } = params;\n this.plugins = new PluginsContainer(plugins || []);\n this.WEBINY_VERSION = WEBINY_VERSION;\n }\n\n public getResult(): any {\n return this._result;\n }\n\n public hasResult(): boolean {\n return !!this._result;\n }\n\n public setResult(value: any): void {\n this._result = value;\n }\n\n public waitFor<T extends ContextInterface = ContextInterface>(\n obj: string | string[],\n cb: (context: T) => void\n ): void {\n const initialTargets = Array.isArray(obj) ? obj : [obj];\n const targets: string[] = [];\n /**\n * We go only through the first level properties\n */\n for (const key in initialTargets) {\n const target = initialTargets[key] as keyof this;\n /**\n * If property already exists, there is no need to wait for it, so we just continue the loop.\n * Also, if target is not a string, skip this property as it will fail to convert properly during the runtime.\n */\n if (this[target]) {\n continue;\n } else if (typeof target !== \"string\") {\n continue;\n }\n /**\n * Since there is no property, we must define it with its setter and getter.\n * We could not know when it got defined otherwise.\n */\n Object.defineProperty(this, target, {\n /**\n * Setter sets the given value to this object.\n * We cannot set it on exact property name it is defined because it would go into loop of setting itself.\n * And that is why we add __ around the property name.\n */\n set: (value: any) => {\n const newTargetKey = `__${target}__` as keyof this;\n this[newTargetKey] = value;\n /**\n * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.\n */\n for (const waiter of this.waiters) {\n if (waiter.targets.includes(target) === false) {\n continue;\n }\n /**\n * Remove currently set property so we know if there are any more to be waited for.\n */\n waiter.targets = waiter.targets.filter(t => t !== target);\n /**\n * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.\n */\n if (waiter.targets.length > 0) {\n continue;\n }\n /**\n * And if there is nothing more to be waited for, we execute the callable.\n * Note that this callable is not async.\n */\n waiter.cb(this);\n }\n },\n /**\n * As we have set property with __ around it, we must get it as well.\n */\n get: (): any => {\n const newTargetKey = `__${target}__` as keyof this;\n return this[newTargetKey];\n },\n configurable: false\n });\n /**\n * We add the target to be awaited.\n */\n targets.push(target as string);\n }\n /**\n * If there are no targets to be awaited, just fire the callable.\n */\n if (targets.length === 0) {\n cb(this as any);\n return;\n }\n /**\n * Otherwise add the waiter for the target properties.\n */\n this.waiters.push({\n targets,\n /**\n * TODO @ts-refactor\n * Problem with possible subtype initialization\n */\n // @ts-ignore\n cb\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;;AAYO,MAAMA,OAAN,CAA0C;EAQtCC,WAAW,CAACC,MAAD,EAAwB;IAAA;IAAA;IAAA;IAAA;IAAA,+CAFL,EAEK;IACtC,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAA8BF,MAApC;IACA,KAAKC,OAAL,GAAe,IAAIE,yBAAJ,CAAqBF,OAAO,IAAI,EAAhC,CAAf;IACA,KAAKC,cAAL,GAAsBA,cAAtB;EACH;;EAEME,SAAS,GAAQ;IACpB,OAAO,KAAKC,OAAZ;EACH;;EAEMC,SAAS,GAAY;IACxB,OAAO,CAAC,CAAC,KAAKD,OAAd;EACH;;EAEME,SAAS,CAACC,KAAD,EAAmB;IAC/B,KAAKH,OAAL,GAAeG,KAAf;EACH;;EAEMC,OAAO,CACVC,GADU,EAEVC,EAFU,EAGN;IACJ,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAN,CAAcJ,GAAd,IAAqBA,GAArB,GAA2B,CAACA,GAAD,CAAlD;IACA,MAAMK,OAAiB,GAAG,EAA1B;IACA;AACR;AACA;;IACQ,KAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;MAC9B,MAAMK,MAAM,GAAGL,cAAc,CAACI,GAAD,CAA7B;MACA;AACZ;AACA;AACA;;MACY,IAAI,KAAKC,MAAL,CAAJ,EAAkB;QACd;MACH,CAFD,MAEO,IAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;QACnC;MACH;MACD;AACZ;AACA;AACA;;;MACYC,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4BF,MAA5B,EAAoC;QAChC;AAChB;AACA;AACA;AACA;QACgBG,GAAG,EAAGZ,KAAD,IAAgB;UACjB,MAAMa,YAAY,GAAI,KAAIJ,MAAO,IAAjC;UACA,KAAKI,YAAL,IAAqBb,KAArB;UACA;AACpB;AACA;;UACoB,KAAK,MAAMc,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;YAC/B,IAAID,MAAM,CAACP,OAAP,CAAeS,QAAf,CAAwBP,MAAxB,MAAoC,KAAxC,EAA+C;cAC3C;YACH;YACD;AACxB;AACA;;;YACwBK,MAAM,CAACP,OAAP,GAAiBO,MAAM,CAACP,OAAP,CAAeU,MAAf,CAAsBC,CAAC,IAAIA,CAAC,KAAKT,MAAjC,CAAjB;YACA;AACxB;AACA;;YACwB,IAAIK,MAAM,CAACP,OAAP,CAAeY,MAAf,GAAwB,CAA5B,EAA+B;cAC3B;YACH;YACD;AACxB;AACA;AACA;;;YACwBL,MAAM,CAACX,EAAP,CAAU,IAAV;UACH;QACJ,CAhC+B;;QAiChC;AAChB;AACA;QACgBiB,GAAG,EAAE,MAAW;UACZ,MAAMP,YAAY,GAAI,KAAIJ,MAAO,IAAjC;UACA,OAAO,KAAKI,YAAL,CAAP;QACH,CAvC+B;QAwChCQ,YAAY,EAAE;MAxCkB,CAApC;MA0CA;AACZ;AACA;;MACYd,OAAO,CAACe,IAAR,CAAab,MAAb;IACH;IACD;AACR;AACA;;;IACQ,IAAIF,OAAO,CAACY,MAAR,KAAmB,CAAvB,EAA0B;MACtBhB,EAAE,CAAC,IAAD,CAAF;MACA;IACH;IACD;AACR;AACA;;;IACQ,KAAKY,OAAL,CAAaO,IAAb,CAAkB;MACdf,OADc;;MAEd;AACZ;AACA;AACA;MACY;MACAJ;IAPc,CAAlB;EASH;;AApH4C"}
package/README.md CHANGED
@@ -4,10 +4,6 @@
4
4
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
5
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
6
 
7
- The base package for building GraphQL powered HTTP APIs for your Webiny apps.
8
-
9
- For more information, please visit [the official docs](https://docs.webiny.com/docs/developer-tutorials/api-overview).
10
-
11
7
  ## Install
12
8
  ```
13
9
  npm install --save @webiny/api
@@ -17,11 +13,3 @@ Or if you prefer yarn:
17
13
  ```
18
14
  yarn add @webiny/api
19
15
  ```
20
-
21
- ## Usage
22
-
23
- Some of the packages that are built on top of the `@webiny/api`:
24
-
25
- - [@webiny/api-cms](../api-cms)
26
- - [@webiny/api-security](../api-security)
27
- - [@webiny/api-cookie-policy](../api-cookie-policy)
package/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- export { createHandler, createSchema } from "./createHandler";
2
- export { PluginsContainer } from "@webiny/plugins";
3
- export * from "./graphql/responses";
4
- export { default as emptyResolver } from "./graphql/emptyResolver";
1
+ export * from "./Context";
2
+ export * from "./plugins/ContextPlugin";
package/index.js CHANGED
@@ -1,57 +1,31 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- var _exportNames = {
9
- createHandler: true,
10
- createSchema: true,
11
- PluginsContainer: true,
12
- emptyResolver: true
13
- };
14
- Object.defineProperty(exports, "createHandler", {
15
- enumerable: true,
16
- get: function () {
17
- return _createHandler.createHandler;
18
- }
19
- });
20
- Object.defineProperty(exports, "createSchema", {
21
- enumerable: true,
22
- get: function () {
23
- return _createHandler.createSchema;
24
- }
25
- });
26
- Object.defineProperty(exports, "PluginsContainer", {
27
- enumerable: true,
28
- get: function () {
29
- return _plugins.PluginsContainer;
30
- }
31
- });
32
- Object.defineProperty(exports, "emptyResolver", {
33
- enumerable: true,
34
- get: function () {
35
- return _emptyResolver.default;
36
- }
37
- });
38
-
39
- var _createHandler = require("./createHandler");
40
-
41
- var _plugins = require("@webiny/plugins");
42
6
 
43
- var _responses = require("./graphql/responses");
7
+ var _Context = require("./Context");
44
8
 
45
- Object.keys(_responses).forEach(function (key) {
9
+ Object.keys(_Context).forEach(function (key) {
46
10
  if (key === "default" || key === "__esModule") return;
47
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
11
+ if (key in exports && exports[key] === _Context[key]) return;
48
12
  Object.defineProperty(exports, key, {
49
13
  enumerable: true,
50
14
  get: function () {
51
- return _responses[key];
15
+ return _Context[key];
52
16
  }
53
17
  });
54
18
  });
55
19
 
56
- var _emptyResolver = _interopRequireDefault(require("./graphql/emptyResolver"));
57
- //# sourceMappingURL=index.js.map
20
+ var _ContextPlugin = require("./plugins/ContextPlugin");
21
+
22
+ Object.keys(_ContextPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _ContextPlugin[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _ContextPlugin[key];
29
+ }
30
+ });
31
+ });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA","sourcesContent":["export { createHandler, createSchema } from \"./createHandler\";\nexport { PluginsContainer } from \"@webiny/plugins\";\nexport * from \"./graphql/responses\";\nexport { default as emptyResolver } from \"./graphql/emptyResolver\";\n"],"file":"index.js"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/Context\";\nexport * from \"~/plugins/ContextPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,45 +1,38 @@
1
1
  {
2
- "name": "@webiny/api",
3
- "version": "3.0.2-next.0",
4
- "main": "index.js",
5
- "types": "dist/types.d.ts",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/webiny/webiny-js.git"
9
- },
10
- "description": "The base package for building GraphQL powered HTTP APIs for your Webiny apps.",
11
- "contributors": [
12
- "Pavel Denisjuk <pavel@webiny.com>",
13
- "Sven Al Hamad <sven@webiny.com>",
14
- "Adrian Smijulj <adrian@webiny.com>"
15
- ],
16
- "license": "MIT",
17
- "dependencies": {
18
- "@apollo/federation": "^0.10.2",
19
- "@webiny/plugins": "^3.0.1",
20
- "graphql": "^14.4.2",
21
- "graphql-iso-date": "^3.6.1",
22
- "graphql-middleware": "^4.0.1",
23
- "graphql-tag": "^2.10.1",
24
- "graphql-tools": "^4.0.5",
25
- "graphql-type-json": "^0.3.0",
26
- "graphql-type-long": "^0.1.1"
27
- },
28
- "devDependencies": {
29
- "@babel/cli": "^7.5.5",
30
- "@babel/core": "^7.5.5",
31
- "@babel/plugin-proposal-class-properties": "^7.5.5",
32
- "@babel/preset-env": "^7.5.5",
33
- "@babel/preset-typescript": "^7.7.7"
34
- },
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "scripts": {
39
- "build": "rimraf ./dist *.tsbuildinfo && babel src -d dist --source-maps --copy-files --extensions \".ts\"",
40
- "watch": "babel src -d dist --source-maps --copy-files --extensions \".ts\" --watch",
41
- "postbuild": "cp package.json LICENSE README.md dist/ && tsc -p tsconfig.build.json",
42
- "prepublishOnly": "yarn build"
43
- },
44
- "gitHead": "4f35869cf60a56f746a688a07b4d757826d011e5"
2
+ "name": "@webiny/api",
3
+ "version": "5.31.0-beta.1",
4
+ "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/webiny/webiny-js.git"
8
+ },
9
+ "description": "Core package for all of our API packages.",
10
+ "contributors": [
11
+ "Bruno Zorić <bruno@webiny.com>"
12
+ ],
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@babel/runtime": "7.18.9",
16
+ "@webiny/plugins": "5.31.0-beta.1"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.16.0",
20
+ "@babel/core": "^7.16.0",
21
+ "@babel/preset-env": "^7.16.4",
22
+ "@babel/preset-typescript": "^7.16.0",
23
+ "@webiny/cli": "^5.31.0-beta.1",
24
+ "@webiny/project-utils": "^5.31.0-beta.1",
25
+ "rimraf": "^3.0.2",
26
+ "ttypescript": "^1.5.13",
27
+ "typescript": "4.7.4"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "directory": "dist"
32
+ },
33
+ "scripts": {
34
+ "build": "yarn webiny run build",
35
+ "watch": "yarn webiny run watch"
36
+ },
37
+ "gitHead": "b29a1cdd4c7cba5af3b9b993a78f4561525a9201"
45
38
  }
@@ -0,0 +1,12 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Context } from "../types";
3
+ export interface ContextPluginCallable<T extends Context = Context> {
4
+ (context: T): void | Promise<void>;
5
+ }
6
+ export declare class ContextPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
8
+ private readonly _callable;
9
+ constructor(callable: ContextPluginCallable<T>);
10
+ apply(context: T): Promise<void>;
11
+ }
12
+ export declare const createContextPlugin: <T extends Context = Context>(callable: ContextPluginCallable<T>) => ContextPlugin<T>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createContextPlugin = exports.ContextPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class ContextPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_callable", void 0);
18
+ this._callable = callable;
19
+ }
20
+
21
+ async apply(context) {
22
+ if (typeof this._callable !== "function") {
23
+ throw Error(`Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
24
+ }
25
+
26
+ return this._callable(context);
27
+ }
28
+
29
+ }
30
+
31
+ exports.ContextPlugin = ContextPlugin;
32
+ (0, _defineProperty2.default)(ContextPlugin, "type", "context");
33
+
34
+ const createContextPlugin = callable => {
35
+ return new ContextPlugin(callable);
36
+ };
37
+
38
+ exports.createContextPlugin = createContextPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ContextPlugin","Plugin","constructor","callable","_callable","apply","context","Error","createContextPlugin"],"sources":["ContextPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface ContextPluginCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class ContextPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"context\";\n private readonly _callable: ContextPluginCallable<T>;\n\n constructor(callable: ContextPluginCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in ContextPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createContextPlugin = <T extends Context = Context>(\n callable: ContextPluginCallable<T>\n): ContextPlugin<T> => {\n return new ContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAMA,aAAN,SAAyDC,eAAzD,CAAgE;EAInEC,WAAW,CAACC,QAAD,EAAqC;IAC5C;IAD4C;IAE5C,KAAKC,SAAL,GAAiBD,QAAjB;EACH;;EAEiB,MAALE,KAAK,CAACC,OAAD,EAA4B;IAC1C,IAAI,OAAO,KAAKF,SAAZ,KAA0B,UAA9B,EAA0C;MACtC,MAAMG,KAAK,CACN,uIADM,CAAX;IAGH;;IAED,OAAO,KAAKH,SAAL,CAAeE,OAAf,CAAP;EACH;;AAjBkE;;;8BAA1DN,a,UACsC,S;;AAmB5C,MAAMQ,mBAAmB,GAC5BL,QAD+B,IAEZ;EACnB,OAAO,IAAIH,aAAJ,CAAqBG,QAArB,CAAP;AACH,CAJM"}
package/types.d.ts CHANGED
@@ -1,46 +1,37 @@
1
- import { GraphQLScalarType, GraphQLSchema, GraphQLFieldResolver as BaseGraphQLFieldResolver } from "graphql";
2
- import { Plugin, PluginsContainer } from "@webiny/plugins/types";
3
- export { Plugin, PluginsContainer };
4
- export interface GraphQLContext {
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ /**
3
+ * The main context which is constructed on every request.
4
+ * All other contexts should extend or augment this one.
5
+ */
6
+ export interface Context {
5
7
  plugins: PluginsContainer;
6
- [key: string]: any;
8
+ args: any;
9
+ readonly WEBINY_VERSION: string;
10
+ /**
11
+ * Not to be used outside of Webiny internal code.
12
+ * @internal
13
+ */
14
+ hasResult: () => boolean;
15
+ /**
16
+ * Not to be used outside of Webiny internal code.
17
+ * @internal
18
+ *
19
+ * @private
20
+ */
21
+ _result?: any;
22
+ /**
23
+ * Not to be used outside of Webiny internal code.
24
+ * @internal
25
+ */
26
+ setResult: (value: any) => void;
27
+ /**
28
+ * Not to be used outside of Webiny internal code.
29
+ * @internal
30
+ */
31
+ getResult: () => void;
32
+ /**
33
+ * Wait for property to be defined on the object and then execute the callable.
34
+ * In case of multiple objects defined, wait for all of them.
35
+ */
36
+ waitFor: <T extends Context = Context>(obj: string[] | string, cb: (context: T) => void) => void;
7
37
  }
8
- export declare type SchemaDefinition = {
9
- typeDefs: any;
10
- resolvers: any;
11
- };
12
- export declare type SchemaDefinitionFactory = (params: {
13
- plugins: PluginsContainer;
14
- }) => Promise<SchemaDefinition>;
15
- export declare type GraphQLSchemaPlugin = Plugin & {
16
- prepare?: (params: {
17
- plugins: PluginsContainer;
18
- }) => void;
19
- schema: SchemaDefinition | SchemaDefinitionFactory;
20
- [key: string]: any;
21
- };
22
- export declare type GraphQLContextPlugin = Plugin & {
23
- preApply?: (context: GraphQLContext) => void | Promise<void>;
24
- apply?: (context: GraphQLContext) => void | Promise<void>;
25
- postApply?: (context: GraphQLContext) => void | Promise<void>;
26
- };
27
- export declare type GraphQLMiddlewarePlugin = Plugin & {
28
- middleware: (params: {
29
- plugins: PluginsContainer;
30
- }) => Function[];
31
- };
32
- export declare type GraphqlScalarPlugin = Plugin & {
33
- scalar: GraphQLScalarType;
34
- };
35
- export declare type CreateApolloHandlerPlugin = Plugin & {
36
- create(params: {
37
- plugins: PluginsContainer;
38
- schema: GraphQLSchema;
39
- }): Function;
40
- };
41
- export declare type CreateApolloGatewayPlugin = Plugin & {
42
- createGateway(params: {
43
- plugins: PluginsContainer;
44
- }): Promise<Function>;
45
- };
46
- export declare type GraphQLFieldResolver<TSource = any, TArgs = any, TContext = GraphQLContext> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;
package/types.js CHANGED
@@ -2,21 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- Object.defineProperty(exports, "Plugin", {
7
- enumerable: true,
8
- get: function () {
9
- return _types.Plugin;
10
- }
11
- });
12
- Object.defineProperty(exports, "PluginsContainer", {
13
- enumerable: true,
14
- get: function () {
15
- return _types.PluginsContainer;
16
- }
17
- });
18
-
19
- var _types = require("@webiny/plugins/types");
20
-
21
- ;
22
- //# sourceMappingURL=types.js.map
5
+ });
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA;;AAOC","sourcesContent":["import {\n GraphQLScalarType,\n GraphQLSchema,\n GraphQLFieldResolver as BaseGraphQLFieldResolver\n} from \"graphql\";\n\nimport { Plugin, PluginsContainer } from \"@webiny/plugins/types\";\n\nexport { Plugin, PluginsContainer };\n\nexport interface GraphQLContext {\n plugins: PluginsContainer;\n [key: string]: any;\n};\n\nexport type SchemaDefinition = {\n typeDefs: any;\n resolvers: any;\n};\n\nexport type SchemaDefinitionFactory = (params: {\n plugins: PluginsContainer;\n}) => Promise<SchemaDefinition>;\n\nexport type GraphQLSchemaPlugin = Plugin & {\n prepare?: (params: { plugins: PluginsContainer }) => void;\n schema: SchemaDefinition | SchemaDefinitionFactory;\n [key: string]: any;\n};\n\nexport type GraphQLContextPlugin = Plugin & {\n preApply?: (context: GraphQLContext) => void | Promise<void>;\n apply?: (context: GraphQLContext) => void | Promise<void>;\n postApply?: (context: GraphQLContext) => void | Promise<void>;\n};\n\nexport type GraphQLMiddlewarePlugin = Plugin & {\n middleware: (params: { plugins: PluginsContainer }) => Function[];\n};\n\nexport type GraphqlScalarPlugin = Plugin & {\n scalar: GraphQLScalarType;\n};\n\nexport type CreateApolloHandlerPlugin = Plugin & {\n create(params: { plugins: PluginsContainer; schema: GraphQLSchema }): Function;\n};\n\nexport type CreateApolloGatewayPlugin = Plugin & {\n createGateway(params: { plugins: PluginsContainer }): Promise<Function>;\n};\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = GraphQLContext\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n"],"file":"types.js"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * The main context which is constructed on every request.\n * All other contexts should extend or augment this one.\n */\nexport interface Context {\n plugins: PluginsContainer;\n args: any;\n readonly WEBINY_VERSION: string;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n hasResult: () => boolean;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n *\n * @private\n */\n _result?: any;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n setResult: (value: any) => void;\n /**\n * Not to be used outside of Webiny internal code.\n * @internal\n */\n getResult: () => void;\n /**\n * Wait for property to be defined on the object and then execute the callable.\n * In case of multiple objects defined, wait for all of them.\n */\n waitFor: <T extends Context = Context>(\n obj: string[] | string,\n cb: (context: T) => void\n ) => void;\n}\n"],"mappings":""}
@@ -1,19 +0,0 @@
1
- import { GraphQLSchema } from "graphql";
2
- import { PluginsContainer } from "./types";
3
- declare type CreateHandlerParams = {
4
- plugins: PluginsContainer;
5
- };
6
- /**
7
- * Create graphql schema only
8
- * @param plugins
9
- * @returns {Promise<void>}
10
- */
11
- export declare const createSchema: ({ plugins }: CreateHandlerParams) => Promise<GraphQLSchema>;
12
- /**
13
- * Create Apollo handler
14
- */
15
- export declare const createHandler: ({ plugins }: CreateHandlerParams) => Promise<{
16
- schema: GraphQLSchema;
17
- handler: Function;
18
- }>;
19
- export {};
package/createHandler.js DELETED
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createHandler = exports.createSchema = void 0;
7
-
8
- var _graphqlMiddleware = require("graphql-middleware");
9
-
10
- var _graphqlTools = require("graphql-tools");
11
-
12
- var _prepareSchema = require("./graphql/prepareSchema");
13
-
14
- /**
15
- * Create graphql schema only
16
- * @param plugins
17
- * @returns {Promise<void>}
18
- */
19
- const createSchema = async ({
20
- plugins
21
- }) => {
22
- let schema = await (0, _prepareSchema.prepareSchema)({
23
- plugins
24
- });
25
- const registeredMiddleware = [];
26
- const middlewarePlugins = plugins.byType("graphql-middleware");
27
-
28
- for (let i = 0; i < middlewarePlugins.length; i++) {
29
- const plugin = middlewarePlugins[i];
30
- const middleware = typeof plugin.middleware === "function" ? await plugin.middleware({
31
- plugins
32
- }) : plugin.middleware;
33
-
34
- if (Array.isArray(middleware)) {
35
- registeredMiddleware.push(...middleware);
36
- } else {
37
- registeredMiddleware.push(middleware);
38
- }
39
- }
40
-
41
- if (registeredMiddleware.length) {
42
- schema = (0, _graphqlMiddleware.applyMiddleware)(schema, ...registeredMiddleware);
43
- }
44
-
45
- (0, _graphqlTools.addSchemaLevelResolveFunction)(schema, async (root, args, context, info) => {
46
- // Make sure we do not block this resolver from processing subsequent requests!
47
- // This is something that is baked into the graphql-tools and cannot be avoided another way.
48
- delete info.operation["__runAtMostOnce"]; // Process `graphql-context` plugins
49
-
50
- const ctxPlugins = plugins.byType("graphql-context");
51
-
52
- for (let i = 0; i < ctxPlugins.length; i++) {
53
- if (typeof ctxPlugins[i].preApply === "function") {
54
- await ctxPlugins[i].preApply(context);
55
- }
56
- }
57
-
58
- for (let i = 0; i < ctxPlugins.length; i++) {
59
- if (typeof ctxPlugins[i].apply === "function") {
60
- await ctxPlugins[i].apply(context);
61
- }
62
- }
63
-
64
- for (let i = 0; i < ctxPlugins.length; i++) {
65
- if (typeof ctxPlugins[i].postApply === "function") {
66
- await ctxPlugins[i].postApply(context);
67
- }
68
- }
69
- });
70
- return schema;
71
- };
72
- /**
73
- * Create Apollo handler
74
- */
75
-
76
-
77
- exports.createSchema = createSchema;
78
-
79
- const createHandler = async ({
80
- plugins
81
- }) => {
82
- const schema = await createSchema({
83
- plugins
84
- });
85
- const plugin = plugins.byName("create-apollo-handler");
86
-
87
- if (!plugin) {
88
- throw Error(`"create-apollo-handler" plugin is not configured!`);
89
- }
90
-
91
- const handler = await plugin.create({
92
- plugins,
93
- schema
94
- });
95
- return {
96
- schema,
97
- handler
98
- };
99
- };
100
-
101
- exports.createHandler = createHandler;
102
- //# sourceMappingURL=createHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createHandler.ts"],"names":["createSchema","plugins","schema","registeredMiddleware","middlewarePlugins","byType","i","length","plugin","middleware","Array","isArray","push","root","args","context","info","operation","ctxPlugins","preApply","apply","postApply","createHandler","byName","Error","handler","create"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AAMA;;;;;AAKO,MAAMA,YAAY,GAAG,OAAO;AAAEC,EAAAA;AAAF,CAAP,KAAoE;AAC5F,MAAIC,MAAM,GAAG,MAAM,kCAAc;AAAED,IAAAA;AAAF,GAAd,CAAnB;AAEA,QAAME,oBAAoB,GAAG,EAA7B;AAEA,QAAMC,iBAAiB,GAAGH,OAAO,CAACI,MAAR,CAAwC,oBAAxC,CAA1B;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,iBAAiB,CAACG,MAAtC,EAA8CD,CAAC,EAA/C,EAAmD;AAC/C,UAAME,MAAM,GAAGJ,iBAAiB,CAACE,CAAD,CAAhC;AACA,UAAMG,UAAU,GACZ,OAAOD,MAAM,CAACC,UAAd,KAA6B,UAA7B,GACM,MAAMD,MAAM,CAACC,UAAP,CAAkB;AAAER,MAAAA;AAAF,KAAlB,CADZ,GAEMO,MAAM,CAACC,UAHjB;;AAIA,QAAIC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAJ,EAA+B;AAC3BN,MAAAA,oBAAoB,CAACS,IAArB,CAA0B,GAAGH,UAA7B;AACH,KAFD,MAEO;AACHN,MAAAA,oBAAoB,CAACS,IAArB,CAA0BH,UAA1B;AACH;AACJ;;AAED,MAAIN,oBAAoB,CAACI,MAAzB,EAAiC;AAC7BL,IAAAA,MAAM,GAAG,wCAAgBA,MAAhB,EAAwB,GAAGC,oBAA3B,CAAT;AACH;;AAED,mDAA8BD,MAA9B,EAAsC,OAAOW,IAAP,EAAaC,IAAb,EAAmBC,OAAnB,EAA4BC,IAA5B,KAAqC;AACvE;AACA;AACA,WAAOA,IAAI,CAACC,SAAL,CAAe,iBAAf,CAAP,CAHuE,CAKvE;;AACA,UAAMC,UAAU,GAAGjB,OAAO,CAACI,MAAR,CAAqC,iBAArC,CAAnB;;AACA,SAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGY,UAAU,CAACX,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AACxC,UAAI,OAAOY,UAAU,CAACZ,CAAD,CAAV,CAAca,QAArB,KAAkC,UAAtC,EAAkD;AAC9C,cAAMD,UAAU,CAACZ,CAAD,CAAV,CAAca,QAAd,CAAuBJ,OAAvB,CAAN;AACH;AACJ;;AAED,SAAK,IAAIT,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGY,UAAU,CAACX,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AACxC,UAAI,OAAOY,UAAU,CAACZ,CAAD,CAAV,CAAcc,KAArB,KAA+B,UAAnC,EAA+C;AAC3C,cAAMF,UAAU,CAACZ,CAAD,CAAV,CAAcc,KAAd,CAAoBL,OAApB,CAAN;AACH;AACJ;;AAED,SAAK,IAAIT,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGY,UAAU,CAACX,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AACxC,UAAI,OAAOY,UAAU,CAACZ,CAAD,CAAV,CAAce,SAArB,KAAmC,UAAvC,EAAmD;AAC/C,cAAMH,UAAU,CAACZ,CAAD,CAAV,CAAce,SAAd,CAAwBN,OAAxB,CAAN;AACH;AACJ;AACJ,GAxBD;AA0BA,SAAOb,MAAP;AACH,CAlDM;AAoDP;;;;;;;AAGO,MAAMoB,aAAa,GAAG,OAAO;AAAErB,EAAAA;AAAF,CAAP,KAA4C;AACrE,QAAMC,MAAM,GAAG,MAAMF,YAAY,CAAC;AAAEC,IAAAA;AAAF,GAAD,CAAjC;AAEA,QAAMO,MAAM,GAAGP,OAAO,CAACsB,MAAR,CAAe,uBAAf,CAAf;;AAEA,MAAI,CAACf,MAAL,EAAa;AACT,UAAMgB,KAAK,CAAE,mDAAF,CAAX;AACH;;AAED,QAAMC,OAAO,GAAG,MAAMjB,MAAM,CAACkB,MAAP,CAAc;AAAEzB,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAd,CAAtB;AAEA,SAAO;AAAEA,IAAAA,MAAF;AAAUuB,IAAAA;AAAV,GAAP;AACH,CAZM","sourcesContent":["import { applyMiddleware } from \"graphql-middleware\";\nimport { addSchemaLevelResolveFunction } from \"graphql-tools\";\nimport { GraphQLSchema } from \"graphql\";\nimport {\n PluginsContainer,\n GraphQLMiddlewarePlugin,\n GraphQLContextPlugin,\n CreateApolloHandlerPlugin\n} from \"./types\";\nimport { prepareSchema } from \"./graphql/prepareSchema\";\n\ntype CreateHandlerParams = {\n plugins: PluginsContainer;\n};\n\n/**\n * Create graphql schema only\n * @param plugins\n * @returns {Promise<void>}\n */\nexport const createSchema = async ({ plugins }: CreateHandlerParams): Promise<GraphQLSchema> => {\n let schema = await prepareSchema({ plugins });\n\n const registeredMiddleware = [];\n\n const middlewarePlugins = plugins.byType<GraphQLMiddlewarePlugin>(\"graphql-middleware\");\n for (let i = 0; i < middlewarePlugins.length; i++) {\n const plugin = middlewarePlugins[i];\n const middleware =\n typeof plugin.middleware === \"function\"\n ? await plugin.middleware({ plugins })\n : plugin.middleware;\n if (Array.isArray(middleware)) {\n registeredMiddleware.push(...middleware);\n } else {\n registeredMiddleware.push(middleware);\n }\n }\n\n if (registeredMiddleware.length) {\n schema = applyMiddleware(schema, ...registeredMiddleware);\n }\n\n addSchemaLevelResolveFunction(schema, async (root, args, context, info) => {\n // Make sure we do not block this resolver from processing subsequent requests!\n // This is something that is baked into the graphql-tools and cannot be avoided another way.\n delete info.operation[\"__runAtMostOnce\"];\n\n // Process `graphql-context` plugins\n const ctxPlugins = plugins.byType<GraphQLContextPlugin>(\"graphql-context\");\n for (let i = 0; i < ctxPlugins.length; i++) {\n if (typeof ctxPlugins[i].preApply === \"function\") {\n await ctxPlugins[i].preApply(context);\n }\n }\n\n for (let i = 0; i < ctxPlugins.length; i++) {\n if (typeof ctxPlugins[i].apply === \"function\") {\n await ctxPlugins[i].apply(context);\n }\n }\n\n for (let i = 0; i < ctxPlugins.length; i++) {\n if (typeof ctxPlugins[i].postApply === \"function\") {\n await ctxPlugins[i].postApply(context);\n }\n }\n });\n\n return schema;\n};\n\n/**\n * Create Apollo handler\n */\nexport const createHandler = async ({ plugins }: CreateHandlerParams) => {\n const schema = await createSchema({ plugins });\n\n const plugin = plugins.byName(\"create-apollo-handler\") as CreateApolloHandlerPlugin;\n\n if (!plugin) {\n throw Error(`\"create-apollo-handler\" plugin is not configured!`);\n }\n\n const handler = await plugin.create({ plugins, schema });\n\n return { schema, handler };\n};\n"],"file":"createHandler.js"}
@@ -1,2 +0,0 @@
1
- import { GraphQLScalarType } from "graphql";
2
- export declare const RefInput: GraphQLScalarType;
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.RefInput = void 0;
7
-
8
- var _graphql = require("graphql");
9
-
10
- const isMongoId = value => {
11
- if (/^[0-9a-fA-F]{24}$/.test(value)) {
12
- return value;
13
- }
14
-
15
- throw new Error("Must be a valid Mongo ID!");
16
- };
17
-
18
- const RefInput = new _graphql.GraphQLScalarType({
19
- name: "RefInput",
20
- description: "A custom input type to be used with references. Supports plain ID and `{ id: ID }` Object literal.",
21
- serialize: value => {
22
- if (!value || value.id === null) {
23
- return null;
24
- }
25
-
26
- return typeof value === "string" ? value : value.id;
27
- },
28
- parseValue: value => {
29
- if (!value || value.id === null) {
30
- return null;
31
- }
32
-
33
- if (typeof value === "string") {
34
- return isMongoId(value);
35
- }
36
-
37
- if ("id" in value) {
38
- return isMongoId(value.id);
39
- }
40
-
41
- throw new Error("Invalid RefInput value!");
42
- },
43
- parseLiteral: ast => {
44
- if (ast.kind === "StringValue") {
45
- return isMongoId(ast.value);
46
- }
47
-
48
- if (ast.kind === "ObjectValue") {
49
- for (let i = 0; i < ast.fields.length; i++) {
50
- const {
51
- name,
52
- value
53
- } = ast.fields[i];
54
-
55
- if (name.value === "id") {
56
- // @ts-ignore
57
- return isMongoId(value.value);
58
- }
59
- }
60
- }
61
-
62
- throw new Error("Invalid RefInput value!");
63
- }
64
- });
65
- exports.RefInput = RefInput;
66
- //# sourceMappingURL=RefInputScalar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/graphql/RefInputScalar.ts"],"names":["isMongoId","value","test","Error","RefInput","GraphQLScalarType","name","description","serialize","id","parseValue","parseLiteral","ast","kind","i","fields","length"],"mappings":";;;;;;;AAAA;;AAEA,MAAMA,SAAS,GAAIC,KAAD,IAAwB;AACtC,MAAI,oBAAoBC,IAApB,CAAyBD,KAAzB,CAAJ,EAAqC;AACjC,WAAOA,KAAP;AACH;;AAED,QAAM,IAAIE,KAAJ,CAAU,2BAAV,CAAN;AACH,CAND;;AAQO,MAAMC,QAAQ,GAAG,IAAIC,0BAAJ,CAAsB;AAC1CC,EAAAA,IAAI,EAAE,UADoC;AAE1CC,EAAAA,WAAW,EACP,oGAHsC;AAI1CC,EAAAA,SAAS,EAAEP,KAAK,IAAI;AAChB,QAAI,CAACA,KAAD,IAAUA,KAAK,CAACQ,EAAN,KAAa,IAA3B,EAAiC;AAC7B,aAAO,IAAP;AACH;;AAED,WAAO,OAAOR,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCA,KAAK,CAACQ,EAAjD;AACH,GAVyC;AAW1CC,EAAAA,UAAU,EAAET,KAAK,IAAI;AACjB,QAAI,CAACA,KAAD,IAAUA,KAAK,CAACQ,EAAN,KAAa,IAA3B,EAAiC;AAC7B,aAAO,IAAP;AACH;;AAED,QAAI,OAAOR,KAAP,KAAiB,QAArB,EAA+B;AAC3B,aAAOD,SAAS,CAACC,KAAD,CAAhB;AACH;;AAED,QAAI,QAAQA,KAAZ,EAAmB;AACf,aAAOD,SAAS,CAACC,KAAK,CAACQ,EAAP,CAAhB;AACH;;AAED,UAAM,IAAIN,KAAJ,CAAU,yBAAV,CAAN;AACH,GAzByC;AA0B1CQ,EAAAA,YAAY,EAAEC,GAAG,IAAI;AACjB,QAAIA,GAAG,CAACC,IAAJ,KAAa,aAAjB,EAAgC;AAC5B,aAAOb,SAAS,CAACY,GAAG,CAACX,KAAL,CAAhB;AACH;;AAED,QAAIW,GAAG,CAACC,IAAJ,KAAa,aAAjB,EAAgC;AAC5B,WAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,GAAG,CAACG,MAAJ,CAAWC,MAA/B,EAAuCF,CAAC,EAAxC,EAA4C;AACxC,cAAM;AAAER,UAAAA,IAAF;AAAQL,UAAAA;AAAR,YAAkBW,GAAG,CAACG,MAAJ,CAAWD,CAAX,CAAxB;;AACA,YAAIR,IAAI,CAACL,KAAL,KAAe,IAAnB,EAAyB;AACrB;AACA,iBAAOD,SAAS,CAACC,KAAK,CAACA,KAAP,CAAhB;AACH;AACJ;AACJ;;AAED,UAAM,IAAIE,KAAJ,CAAU,yBAAV,CAAN;AACH;AA1CyC,CAAtB,CAAjB","sourcesContent":["import { GraphQLScalarType } from \"graphql\";\n\nconst isMongoId = (value: any): string => {\n if (/^[0-9a-fA-F]{24}$/.test(value)) {\n return value;\n }\n\n throw new Error(\"Must be a valid Mongo ID!\");\n};\n\nexport const RefInput = new GraphQLScalarType({\n name: \"RefInput\",\n description:\n \"A custom input type to be used with references. Supports plain ID and `{ id: ID }` Object literal.\",\n serialize: value => {\n if (!value || value.id === null) {\n return null;\n }\n\n return typeof value === \"string\" ? value : value.id;\n },\n parseValue: value => {\n if (!value || value.id === null) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return isMongoId(value);\n }\n\n if (\"id\" in value) {\n return isMongoId(value.id);\n }\n\n throw new Error(\"Invalid RefInput value!\");\n },\n parseLiteral: ast => {\n if (ast.kind === \"StringValue\") {\n return isMongoId(ast.value);\n }\n\n if (ast.kind === \"ObjectValue\") {\n for (let i = 0; i < ast.fields.length; i++) {\n const { name, value } = ast.fields[i];\n if (name.value === \"id\") {\n // @ts-ignore\n return isMongoId(value.value);\n }\n }\n }\n\n throw new Error(\"Invalid RefInput value!\");\n }\n});\n"],"file":"RefInputScalar.js"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => {};
2
- export default _default;
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _default = () => ({});
9
-
10
- exports.default = _default;
11
- //# sourceMappingURL=emptyResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/graphql/emptyResolver.ts"],"names":[],"mappings":";;;;;;;eAAe,OAAO,EAAP,C","sourcesContent":["export default () => ({});\n"],"file":"emptyResolver.js"}
@@ -1,9 +0,0 @@
1
- import { PluginsContainer } from "../types";
2
- declare type PrepareSchemaParams = {
3
- plugins: PluginsContainer;
4
- };
5
- /**
6
- * @return {schema, context}
7
- */
8
- export declare function prepareSchema({ plugins }: PrepareSchemaParams): Promise<import("graphql").GraphQLSchema>;
9
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.prepareSchema = prepareSchema;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
13
-
14
- var _federation = require("@apollo/federation");
15
-
16
- var _graphqlTypeJson = _interopRequireDefault(require("graphql-type-json"));
17
-
18
- var _graphqlIsoDate = require("graphql-iso-date");
19
-
20
- var _graphqlTypeLong = _interopRequireDefault(require("graphql-type-long"));
21
-
22
- var _RefInputScalar = require("./RefInputScalar");
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
-
28
- /**
29
- * @return {schema, context}
30
- */
31
- async function prepareSchema({
32
- plugins
33
- }) {
34
- // This allows developers to register more plugins dynamically, before the graphql schema is instantiated.
35
- const gqlPlugins = plugins.byType("graphql-schema");
36
-
37
- for (let i = 0; i < gqlPlugins.length; i++) {
38
- if (typeof gqlPlugins[i].prepare === "function") {
39
- await gqlPlugins[i].prepare({
40
- plugins
41
- });
42
- }
43
- }
44
-
45
- const scalars = plugins.byType("graphql-scalar").map(item => item.scalar);
46
- const schemaDefs = [{
47
- typeDefs: (0, _graphqlTag.default)`
48
- ${scalars.map(scalar => `scalar ${scalar.name}`).join(" ")}
49
- scalar JSON
50
- scalar Long
51
- scalar DateTime
52
- scalar RefInput
53
- `,
54
- resolvers: _objectSpread({}, scalars, {
55
- JSON: _graphqlTypeJson.default,
56
- DateTime: _graphqlIsoDate.GraphQLDateTime,
57
- Long: _graphqlTypeLong.default,
58
- RefInput: _RefInputScalar.RefInput
59
- })
60
- }]; // Fetch schema plugins again, in case there were new plugins registered in the meantime.
61
-
62
- const schemaPlugins = plugins.byType("graphql-schema");
63
-
64
- for (let i = 0; i < schemaPlugins.length; i++) {
65
- const {
66
- schema
67
- } = schemaPlugins[i];
68
-
69
- if (!schema) {
70
- continue;
71
- }
72
-
73
- if (typeof schema === "function") {
74
- schemaDefs.push((await schema({
75
- plugins
76
- })));
77
- } else {
78
- schemaDefs.push(schema);
79
- }
80
- } // @ts-ignore
81
-
82
-
83
- return (0, _federation.buildFederatedSchema)([...schemaDefs]);
84
- }
85
- //# sourceMappingURL=prepareSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/graphql/prepareSchema.ts"],"names":["prepareSchema","plugins","gqlPlugins","byType","i","length","prepare","scalars","map","item","scalar","schemaDefs","typeDefs","name","join","resolvers","JSON","GraphQLJSON","DateTime","GraphQLDateTime","Long","GraphQLLong","RefInput","schemaPlugins","schema","push"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAUA;;;AAGO,eAAeA,aAAf,CAA6B;AAAEC,EAAAA;AAAF,CAA7B,EAA+D;AAClE;AACA,QAAMC,UAAU,GAAGD,OAAO,CAACE,MAAR,CAAoC,gBAApC,CAAnB;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,UAAU,CAACG,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AACxC,QAAI,OAAOF,UAAU,CAACE,CAAD,CAAV,CAAcE,OAArB,KAAiC,UAArC,EAAiD;AAC7C,YAAMJ,UAAU,CAACE,CAAD,CAAV,CAAcE,OAAd,CAAsB;AAAEL,QAAAA;AAAF,OAAtB,CAAN;AACH;AACJ;;AAED,QAAMM,OAAO,GAAGN,OAAO,CAClBE,MADW,CACiB,gBADjB,EAEXK,GAFW,CAEPC,IAAI,IAAIA,IAAI,CAACC,MAFN,CAAhB;AAIA,QAAMC,UAA8B,GAAG,CACnC;AACIC,IAAAA,QAAQ,EAAE,wBAAI;kBACRL,OAAO,CAACC,GAAR,CAAYE,MAAM,IAAK,UAASA,MAAM,CAACG,IAAK,EAA5C,EAA+CC,IAA/C,CAAoD,GAApD,CAAyD;;;;;aAFnE;AAQIC,IAAAA,SAAS,oBACFR,OADE;AAELS,MAAAA,IAAI,EAAEC,wBAFD;AAGLC,MAAAA,QAAQ,EAAEC,+BAHL;AAILC,MAAAA,IAAI,EAAEC,wBAJD;AAKLC,MAAAA,QAAQ,EAARA;AALK;AARb,GADmC,CAAvC,CAdkE,CAiClE;;AACA,QAAMC,aAAa,GAAGtB,OAAO,CAACE,MAAR,CAAoC,gBAApC,CAAtB;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGmB,aAAa,CAAClB,MAAlC,EAA0CD,CAAC,EAA3C,EAA+C;AAC3C,UAAM;AAAEoB,MAAAA;AAAF,QAAaD,aAAa,CAACnB,CAAD,CAAhC;;AACA,QAAI,CAACoB,MAAL,EAAa;AACT;AACH;;AAED,QAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC;AAC9Bb,MAAAA,UAAU,CAACc,IAAX,EAAgB,MAAMD,MAAM,CAAC;AAAEvB,QAAAA;AAAF,OAAD,CAA5B;AACH,KAFD,MAEO;AACHU,MAAAA,UAAU,CAACc,IAAX,CAAgBD,MAAhB;AACH;AACJ,GA9CiE,CAgDlE;;;AACA,SAAO,sCAAqB,CAAC,GAAGb,UAAJ,CAArB,CAAP;AACH","sourcesContent":["import gql from \"graphql-tag\";\nimport { buildFederatedSchema } from \"@apollo/federation\";\nimport GraphQLJSON from \"graphql-type-json\";\nimport { GraphQLDateTime } from \"graphql-iso-date\";\nimport GraphQLLong from \"graphql-type-long\";\nimport { RefInput } from \"./RefInputScalar\";\nimport {\n PluginsContainer,\n GraphQLSchemaPlugin,\n GraphqlScalarPlugin,\n SchemaDefinition\n} from \"../types\";\n\ntype PrepareSchemaParams = { plugins: PluginsContainer };\n\n/**\n * @return {schema, context}\n */\nexport async function prepareSchema({ plugins }: PrepareSchemaParams) {\n // This allows developers to register more plugins dynamically, before the graphql schema is instantiated.\n const gqlPlugins = plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\");\n\n for (let i = 0; i < gqlPlugins.length; i++) {\n if (typeof gqlPlugins[i].prepare === \"function\") {\n await gqlPlugins[i].prepare({ plugins });\n }\n }\n\n const scalars = plugins\n .byType<GraphqlScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const schemaDefs: SchemaDefinition[] = [\n {\n typeDefs: gql`\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar DateTime\n scalar RefInput\n `,\n resolvers: {\n ...scalars,\n JSON: GraphQLJSON,\n DateTime: GraphQLDateTime,\n Long: GraphQLLong,\n RefInput\n }\n }\n ];\n\n // Fetch schema plugins again, in case there were new plugins registered in the meantime.\n const schemaPlugins = plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\");\n for (let i = 0; i < schemaPlugins.length; i++) {\n const { schema } = schemaPlugins[i];\n if (!schema) {\n continue;\n }\n\n if (typeof schema === \"function\") {\n schemaDefs.push(await schema({ plugins }));\n } else {\n schemaDefs.push(schema);\n }\n }\n\n // @ts-ignore\n return buildFederatedSchema([...schemaDefs]);\n}\n"],"file":"prepareSchema.js"}
@@ -1,39 +0,0 @@
1
- declare type ErrorResponseParams = {
2
- code?: string;
3
- message?: string;
4
- data?: any;
5
- };
6
- export declare class ErrorResponse {
7
- data: any;
8
- error: {
9
- code: string;
10
- message: string;
11
- data?: any;
12
- };
13
- constructor(params: ErrorResponseParams);
14
- }
15
- export declare class NotFoundResponse extends ErrorResponse {
16
- constructor(message: string);
17
- }
18
- export declare class ListErrorResponse {
19
- data: null;
20
- meta: null;
21
- error: {
22
- code: string;
23
- message: string;
24
- data?: any;
25
- };
26
- constructor(params: ErrorResponseParams);
27
- }
28
- export declare class Response {
29
- data: any;
30
- error: null;
31
- constructor(data: any);
32
- }
33
- export declare class ListResponse {
34
- data: Array<Object>;
35
- meta: Object;
36
- error: null;
37
- constructor(data: Array<Object>, meta?: Object);
38
- }
39
- export {};
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ListResponse = exports.Response = exports.ListErrorResponse = exports.NotFoundResponse = exports.ErrorResponse = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- const defaultParams = {
13
- code: "",
14
- message: "",
15
- data: null
16
- };
17
-
18
- class ErrorResponse {
19
- constructor(params) {
20
- (0, _defineProperty2.default)(this, "data", void 0);
21
- (0, _defineProperty2.default)(this, "error", void 0);
22
- this.data = null;
23
- this.error = {
24
- code: params.code || defaultParams.code,
25
- message: params.message || defaultParams.message,
26
- data: params.data || defaultParams.data
27
- };
28
- }
29
-
30
- }
31
-
32
- exports.ErrorResponse = ErrorResponse;
33
-
34
- class NotFoundResponse extends ErrorResponse {
35
- constructor(message) {
36
- super({
37
- code: "NOT_FOUND",
38
- message
39
- });
40
- }
41
-
42
- }
43
-
44
- exports.NotFoundResponse = NotFoundResponse;
45
-
46
- class ListErrorResponse {
47
- constructor(params) {
48
- (0, _defineProperty2.default)(this, "data", void 0);
49
- (0, _defineProperty2.default)(this, "meta", void 0);
50
- (0, _defineProperty2.default)(this, "error", void 0);
51
- this.data = null;
52
- this.meta = null;
53
- this.error = {
54
- code: params.code || defaultParams.code,
55
- message: params.message || defaultParams.message,
56
- data: params.data || defaultParams.data
57
- };
58
- }
59
-
60
- }
61
-
62
- exports.ListErrorResponse = ListErrorResponse;
63
-
64
- class Response {
65
- constructor(data) {
66
- (0, _defineProperty2.default)(this, "data", void 0);
67
- (0, _defineProperty2.default)(this, "error", void 0);
68
- this.data = data;
69
- this.error = null;
70
- }
71
-
72
- }
73
-
74
- exports.Response = Response;
75
-
76
- class ListResponse {
77
- constructor(data, meta = {}) {
78
- (0, _defineProperty2.default)(this, "data", void 0);
79
- (0, _defineProperty2.default)(this, "meta", void 0);
80
- (0, _defineProperty2.default)(this, "error", void 0);
81
- this.data = Array.isArray(data) ? data : [];
82
- this.meta = meta;
83
- this.error = null;
84
- }
85
-
86
- }
87
-
88
- exports.ListResponse = ListResponse;
89
- //# sourceMappingURL=responses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/graphql/responses.ts"],"names":["defaultParams","code","message","data","ErrorResponse","constructor","params","error","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"mappings":";;;;;;;;;;;AAMA,MAAMA,aAAa,GAAG;AAClBC,EAAAA,IAAI,EAAE,EADY;AAElBC,EAAAA,OAAO,EAAE,EAFS;AAGlBC,EAAAA,IAAI,EAAE;AAHY,CAAtB;;AAMO,MAAMC,aAAN,CAAoB;AAOvBC,EAAAA,WAAW,CAACC,MAAD,EAA8B;AAAA;AAAA;AACrC,SAAKH,IAAL,GAAY,IAAZ;AACA,SAAKI,KAAL,GAAa;AACTN,MAAAA,IAAI,EAAEK,MAAM,CAACL,IAAP,IAAeD,aAAa,CAACC,IAD1B;AAETC,MAAAA,OAAO,EAAEI,MAAM,CAACJ,OAAP,IAAkBF,aAAa,CAACE,OAFhC;AAGTC,MAAAA,IAAI,EAAEG,MAAM,CAACH,IAAP,IAAeH,aAAa,CAACG;AAH1B,KAAb;AAKH;;AAdsB;;;;AAiBpB,MAAMK,gBAAN,SAA+BJ,aAA/B,CAA6C;AAChDC,EAAAA,WAAW,CAACH,OAAD,EAAkB;AACzB,UAAM;AACFD,MAAAA,IAAI,EAAE,WADJ;AAEFC,MAAAA;AAFE,KAAN;AAIH;;AAN+C;;;;AAS7C,MAAMO,iBAAN,CAAwB;AAQ3BJ,EAAAA,WAAW,CAACC,MAAD,EAA8B;AAAA;AAAA;AAAA;AACrC,SAAKH,IAAL,GAAY,IAAZ;AACA,SAAKO,IAAL,GAAY,IAAZ;AACA,SAAKH,KAAL,GAAa;AACTN,MAAAA,IAAI,EAAEK,MAAM,CAACL,IAAP,IAAeD,aAAa,CAACC,IAD1B;AAETC,MAAAA,OAAO,EAAEI,MAAM,CAACJ,OAAP,IAAkBF,aAAa,CAACE,OAFhC;AAGTC,MAAAA,IAAI,EAAEG,MAAM,CAACH,IAAP,IAAeH,aAAa,CAACG;AAH1B,KAAb;AAKH;;AAhB0B;;;;AAmBxB,MAAMQ,QAAN,CAAe;AAGlBN,EAAAA,WAAW,CAACF,IAAD,EAAY;AAAA;AAAA;AACnB,SAAKA,IAAL,GAAYA,IAAZ;AACA,SAAKI,KAAL,GAAa,IAAb;AACH;;AANiB;;;;AASf,MAAMK,YAAN,CAAmB;AAItBP,EAAAA,WAAW,CAACF,IAAD,EAAsBO,IAAY,GAAG,EAArC,EAAyC;AAAA;AAAA;AAAA;AAChD,SAAKP,IAAL,GAAYU,KAAK,CAACC,OAAN,CAAcX,IAAd,IAAsBA,IAAtB,GAA6B,EAAzC;AACA,SAAKO,IAAL,GAAYA,IAAZ;AACA,SAAKH,KAAL,GAAa,IAAb;AACH;;AARqB","sourcesContent":["type ErrorResponseParams = {\n code?: string;\n message?: string;\n data?: any;\n};\n\nconst defaultParams = {\n code: \"\",\n message: \"\",\n data: null\n};\n\nexport class ErrorResponse {\n data: any;\n error: {\n code: string;\n message: string;\n data?: any;\n };\n constructor(params: ErrorResponseParams) {\n this.data = null;\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data\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 data: null;\n meta: null;\n error: {\n code: string;\n message: string;\n data?: any;\n };\n constructor(params: ErrorResponseParams) {\n this.data = null;\n this.meta = null;\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data\n };\n }\n}\n\nexport class Response {\n data: any;\n error: null;\n constructor(data: any) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse {\n data: Array<Object>;\n meta: Object;\n error: null;\n constructor(data: Array<Object>, meta: Object = {}) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta;\n this.error = null;\n }\n}\n"],"file":"responses.js"}
@@ -1,7 +0,0 @@
1
- import { PluginsContainer } from "@webiny/plugins/PluginsContainer";
2
- export declare const setupSchema: (plugins: any) => Promise<{
3
- schema: import("graphql").GraphQLSchema;
4
- context: {
5
- plugins: PluginsContainer;
6
- };
7
- }>;
package/testing/index.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setupSchema = void 0;
7
-
8
- var _index = require("../index");
9
-
10
- var _PluginsContainer = require("@webiny/plugins/PluginsContainer");
11
-
12
- const setupSchema = async plugins => {
13
- const pluginsContainer = new _PluginsContainer.PluginsContainer([plugins]);
14
- const schema = await (0, _index.createSchema)({
15
- plugins: pluginsContainer
16
- });
17
- const context = {
18
- plugins: pluginsContainer
19
- };
20
- return {
21
- schema,
22
- context
23
- };
24
- };
25
-
26
- exports.setupSchema = setupSchema;
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/testing/index.ts"],"names":["setupSchema","plugins","pluginsContainer","PluginsContainer","schema","context"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,WAAW,GAAG,MAAMC,OAAN,IAAiB;AACxC,QAAMC,gBAAgB,GAAG,IAAIC,kCAAJ,CAAqB,CAACF,OAAD,CAArB,CAAzB;AAEA,QAAMG,MAAM,GAAG,MAAM,yBAAa;AAAEH,IAAAA,OAAO,EAAEC;AAAX,GAAb,CAArB;AAEA,QAAMG,OAAO,GAAG;AAAEJ,IAAAA,OAAO,EAAEC;AAAX,GAAhB;AAEA,SAAO;AACHE,IAAAA,MADG;AAEHC,IAAAA;AAFG,GAAP;AAIH,CAXM","sourcesContent":["import { createSchema } from \"../index\";\nimport { PluginsContainer } from \"@webiny/plugins/PluginsContainer\";\n\nexport const setupSchema = async plugins => {\n const pluginsContainer = new PluginsContainer([plugins]);\n\n const schema = await createSchema({ plugins: pluginsContainer });\n\n const context = { plugins: pluginsContainer };\n\n return {\n schema,\n context\n };\n};\n"],"file":"index.js"}