@webiny/app 0.0.0-mt-2 → 0.0.0-unstable.1e66d121db
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/apollo-client/InMemoryCache.d.ts +1 -1
- package/apollo-client/InMemoryCache.js +49 -29
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/components/Image.js +26 -11
- package/components/Image.js.map +1 -0
- package/components/Routes.js +24 -10
- package/components/Routes.js.map +1 -0
- package/components/View.js +27 -9
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +21 -1
- package/components/index.js.map +1 -0
- package/config.d.ts +8 -0
- package/config.js +33 -0
- package/config.js.map +1 -0
- package/contexts/Ui/index.d.ts +5 -4
- package/contexts/Ui/index.js +55 -32
- package/contexts/Ui/index.js.map +1 -0
- package/hooks/useAutocomplete/index.js +13 -1
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -1
- package/hooks/useAutocomplete/useAutocomplete.js +22 -11
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +1 -1
- package/hooks/useDataList/functions/getData.js +16 -4
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +1 -1
- package/hooks/useDataList/functions/getError.js +16 -4
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +1 -1
- package/hooks/useDataList/functions/getMeta.js +16 -4
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.js +31 -3
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +9 -1
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.js +13 -1
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +4 -4
- package/hooks/useDataList/useDataList.js +54 -39
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.js +23 -2
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +10 -3
- package/hooks/useDataList/utils/prepareLoadListParams.js +23 -9
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +13 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +13 -4
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.js +5 -1
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +11 -1
- package/hooks/useHandler.js +13 -5
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +1 -1
- package/hooks/useHandlers.js +16 -5
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useUi.js +16 -5
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.js +21 -5
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.js +15 -1
- package/i18n/index.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +37 -0
- package/index.js.map +1 -0
- package/package.json +28 -23
- package/plugins/AddQuerySelectionPlugin.d.ts +1 -1
- package/plugins/AddQuerySelectionPlugin.js +60 -29
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +8 -8
- package/plugins/ApolloCacheObjectIdPlugin.js +33 -20
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +41 -20
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +5 -5
- package/plugins/ApolloLinkPlugin.js +43 -23
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.js +35 -19
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +3 -2
- package/plugins/LocaleHeaderLinkPlugin.js +37 -21
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +13 -5
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +56 -35
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -2
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +16 -4
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +6 -4
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +20 -9
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.js +42 -22
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.js +29 -15
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +2 -2
- package/plugins/RoutePlugin.js +37 -20
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -2
- package/plugins/TenantHeaderLinkPlugin.js +37 -23
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +4 -4
- package/plugins/ViewPlugin.js +37 -20
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.js +43 -24
- package/plugins/image.js.map +1 -0
- package/plugins/index.js +51 -14
- package/plugins/index.js.map +1 -0
- package/types.d.ts +21 -13
- package/types.js +13 -2
- package/types.js.map +1 -0
package/hooks/useHandlers.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useHandlers = useHandlers;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function useHandlers(props, factories) {
|
|
11
|
+
var propsRef = (0, _react.useRef)(props);
|
|
12
|
+
var handlersRef = (0, _react.useRef)(function () {
|
|
5
13
|
var names = Object.keys(factories);
|
|
6
14
|
return names.reduce(function (handlers, name) {
|
|
15
|
+
/**
|
|
16
|
+
* TODO: figure out args types
|
|
17
|
+
*/
|
|
7
18
|
handlers[name] = function () {
|
|
8
19
|
var handler = factories[name](propsRef.current);
|
|
9
20
|
return handler.apply(void 0, arguments);
|
|
@@ -12,7 +23,7 @@ export function useHandlers(props, factories) {
|
|
|
12
23
|
return handlers;
|
|
13
24
|
}, {});
|
|
14
25
|
}());
|
|
15
|
-
useEffect(function () {
|
|
26
|
+
(0, _react.useEffect)(function () {
|
|
16
27
|
propsRef.current = props;
|
|
17
28
|
});
|
|
18
29
|
return handlersRef.current;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useHandlers","props","factories","propsRef","useRef","handlersRef","names","Object","keys","reduce","handlers","name","handler","current","useEffect"],"sources":["useHandlers.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce((handlers, name) => {\n /**\n * TODO: figure out args types\n */\n handlers[name] = (...args: any) => {\n const handler = factories[name](propsRef.current);\n return handler(...args);\n };\n return handlers;\n }, {} as Record<string, any>);\n })()\n );\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlersRef.current as H;\n}\n"],"mappings":";;;;;;;AAAA;;AAQO,SAASA,WAAT,CAAmCC,KAAnC,EAAwDC,SAAxD,EAAqF;EACxF,IAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAOH,KAAP,CAAjB;EAEA,IAAMI,WAAW,GAAG,IAAAD,aAAA,EACf,YAAM;IACH,IAAME,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYN,SAAZ,CAAd;IACA,OAAOI,KAAK,CAACG,MAAN,CAAa,UAACC,QAAD,EAAWC,IAAX,EAAoB;MACpC;AAChB;AACA;MACgBD,QAAQ,CAACC,IAAD,CAAR,GAAiB,YAAkB;QAC/B,IAAMC,OAAO,GAAGV,SAAS,CAACS,IAAD,CAAT,CAAgBR,QAAQ,CAACU,OAAzB,CAAhB;QACA,OAAOD,OAAO,MAAP,mBAAP;MACH,CAHD;;MAIA,OAAOF,QAAP;IACH,CATM,EASJ,EATI,CAAP;EAUH,CAZD,EADgB,CAApB;EAgBA,IAAAI,gBAAA,EAAU,YAAM;IACZX,QAAQ,CAACU,OAAT,GAAmBZ,KAAnB;EACH,CAFD;EAIA,OAAOI,WAAW,CAACQ,OAAnB;AACH"}
|
package/hooks/useUi.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useUi = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _Ui = require("./../contexts/Ui");
|
|
11
|
+
|
|
12
|
+
var useUi = function useUi() {
|
|
13
|
+
return (0, _react.useContext)(_Ui.UiContext);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.useUi = useUi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useUi","useContext","UiContext"],"sources":["useUi.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { UiContext, UiContextValue } from \"./../contexts/Ui\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,IAAMA,KAAK,GAAG,SAARA,KAAQ,GAAM;EACvB,OAAO,IAAAC,iBAAA,EAAWC,aAAX,CAAP;AACH,CAFM"}
|
package/i18n/i18n.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _i18n = _interopRequireWildcard(require("@webiny/i18n"));
|
|
13
|
+
|
|
14
|
+
var _i18nReact = _interopRequireDefault(require("@webiny/i18n-react"));
|
|
15
|
+
|
|
16
|
+
_i18n.default.registerProcessors([_i18n.defaultProcessor, _i18nReact.default]);
|
|
17
|
+
|
|
18
|
+
_i18n.default.registerModifiers(_i18n.defaultModifiers);
|
|
19
|
+
|
|
20
|
+
var _default = _i18n.default;
|
|
21
|
+
exports.default = _default;
|
package/i18n/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["i18n","registerProcessors","defaultProcessor","reactProcessor","registerModifiers","defaultModifiers"],"sources":["i18n.ts"],"sourcesContent":["import i18n, { defaultProcessor, defaultModifiers } from \"@webiny/i18n\";\nimport reactProcessor from \"@webiny/i18n-react\";\n\ni18n.registerProcessors([defaultProcessor, reactProcessor]);\ni18n.registerModifiers(defaultModifiers);\n\nexport default i18n;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEAA,aAAA,CAAKC,kBAAL,CAAwB,CAACC,sBAAD,EAAmBC,kBAAnB,CAAxB;;AACAH,aAAA,CAAKI,iBAAL,CAAuBC,sBAAvB;;eAEeL,a"}
|
package/i18n/index.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "i18n", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _i18n.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _i18n = _interopRequireDefault(require("./i18n"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as i18n } from \"./i18n\";\n"],"mappings":";;;;;;;;;;;;;;AAAA"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin";
|
|
2
|
+
export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin";
|
|
3
|
+
export { RoutePlugin } from "./plugins/RoutePlugin";
|
|
4
|
+
export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin";
|
package/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AddQuerySelectionPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ApolloCacheObjectIdPlugin", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ApolloCacheObjectIdPlugin.ApolloCacheObjectIdPlugin;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ApolloLinkPlugin", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _ApolloLinkPlugin.ApolloLinkPlugin;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "RoutePlugin", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _RoutePlugin.RoutePlugin;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var _AddQuerySelectionPlugin = require("./plugins/AddQuerySelectionPlugin");
|
|
32
|
+
|
|
33
|
+
var _ApolloLinkPlugin = require("./plugins/ApolloLinkPlugin");
|
|
34
|
+
|
|
35
|
+
var _RoutePlugin = require("./plugins/RoutePlugin");
|
|
36
|
+
|
|
37
|
+
var _ApolloCacheObjectIdPlugin = require("./plugins/ApolloCacheObjectIdPlugin");
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin\";\nexport { RoutePlugin } from \"./plugins/RoutePlugin\";\nexport { ApolloCacheObjectIdPlugin } from \"./plugins/ApolloCacheObjectIdPlugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.1e66d121db",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,41 +15,45 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@apollo/react-hooks": "3.1.5",
|
|
18
|
-
"@babel/runtime": "7.
|
|
19
|
-
"@emotion/styled": "10.0
|
|
20
|
-
"@types/react": "
|
|
21
|
-
"@
|
|
22
|
-
"@webiny/i18n
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
18
|
+
"@babel/runtime": "7.19.0",
|
|
19
|
+
"@emotion/styled": "10.3.0",
|
|
20
|
+
"@types/react": "17.0.39",
|
|
21
|
+
"@types/web": "0.0.61",
|
|
22
|
+
"@webiny/i18n": "0.0.0-unstable.1e66d121db",
|
|
23
|
+
"@webiny/i18n-react": "0.0.0-unstable.1e66d121db",
|
|
24
|
+
"@webiny/plugins": "0.0.0-unstable.1e66d121db",
|
|
25
|
+
"@webiny/react-router": "0.0.0-unstable.1e66d121db",
|
|
26
|
+
"@webiny/ui": "0.0.0-unstable.1e66d121db",
|
|
26
27
|
"apollo-cache": "1.3.5",
|
|
27
28
|
"apollo-cache-inmemory": "1.6.6",
|
|
28
29
|
"apollo-client": "2.6.10",
|
|
29
30
|
"apollo-link": "1.2.14",
|
|
30
31
|
"apollo-link-context": "1.0.20",
|
|
31
32
|
"apollo-link-error": "1.1.13",
|
|
33
|
+
"apollo-link-http-common": "0.2.16",
|
|
32
34
|
"apollo-utilities": "1.3.4",
|
|
33
|
-
"boolean": "3.
|
|
34
|
-
"graphql": "
|
|
35
|
+
"boolean": "3.2.0",
|
|
36
|
+
"graphql": "15.8.0",
|
|
35
37
|
"invariant": "2.2.4",
|
|
36
38
|
"lodash": "4.17.21",
|
|
37
|
-
"
|
|
38
|
-
"react
|
|
39
|
+
"nanoid": "3.3.4",
|
|
40
|
+
"react": "17.0.2",
|
|
41
|
+
"react-dom": "17.0.2",
|
|
39
42
|
"warning": "4.0.3"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@babel/cli": "^7.
|
|
43
|
-
"@babel/core": "^7.
|
|
44
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
45
|
-
"@babel/preset-env": "^7.
|
|
46
|
-
"@babel/preset-react": "^7.
|
|
47
|
-
"@babel/preset-typescript": "^7.
|
|
48
|
-
"@
|
|
49
|
-
"@webiny/
|
|
45
|
+
"@babel/cli": "^7.19.3",
|
|
46
|
+
"@babel/core": "^7.19.3",
|
|
47
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
48
|
+
"@babel/preset-env": "^7.19.4",
|
|
49
|
+
"@babel/preset-react": "^7.18.6",
|
|
50
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
51
|
+
"@types/warning": "^3.0.0",
|
|
52
|
+
"@webiny/cli": "^0.0.0-unstable.1e66d121db",
|
|
53
|
+
"@webiny/project-utils": "^0.0.0-unstable.1e66d121db",
|
|
50
54
|
"babel-plugin-lodash": "^3.3.4",
|
|
51
55
|
"rimraf": "^3.0.2",
|
|
52
|
-
"typescript": "
|
|
56
|
+
"typescript": "4.7.4"
|
|
53
57
|
},
|
|
54
58
|
"publishConfig": {
|
|
55
59
|
"access": "public",
|
|
@@ -62,9 +66,10 @@
|
|
|
62
66
|
"adio": {
|
|
63
67
|
"ignore": {
|
|
64
68
|
"dependencies": [
|
|
69
|
+
"@types/web",
|
|
65
70
|
"react-dom"
|
|
66
71
|
]
|
|
67
72
|
}
|
|
68
73
|
},
|
|
69
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "b670bf27c5039de1a2b0be764a09ba4cb94ad5e2"
|
|
70
75
|
}
|
|
@@ -7,7 +7,7 @@ interface Config {
|
|
|
7
7
|
addSelection: DocumentNode;
|
|
8
8
|
}
|
|
9
9
|
export declare class AddQuerySelectionPlugin extends ApolloLinkPlugin {
|
|
10
|
-
private config;
|
|
10
|
+
private readonly config;
|
|
11
11
|
constructor(config: Config);
|
|
12
12
|
createLink(): ApolloLink;
|
|
13
13
|
addSelectionToQuery(operationName: string, query: DocumentNode): void;
|
|
@@ -1,37 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import { ApolloLink } from "apollo-link";
|
|
10
|
-
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
11
|
-
export var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
12
|
-
_inherits(AddQuerySelectionPlugin, _ApolloLinkPlugin);
|
|
13
|
-
|
|
14
|
-
var _super = _createSuper(AddQuerySelectionPlugin);
|
|
1
|
+
"use strict";
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
var _this;
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
18
4
|
|
|
19
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.AddQuerySelectionPlugin = void 0;
|
|
20
9
|
|
|
21
|
-
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
24
21
|
|
|
22
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _apolloLink = require("apollo-link");
|
|
27
|
+
|
|
28
|
+
var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
|
|
29
|
+
|
|
30
|
+
var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
31
|
+
(0, _inherits2.default)(AddQuerySelectionPlugin, _ApolloLinkPlugin);
|
|
32
|
+
|
|
33
|
+
var _super = (0, _createSuper2.default)(AddQuerySelectionPlugin);
|
|
34
|
+
|
|
35
|
+
function AddQuerySelectionPlugin(config) {
|
|
36
|
+
var _this;
|
|
37
|
+
|
|
38
|
+
(0, _classCallCheck2.default)(this, AddQuerySelectionPlugin);
|
|
39
|
+
_this = _super.call(this);
|
|
40
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "config", void 0);
|
|
25
41
|
_this.config = config;
|
|
26
42
|
return _this;
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
(0, _createClass2.default)(AddQuerySelectionPlugin, [{
|
|
30
46
|
key: "createLink",
|
|
31
47
|
value: function createLink() {
|
|
32
48
|
var _this2 = this;
|
|
33
49
|
|
|
34
|
-
return new ApolloLink(function (operation, forward) {
|
|
50
|
+
return new _apolloLink.ApolloLink(function (operation, forward) {
|
|
35
51
|
if (operation.operationName !== _this2.config.operationName) {
|
|
36
52
|
return forward(operation);
|
|
37
53
|
}
|
|
@@ -53,25 +69,36 @@ export var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
53
69
|
var _this$config = this.config,
|
|
54
70
|
addSelection = _this$config.addSelection,
|
|
55
71
|
selectionPath = _this$config.selectionPath; // TODO: check if the selection is already in the query and don't add it again if not necessary.
|
|
56
|
-
// @ts-ignore
|
|
57
72
|
|
|
58
|
-
var
|
|
73
|
+
var firstQueryDefinition = query.definitions[0];
|
|
74
|
+
|
|
75
|
+
if (!firstQueryDefinition) {
|
|
76
|
+
return;
|
|
77
|
+
} else if (!firstQueryDefinition.selectionSet) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var tree = firstQueryDefinition.selectionSet.selections;
|
|
59
82
|
var fields = selectionPath.split(".");
|
|
60
83
|
|
|
61
|
-
var _iterator =
|
|
84
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(fields),
|
|
62
85
|
_step;
|
|
63
86
|
|
|
64
87
|
try {
|
|
65
88
|
fieldLoop: for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
89
|
var field = _step.value;
|
|
67
90
|
|
|
68
|
-
var _iterator2 =
|
|
91
|
+
var _iterator2 = (0, _createForOfIteratorHelper2.default)(tree),
|
|
69
92
|
_step2;
|
|
70
93
|
|
|
71
94
|
try {
|
|
72
95
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
73
96
|
var selection = _step2.value;
|
|
74
97
|
|
|
98
|
+
if (!selection.selectionSet) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
75
102
|
if (selection.name.value === field) {
|
|
76
103
|
tree = selection.selectionSet.selections;
|
|
77
104
|
continue fieldLoop;
|
|
@@ -90,12 +117,16 @@ export var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
90
117
|
_iterator.e(err);
|
|
91
118
|
} finally {
|
|
92
119
|
_iterator.f();
|
|
93
|
-
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* We must cast because there are a lot of types that are not intertwined and TS is complaining
|
|
123
|
+
*/
|
|
94
124
|
|
|
95
125
|
|
|
96
|
-
(_tree = tree).push.apply(_tree,
|
|
126
|
+
(_tree = tree).push.apply(_tree, (0, _toConsumableArray2.default)(addSelection.definitions[0].selectionSet.selections));
|
|
97
127
|
}
|
|
98
128
|
}]);
|
|
99
|
-
|
|
100
129
|
return AddQuerySelectionPlugin;
|
|
101
|
-
}(ApolloLinkPlugin);
|
|
130
|
+
}(_ApolloLinkPlugin2.ApolloLinkPlugin);
|
|
131
|
+
|
|
132
|
+
exports.AddQuerySelectionPlugin = AddQuerySelectionPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AddQuerySelectionPlugin","config","ApolloLink","operation","forward","operationName","addSelectionToQuery","query","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","ApolloLinkPlugin"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast\";\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, query: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n const { addSelection, selectionPath } = this.config;\n\n // TODO: check if the selection is already in the query and don't add it again if not necessary.\n\n const firstQueryDefinition = query.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;IASaA,uB;;;;;EAGT,iCAAYC,MAAZ,EAA4B;IAAA;;IAAA;IACxB;IADwB;IAExB,MAAKA,MAAL,GAAcA,MAAd;IAFwB;EAG3B;;;;WAED,sBAAyC;MAAA;;MACrC,OAAO,IAAIC,sBAAJ,CAAe,UAACC,SAAD,EAAYC,OAAZ,EAAwB;QAC1C,IAAID,SAAS,CAACE,aAAV,KAA4B,MAAI,CAACJ,MAAL,CAAYI,aAA5C,EAA2D;UACvD,OAAOD,OAAO,CAACD,SAAD,CAAd;QACH;;QAED,MAAI,CAACG,mBAAL,CAAyBH,SAAS,CAACE,aAAnC,EAAkDF,SAAS,CAACI,KAA5D;;QAEA,OAAOH,OAAO,CAACD,SAAD,CAAd;MACH,CARM,CAAP;IASH;;;WAED,6BAA2BE,aAA3B,EAAkDE,KAAlD,EAA6E;MAAA;;MACzE,IAAIF,aAAa,KAAK,KAAKJ,MAAL,CAAYI,aAAlC,EAAiD;QAC7C;MACH;;MAED,mBAAwC,KAAKJ,MAA7C;MAAA,IAAQO,YAAR,gBAAQA,YAAR;MAAA,IAAsBC,aAAtB,gBAAsBA,aAAtB,CALyE,CAOzE;;MAEA,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,WAAN,CAAkB,CAAlB,CAA7B;;MACA,IAAI,CAACD,oBAAL,EAA2B;QACvB;MACH,CAFD,MAEO,IAAI,CAACA,oBAAoB,CAACE,YAA1B,EAAwC;QAC3C;MACH;;MAED,IAAIC,IAAI,GAAGH,oBAAoB,CAACE,YAArB,CAAkCE,UAA7C;MACA,IAAMC,MAAM,GAAGN,aAAa,CAACO,KAAd,CAAoB,GAApB,CAAf;;MAjByE,yDAmB1CD,MAnB0C;MAAA;;MAAA;QAmBzEE,SAnByE,EAmB9D,oDAA4B;UAAA,IAAjBC,KAAiB;;UAAA,0DACXL,IADW;UAAA;;UAAA;YACnC,uDAA8B;cAAA,IAAnBM,SAAmB;;cAC1B,IAAI,CAACA,SAAS,CAACP,YAAf,EAA6B;gBACzB;cACH;;cACD,IAAIO,SAAS,CAACC,IAAV,CAAeC,KAAf,KAAyBH,KAA7B,EAAoC;gBAChCL,IAAI,GAAGM,SAAS,CAACP,YAAV,CAAuBE,UAA9B;gBACA,SAASG,SAAT;cACH;YACJ,CATkC,CAUnC;;UAVmC;YAAA;UAAA;YAAA;UAAA;;UAWnC;QACH;MA/BwE;QAAA;MAAA;QAAA;MAAA;MAgCzE;AACR;AACA;;;MACQ,SAAAJ,IAAI,EAACS,IAAL,+CACSd,YAAY,CAACG,WAAb,CAAyB,CAAzB,CAAD,CAA0DC,YAA1D,CACCE,UAFT;IAIH;;;EA3DwCS,mC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
export interface
|
|
2
|
+
export interface ApolloCacheObject {
|
|
3
3
|
__typename?: string;
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
7
|
-
(data: T):
|
|
6
|
+
interface ApolloCacheObjectIdPluginCallable<T> {
|
|
7
|
+
(data: T): string | null | undefined;
|
|
8
8
|
}
|
|
9
|
-
export declare class ApolloCacheObjectIdPlugin<T extends
|
|
10
|
-
static readonly type
|
|
11
|
-
private _getObjectId
|
|
12
|
-
constructor(getObjectId?:
|
|
13
|
-
getObjectId(data: T):
|
|
9
|
+
export declare class ApolloCacheObjectIdPlugin<T extends ApolloCacheObject = ApolloCacheObject> extends Plugin {
|
|
10
|
+
static readonly type: string;
|
|
11
|
+
private readonly _getObjectId?;
|
|
12
|
+
constructor(getObjectId?: ApolloCacheObjectIdPluginCallable<T>);
|
|
13
|
+
getObjectId(data: T): string | null | undefined;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
|
@@ -1,29 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
import { Plugin } from "@webiny/plugins";
|
|
8
|
-
export var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
|
|
9
|
-
_inherits(ApolloCacheObjectIdPlugin, _Plugin);
|
|
10
|
-
|
|
11
|
-
var _super = _createSuper(ApolloCacheObjectIdPlugin);
|
|
1
|
+
"use strict";
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
var _this;
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
15
4
|
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ApolloCacheObjectIdPlugin = void 0;
|
|
17
9
|
|
|
18
|
-
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
var _plugins = require("@webiny/plugins");
|
|
21
23
|
|
|
24
|
+
var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
|
|
25
|
+
(0, _inherits2.default)(ApolloCacheObjectIdPlugin, _Plugin);
|
|
26
|
+
|
|
27
|
+
var _super = (0, _createSuper2.default)(ApolloCacheObjectIdPlugin);
|
|
28
|
+
|
|
29
|
+
function ApolloCacheObjectIdPlugin(getObjectId) {
|
|
30
|
+
var _this;
|
|
31
|
+
|
|
32
|
+
(0, _classCallCheck2.default)(this, ApolloCacheObjectIdPlugin);
|
|
33
|
+
_this = _super.call(this);
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_getObjectId", void 0);
|
|
22
35
|
_this._getObjectId = getObjectId;
|
|
23
36
|
return _this;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
|
|
39
|
+
(0, _createClass2.default)(ApolloCacheObjectIdPlugin, [{
|
|
27
40
|
key: "getObjectId",
|
|
28
41
|
value: function getObjectId(data) {
|
|
29
42
|
if (typeof this._getObjectId !== "function") {
|
|
@@ -33,8 +46,8 @@ export var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
|
|
|
33
46
|
return this._getObjectId(data);
|
|
34
47
|
}
|
|
35
48
|
}]);
|
|
36
|
-
|
|
37
49
|
return ApolloCacheObjectIdPlugin;
|
|
38
|
-
}(Plugin);
|
|
50
|
+
}(_plugins.Plugin);
|
|
39
51
|
|
|
40
|
-
|
|
52
|
+
exports.ApolloCacheObjectIdPlugin = ApolloCacheObjectIdPlugin;
|
|
53
|
+
(0, _defineProperty2.default)(ApolloCacheObjectIdPlugin, "type", "cache-get-object-id");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApolloCacheObjectIdPlugin","getObjectId","_getObjectId","data","Error","Plugin"],"sources":["ApolloCacheObjectIdPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport interface ApolloCacheObject {\n __typename?: string;\n [key: string]: any;\n}\n\ninterface ApolloCacheObjectIdPluginCallable<T> {\n // A value for `id`, null to prevent normalization, or undefined to continue with defaults.\n (data: T): string | null | undefined;\n}\n\nexport class ApolloCacheObjectIdPlugin<\n T extends ApolloCacheObject = ApolloCacheObject\n> extends Plugin {\n public static override readonly type: string = \"cache-get-object-id\";\n private readonly _getObjectId?: ApolloCacheObjectIdPluginCallable<T>;\n\n public constructor(getObjectId?: ApolloCacheObjectIdPluginCallable<T>) {\n super();\n this._getObjectId = getObjectId;\n }\n\n public getObjectId(data: T) {\n if (typeof this._getObjectId !== \"function\") {\n throw Error(\n `You must provide a \"getObjectId\" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.`\n );\n }\n\n return this._getObjectId(data);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;IAYaA,yB;;;;;EAMT,mCAAmBC,WAAnB,EAAuE;IAAA;;IAAA;IACnE;IADmE;IAEnE,MAAKC,YAAL,GAAoBD,WAApB;IAFmE;EAGtE;;;;WAED,qBAAmBE,IAAnB,EAA4B;MACxB,IAAI,OAAO,KAAKD,YAAZ,KAA6B,UAAjC,EAA6C;QACzC,MAAME,KAAK,kHAAX;MAGH;;MAED,OAAO,KAAKF,YAAL,CAAkBC,IAAlB,CAAP;IACH;;;EAjBKE,e;;;8BAFGL,yB,UAGsC,qB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ApolloLink } from "apollo-link";
|
|
1
|
+
import { ApolloLink, NextLink } from "apollo-link";
|
|
2
|
+
import { Operation } from "apollo-link/lib/types";
|
|
2
3
|
export declare class ApolloDynamicLink extends ApolloLink {
|
|
3
4
|
private cache;
|
|
4
|
-
request(operation:
|
|
5
|
+
request(operation: Operation, forward: NextLink): any;
|
|
5
6
|
}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ApolloDynamicLink = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _apolloLink = require("apollo-link");
|
|
23
|
+
|
|
24
|
+
var _plugins = require("@webiny/plugins");
|
|
9
25
|
|
|
10
26
|
function createLink(plugin) {
|
|
11
27
|
try {
|
|
@@ -14,33 +30,33 @@ function createLink(plugin) {
|
|
|
14
30
|
console.error("Caught an error while executing \"createLink\" on plugin", plugin);
|
|
15
31
|
console.error(e);
|
|
16
32
|
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
17
35
|
}
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
|
|
38
|
+
(0, _inherits2.default)(ApolloDynamicLink, _ApolloLink);
|
|
21
39
|
|
|
22
|
-
var _super =
|
|
40
|
+
var _super = (0, _createSuper2.default)(ApolloDynamicLink);
|
|
23
41
|
|
|
24
42
|
function ApolloDynamicLink() {
|
|
25
43
|
var _this;
|
|
26
44
|
|
|
27
|
-
|
|
45
|
+
(0, _classCallCheck2.default)(this, ApolloDynamicLink);
|
|
28
46
|
|
|
29
47
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
48
|
args[_key] = arguments[_key];
|
|
31
49
|
}
|
|
32
50
|
|
|
33
51
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "cache", new Map());
|
|
36
|
-
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cache", new Map());
|
|
37
53
|
return _this;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
|
-
|
|
56
|
+
(0, _createClass2.default)(ApolloDynamicLink, [{
|
|
41
57
|
key: "request",
|
|
42
58
|
value: function request(operation, forward) {
|
|
43
|
-
var linkPlugins = plugins.byType("apollo-link");
|
|
59
|
+
var linkPlugins = _plugins.plugins.byType("apollo-link");
|
|
44
60
|
|
|
45
61
|
if (!linkPlugins.length) {
|
|
46
62
|
return forward(operation);
|
|
@@ -51,12 +67,17 @@ export var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
|
|
|
51
67
|
}).join(",");
|
|
52
68
|
|
|
53
69
|
if (!this.cache.has(cacheKey)) {
|
|
54
|
-
|
|
70
|
+
/**
|
|
71
|
+
* We filter out falsy items from the linkPlugins because there might be some error while creating link.
|
|
72
|
+
*/
|
|
73
|
+
var links = linkPlugins.map(createLink).filter(Boolean);
|
|
74
|
+
this.cache.set(cacheKey, _apolloLink.ApolloLink.from(links));
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
return this.cache.get(cacheKey).request(operation, forward);
|
|
58
78
|
}
|
|
59
79
|
}]);
|
|
60
|
-
|
|
61
80
|
return ApolloDynamicLink;
|
|
62
|
-
}(ApolloLink);
|
|
81
|
+
}(_apolloLink.ApolloLink);
|
|
82
|
+
|
|
83
|
+
exports.ApolloDynamicLink = ApolloDynamicLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createLink","plugin","e","console","error","ApolloDynamicLink","Map","operation","forward","linkPlugins","plugins","byType","length","cacheKey","map","pl","join","cache","has","links","filter","Boolean","set","ApolloLink","from","get","request"],"sources":["ApolloDynamicLink.ts"],"sourcesContent":["import { ApolloLink, NextLink } from \"apollo-link\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { Operation } from \"apollo-link/lib/types\";\n\nfunction createLink(plugin: ApolloLinkPlugin) {\n try {\n return plugin.createLink();\n } catch (e) {\n console.error(`Caught an error while executing \"createLink\" on plugin`, plugin);\n console.error(e);\n }\n return null;\n}\n\nexport class ApolloDynamicLink extends ApolloLink {\n private cache = new Map();\n\n public override request(operation: Operation, forward: NextLink) {\n const linkPlugins = plugins.byType<ApolloLinkPlugin>(\"apollo-link\");\n\n if (!linkPlugins.length) {\n return forward(operation);\n }\n\n const cacheKey = linkPlugins.map(pl => pl.cacheKey).join(\",\");\n\n if (!this.cache.has(cacheKey)) {\n /**\n * We filter out falsy items from the linkPlugins because there might be some error while creating link.\n */\n const links = linkPlugins.map(createLink).filter(Boolean) as ApolloLink[];\n this.cache.set(cacheKey, ApolloLink.from(links));\n }\n\n return this.cache.get(cacheKey).request(operation, forward);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA,SAASA,UAAT,CAAoBC,MAApB,EAA8C;EAC1C,IAAI;IACA,OAAOA,MAAM,CAACD,UAAP,EAAP;EACH,CAFD,CAEE,OAAOE,CAAP,EAAU;IACRC,OAAO,CAACC,KAAR,6DAAwEH,MAAxE;IACAE,OAAO,CAACC,KAAR,CAAcF,CAAd;EACH;;EACD,OAAO,IAAP;AACH;;IAEYG,iB;;;;;;;;;;;;;;;wFACO,IAAIC,GAAJ,E;;;;;;WAEhB,iBAAwBC,SAAxB,EAA8CC,OAA9C,EAAiE;MAC7D,IAAMC,WAAW,GAAGC,gBAAA,CAAQC,MAAR,CAAiC,aAAjC,CAApB;;MAEA,IAAI,CAACF,WAAW,CAACG,MAAjB,EAAyB;QACrB,OAAOJ,OAAO,CAACD,SAAD,CAAd;MACH;;MAED,IAAMM,QAAQ,GAAGJ,WAAW,CAACK,GAAZ,CAAgB,UAAAC,EAAE;QAAA,OAAIA,EAAE,CAACF,QAAP;MAAA,CAAlB,EAAmCG,IAAnC,CAAwC,GAAxC,CAAjB;;MAEA,IAAI,CAAC,KAAKC,KAAL,CAAWC,GAAX,CAAeL,QAAf,CAAL,EAA+B;QAC3B;AACZ;AACA;QACY,IAAMM,KAAK,GAAGV,WAAW,CAACK,GAAZ,CAAgBd,UAAhB,EAA4BoB,MAA5B,CAAmCC,OAAnC,CAAd;QACA,KAAKJ,KAAL,CAAWK,GAAX,CAAeT,QAAf,EAAyBU,sBAAA,CAAWC,IAAX,CAAgBL,KAAhB,CAAzB;MACH;;MAED,OAAO,KAAKF,KAAL,CAAWQ,GAAX,CAAeZ,QAAf,EAAyBa,OAAzB,CAAiCnB,SAAjC,EAA4CC,OAA5C,CAAP;IACH;;;EArBkCe,sB"}
|