@webiny/app 5.34.8 → 5.35.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +15 -37
- package/App.js.map +1 -1
- package/apollo-client/InMemoryCache.js +1 -24
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/components/Image.js +1 -14
- package/components/Image.js.map +1 -1
- package/components/Routes.js +8 -14
- package/components/Routes.js.map +1 -1
- package/components/View.js +3 -14
- package/components/View.js.map +1 -1
- package/components/index.js +0 -2
- package/components/index.js.map +1 -1
- package/config.js +0 -3
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +0 -22
- package/contexts/Ui/index.js.map +1 -1
- package/core/AddRoute.js +1 -8
- package/core/AddRoute.js.map +1 -1
- package/core/DebounceRender.js +5 -15
- package/core/DebounceRender.js.map +1 -1
- package/core/Plugin.d.ts +8 -0
- package/core/Plugin.js +21 -0
- package/core/Plugin.js.map +1 -0
- package/core/Plugins.d.ts +4 -0
- package/core/Plugins.js +6 -13
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +1 -7
- package/core/Provider.js.map +1 -1
- package/core/Routes.js +6 -13
- package/core/Routes.js.map +1 -1
- package/core/createProvider.d.ts +6 -0
- package/core/createProvider.js +13 -0
- package/core/createProvider.js.map +1 -0
- package/core/createProviderPlugin.d.ts +0 -1
- package/core/createProviderPlugin.js +1 -12
- package/core/createProviderPlugin.js.map +1 -1
- package/hooks/useAutocomplete/index.js +0 -1
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +0 -9
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +0 -4
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +0 -4
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +0 -4
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -4
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +0 -6
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -1
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.js +6 -32
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -3
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +0 -10
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +1 -3
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -1
- package/hooks/useHandler.js +0 -2
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +0 -3
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useUi.js +0 -4
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +0 -7
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/i18n/index.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +24 -18
- package/index.js.map +1 -1
- package/package.json +12 -12
- package/plugins/AddQuerySelectionPlugin.d.ts +8 -1
- package/plugins/AddQuerySelectionPlugin.js +31 -41
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +0 -15
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +0 -23
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +0 -17
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +0 -15
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -5
- package/plugins/LocaleHeaderLinkPlugin.js +2 -26
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +5 -25
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +9 -3
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +0 -3
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +8 -15
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +3 -20
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +1 -15
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/RoutePlugin.js +0 -15
- package/plugins/RoutePlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +0 -5
- package/plugins/TenantHeaderLinkPlugin.js +2 -27
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/ViewPlugin.js +0 -15
- package/plugins/ViewPlugin.js.map +1 -1
- package/plugins/image.js +12 -45
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +12 -33
- package/plugins/index.js.map +1 -1
- package/types.d.ts +4 -2
- package/types.js +0 -1
- package/types.js.map +1 -1
- package/utils/getApiUrl.d.ts +1 -0
- package/utils/getApiUrl.js +11 -0
- package/utils/getApiUrl.js.map +1 -0
- package/utils/getGqlApiUrl.d.ts +1 -0
- package/utils/getGqlApiUrl.js +11 -0
- package/utils/getGqlApiUrl.js.map +1 -0
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
- package/utils/getHeadlessCmsGqlApiUrl.js +17 -0
- package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
- package/utils/getLocaleCode.d.ts +6 -0
- package/utils/getLocaleCode.js +42 -0
- package/utils/getLocaleCode.js.map +1 -0
- package/utils/getPrerenderId.d.ts +6 -0
- package/utils/getPrerenderId.js +10 -0
- package/utils/getPrerenderId.js.map +1 -0
- package/utils/getTenantId.d.ts +6 -0
- package/utils/getTenantId.js +34 -0
- package/utils/getTenantId.js.map +1 -0
- package/utils/index.d.ts +8 -0
- package/utils/index.js +93 -0
- package/utils/index.js.map +1 -0
- package/utils/isLocalhost.d.ts +1 -0
- package/utils/isLocalhost.js +14 -0
- package/utils/isLocalhost.js.map +1 -0
- package/utils/isPrerendering.d.ts +1 -0
- package/utils/isPrerendering.js +10 -0
- package/utils/isPrerendering.js.map +1 -0
|
@@ -1,116 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.AddQuerySelectionPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
-
|
|
20
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
14
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
23
|
-
|
|
24
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
16
|
var _apolloLink = require("apollo-link");
|
|
27
|
-
|
|
17
|
+
var _graphql = require("graphql");
|
|
28
18
|
var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
|
|
29
|
-
|
|
30
19
|
var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
31
20
|
(0, _inherits2.default)(AddQuerySelectionPlugin, _ApolloLinkPlugin);
|
|
32
|
-
|
|
33
21
|
var _super = (0, _createSuper2.default)(AddQuerySelectionPlugin);
|
|
34
|
-
|
|
35
22
|
function AddQuerySelectionPlugin(config) {
|
|
36
23
|
var _this;
|
|
37
|
-
|
|
38
24
|
(0, _classCallCheck2.default)(this, AddQuerySelectionPlugin);
|
|
39
25
|
_this = _super.call(this);
|
|
40
26
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "config", void 0);
|
|
41
27
|
_this.config = config;
|
|
42
28
|
return _this;
|
|
43
29
|
}
|
|
44
|
-
|
|
45
30
|
(0, _createClass2.default)(AddQuerySelectionPlugin, [{
|
|
46
31
|
key: "createLink",
|
|
47
32
|
value: function createLink() {
|
|
48
33
|
var _this2 = this;
|
|
49
|
-
|
|
50
34
|
return new _apolloLink.ApolloLink(function (operation, forward) {
|
|
51
35
|
if (operation.operationName !== _this2.config.operationName) {
|
|
52
36
|
return forward(operation);
|
|
53
37
|
}
|
|
54
|
-
|
|
55
38
|
_this2.addSelectionToQuery(operation.operationName, operation.query);
|
|
56
|
-
|
|
57
39
|
return forward(operation);
|
|
58
40
|
});
|
|
59
41
|
}
|
|
60
42
|
}, {
|
|
61
43
|
key: "addSelectionToQuery",
|
|
62
|
-
value: function addSelectionToQuery(operationName,
|
|
44
|
+
value: function addSelectionToQuery(operationName, document) {
|
|
63
45
|
var _tree;
|
|
64
|
-
|
|
65
46
|
if (operationName !== this.config.operationName) {
|
|
66
47
|
return;
|
|
67
48
|
}
|
|
68
49
|
|
|
50
|
+
// If this plugin already processed the given document (documents are always passed by reference),
|
|
51
|
+
// then we don't want to apply the selection again, to avoid adding duplicate selections.
|
|
52
|
+
if (this.isProcessed(document)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.markProcessed(document);
|
|
69
56
|
var _this$config = this.config,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var firstQueryDefinition = query.definitions[0];
|
|
74
|
-
|
|
57
|
+
addSelection = _this$config.addSelection,
|
|
58
|
+
selectionPath = _this$config.selectionPath;
|
|
59
|
+
var firstQueryDefinition = document.definitions[0];
|
|
75
60
|
if (!firstQueryDefinition) {
|
|
76
61
|
return;
|
|
77
62
|
} else if (!firstQueryDefinition.selectionSet) {
|
|
78
63
|
return;
|
|
79
64
|
}
|
|
80
|
-
|
|
81
65
|
var tree = firstQueryDefinition.selectionSet.selections;
|
|
82
66
|
var fields = selectionPath.split(".");
|
|
83
|
-
|
|
84
67
|
var _iterator = (0, _createForOfIteratorHelper2.default)(fields),
|
|
85
|
-
|
|
86
|
-
|
|
68
|
+
_step;
|
|
87
69
|
try {
|
|
88
70
|
fieldLoop: for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
89
71
|
var field = _step.value;
|
|
90
|
-
|
|
91
72
|
var _iterator2 = (0, _createForOfIteratorHelper2.default)(tree),
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
_step2;
|
|
94
74
|
try {
|
|
95
75
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
96
76
|
var selection = _step2.value;
|
|
97
|
-
|
|
98
77
|
if (!selection.selectionSet) {
|
|
99
78
|
continue;
|
|
100
79
|
}
|
|
101
|
-
|
|
102
80
|
if (selection.name.value === field) {
|
|
103
81
|
tree = selection.selectionSet.selections;
|
|
104
82
|
continue fieldLoop;
|
|
105
83
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
84
|
+
}
|
|
85
|
+
// If we get here, it means we didn't find the necessary selection
|
|
108
86
|
} catch (err) {
|
|
109
87
|
_iterator2.e(err);
|
|
110
88
|
} finally {
|
|
111
89
|
_iterator2.f();
|
|
112
90
|
}
|
|
113
|
-
|
|
114
91
|
return;
|
|
115
92
|
}
|
|
116
93
|
} catch (err) {
|
|
@@ -121,12 +98,25 @@ var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
121
98
|
/**
|
|
122
99
|
* We must cast because there are a lot of types that are not intertwined and TS is complaining
|
|
123
100
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
101
|
(_tree = tree).push.apply(_tree, (0, _toConsumableArray2.default)(addSelection.definitions[0].selectionSet.selections));
|
|
127
102
|
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "isProcessed",
|
|
105
|
+
value: function isProcessed(document) {
|
|
106
|
+
if (!document.hasOwnProperty("__webiny__")) {
|
|
107
|
+
document.__webiny__ = new Set();
|
|
108
|
+
}
|
|
109
|
+
return document.__webiny__.has(this.cacheKey);
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "markProcessed",
|
|
113
|
+
value: function markProcessed(document) {
|
|
114
|
+
if (!document.hasOwnProperty("__webiny__")) {
|
|
115
|
+
document.__webiny__ = new Set();
|
|
116
|
+
}
|
|
117
|
+
document.__webiny__.add(this.cacheKey);
|
|
118
|
+
}
|
|
128
119
|
}]);
|
|
129
120
|
return AddQuerySelectionPlugin;
|
|
130
121
|
}(_ApolloLinkPlugin2.ApolloLinkPlugin);
|
|
131
|
-
|
|
132
122
|
exports.AddQuerySelectionPlugin = AddQuerySelectionPlugin;
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"names":["AddQuerySelectionPlugin","config","ApolloLink","operation","forward","operationName","addSelectionToQuery","query","document","isProcessed","markProcessed","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","hasOwnProperty","__webiny__","Set","has","cacheKey","add","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\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\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, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.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 private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AAAsD,IAezCA,uBAAuB;EAAA;EAAA;EAGhC,iCAAYC,MAAc,EAAE;IAAA;IAAA;IACxB;IAAQ;IACR,MAAKA,MAAM,GAAGA,MAAM;IAAC;EACzB;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAIC,sBAAU,CAAC,UAACC,SAAS,EAAEC,OAAO,EAAK;QAC1C,IAAID,SAAS,CAACE,aAAa,KAAK,MAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;UACvD,OAAOD,OAAO,CAACD,SAAS,CAAC;QAC7B;QAEA,MAAI,CAACG,mBAAmB,CAACH,SAAS,CAACE,aAAa,EAAEF,SAAS,CAACI,KAAK,CAAC;QAElE,OAAOH,OAAO,CAACD,SAAS,CAAC;MAC7B,CAAC,CAAC;IACN;EAAC;IAAA;IAAA,OAED,6BAA2BE,aAAqB,EAAEG,QAAsB,EAAQ;MAAA;MAC5E,IAAIH,aAAa,KAAK,IAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;QAC7C;MACJ;;MAEA;MACA;MACA,IAAI,IAAI,CAACI,WAAW,CAACD,QAAQ,CAAC,EAAE;QAC5B;MACJ;MAEA,IAAI,CAACE,aAAa,CAACF,QAAQ,CAAC;MAE5B,mBAAwC,IAAI,CAACP,MAAM;QAA3CU,YAAY,gBAAZA,YAAY;QAAEC,aAAa,gBAAbA,aAAa;MAEnC,IAAMC,oBAAoB,GAAGL,QAAQ,CAACM,WAAW,CAAC,CAAC,CAA6B;MAChF,IAAI,CAACD,oBAAoB,EAAE;QACvB;MACJ,CAAC,MAAM,IAAI,CAACA,oBAAoB,CAACE,YAAY,EAAE;QAC3C;MACJ;MAEA,IAAIC,IAAI,GAAGH,oBAAoB,CAACE,YAAY,CAACE,UAAyB;MACtE,IAAMC,MAAM,GAAGN,aAAa,CAACO,KAAK,CAAC,GAAG,CAAC;MAAC,yDAETD,MAAM;QAAA;MAAA;QAArCE,SAAS,EAAE,oDAA4B;UAAA,IAAjBC,KAAK;UAAA,0DACCL,IAAI;YAAA;UAAA;YAA5B,uDAA8B;cAAA,IAAnBM,SAAS;cAChB,IAAI,CAACA,SAAS,CAACP,YAAY,EAAE;gBACzB;cACJ;cACA,IAAIO,SAAS,CAACC,IAAI,CAACC,KAAK,KAAKH,KAAK,EAAE;gBAChCL,IAAI,GAAGM,SAAS,CAACP,YAAY,CAACE,UAAyB;gBACvD,SAASG,SAAS;cACtB;YACJ;YACA;UAAA;YAAA;UAAA;YAAA;UAAA;UACA;QACJ;MAAC;QAAA;MAAA;QAAA;MAAA;MACD;AACR;AACA;MACQ,SAAAJ,IAAI,EAACS,IAAI,+CACAd,YAAY,CAACG,WAAW,CAAC,CAAC,CAAC,CAA8BC,YAAY,CACrEE,UAAU,EAClB;IACL;EAAC;IAAA;IAAA,OAED,qBAAoBT,QAAsB,EAAE;MACxC,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;QACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,EAAE;MACnC;MAEA,OAAOpB,QAAQ,CAACmB,UAAU,CAACE,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;IACjD;EAAC;IAAA;IAAA,OAED,uBAAsBtB,QAAsB,EAAE;MAC1C,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;QACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,EAAE;MACnC;MAEApB,QAAQ,CAACmB,UAAU,CAACI,GAAG,CAAC,IAAI,CAACD,QAAQ,CAAC;IAC1C;EAAC;EAAA;AAAA,EAjFwCE,mCAAgB;AAAA"}
|
|
@@ -1,53 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ApolloCacheObjectIdPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
-
|
|
20
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
14
|
var _plugins = require("@webiny/plugins");
|
|
23
|
-
|
|
24
15
|
var ApolloCacheObjectIdPlugin = /*#__PURE__*/function (_Plugin) {
|
|
25
16
|
(0, _inherits2.default)(ApolloCacheObjectIdPlugin, _Plugin);
|
|
26
|
-
|
|
27
17
|
var _super = (0, _createSuper2.default)(ApolloCacheObjectIdPlugin);
|
|
28
|
-
|
|
29
18
|
function ApolloCacheObjectIdPlugin(getObjectId) {
|
|
30
19
|
var _this;
|
|
31
|
-
|
|
32
20
|
(0, _classCallCheck2.default)(this, ApolloCacheObjectIdPlugin);
|
|
33
21
|
_this = _super.call(this);
|
|
34
22
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_getObjectId", void 0);
|
|
35
23
|
_this._getObjectId = getObjectId;
|
|
36
24
|
return _this;
|
|
37
25
|
}
|
|
38
|
-
|
|
39
26
|
(0, _createClass2.default)(ApolloCacheObjectIdPlugin, [{
|
|
40
27
|
key: "getObjectId",
|
|
41
28
|
value: function getObjectId(data) {
|
|
42
29
|
if (typeof this._getObjectId !== "function") {
|
|
43
30
|
throw Error("You must provide a \"getObjectId\" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.");
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
return this._getObjectId(data);
|
|
47
33
|
}
|
|
48
34
|
}]);
|
|
49
35
|
return ApolloCacheObjectIdPlugin;
|
|
50
36
|
}(_plugins.Plugin);
|
|
51
|
-
|
|
52
37
|
exports.ApolloCacheObjectIdPlugin = ApolloCacheObjectIdPlugin;
|
|
53
38
|
(0, _defineProperty2.default)(ApolloCacheObjectIdPlugin, "type", "cache-get-object-id");
|
|
@@ -1 +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":"
|
|
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;AAAyC,IAY5BA,yBAAyB;EAAA;EAAA;EAMlC,mCAAmBC,WAAkD,EAAE;IAAA;IAAA;IACnE;IAAQ;IACR,MAAKC,YAAY,GAAGD,WAAW;IAAC;EACpC;EAAC;IAAA;IAAA,OAED,qBAAmBE,IAAO,EAAE;MACxB,IAAI,OAAO,IAAI,CAACD,YAAY,KAAK,UAAU,EAAE;QACzC,MAAME,KAAK,kHAEV;MACL;MAEA,OAAO,IAAI,CAACF,YAAY,CAACC,IAAI,CAAC;IAClC;EAAC;EAAA;AAAA,EAjBKE,eAAM;AAAA;AAAA,8BAFHL,yBAAyB,UAGa,qBAAqB"}
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ApolloDynamicLink = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
-
|
|
20
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
14
|
var _apolloLink = require("apollo-link");
|
|
23
|
-
|
|
24
15
|
var _plugins = require("@webiny/plugins");
|
|
25
|
-
|
|
26
16
|
function createLink(plugin) {
|
|
27
17
|
try {
|
|
28
18
|
return plugin.createLink();
|
|
@@ -30,42 +20,31 @@ function createLink(plugin) {
|
|
|
30
20
|
console.error("Caught an error while executing \"createLink\" on plugin", plugin);
|
|
31
21
|
console.error(e);
|
|
32
22
|
}
|
|
33
|
-
|
|
34
23
|
return null;
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
|
|
38
26
|
(0, _inherits2.default)(ApolloDynamicLink, _ApolloLink);
|
|
39
|
-
|
|
40
27
|
var _super = (0, _createSuper2.default)(ApolloDynamicLink);
|
|
41
|
-
|
|
42
28
|
function ApolloDynamicLink() {
|
|
43
29
|
var _this;
|
|
44
|
-
|
|
45
30
|
(0, _classCallCheck2.default)(this, ApolloDynamicLink);
|
|
46
|
-
|
|
47
31
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
32
|
args[_key] = arguments[_key];
|
|
49
33
|
}
|
|
50
|
-
|
|
51
34
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
52
35
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cache", new Map());
|
|
53
36
|
return _this;
|
|
54
37
|
}
|
|
55
|
-
|
|
56
38
|
(0, _createClass2.default)(ApolloDynamicLink, [{
|
|
57
39
|
key: "request",
|
|
58
40
|
value: function request(operation, forward) {
|
|
59
41
|
var linkPlugins = _plugins.plugins.byType("apollo-link");
|
|
60
|
-
|
|
61
42
|
if (!linkPlugins.length) {
|
|
62
43
|
return forward(operation);
|
|
63
44
|
}
|
|
64
|
-
|
|
65
45
|
var cacheKey = linkPlugins.map(function (pl) {
|
|
66
46
|
return pl.cacheKey;
|
|
67
47
|
}).join(",");
|
|
68
|
-
|
|
69
48
|
if (!this.cache.has(cacheKey)) {
|
|
70
49
|
/**
|
|
71
50
|
* We filter out falsy items from the linkPlugins because there might be some error while creating link.
|
|
@@ -73,11 +52,9 @@ var ApolloDynamicLink = /*#__PURE__*/function (_ApolloLink) {
|
|
|
73
52
|
var links = linkPlugins.map(createLink).filter(Boolean);
|
|
74
53
|
this.cache.set(cacheKey, _apolloLink.ApolloLink.from(links));
|
|
75
54
|
}
|
|
76
|
-
|
|
77
55
|
return this.cache.get(cacheKey).request(operation, forward);
|
|
78
56
|
}
|
|
79
57
|
}]);
|
|
80
58
|
return ApolloDynamicLink;
|
|
81
59
|
}(_apolloLink.ApolloLink);
|
|
82
|
-
|
|
83
60
|
exports.ApolloDynamicLink = ApolloDynamicLink;
|
|
@@ -1 +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":"
|
|
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,UAAU,CAACC,MAAwB,EAAE;EAC1C,IAAI;IACA,OAAOA,MAAM,CAACD,UAAU,EAAE;EAC9B,CAAC,CAAC,OAAOE,CAAC,EAAE;IACRC,OAAO,CAACC,KAAK,6DAA2DH,MAAM,CAAC;IAC/EE,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;EACpB;EACA,OAAO,IAAI;AACf;AAAC,IAEYG,iBAAiB;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,oFACV,IAAIC,GAAG,EAAE;IAAA;EAAA;EAAA;IAAA;IAAA,OAEzB,iBAAwBC,SAAoB,EAAEC,OAAiB,EAAE;MAC7D,IAAMC,WAAW,GAAGC,gBAAO,CAACC,MAAM,CAAmB,aAAa,CAAC;MAEnE,IAAI,CAACF,WAAW,CAACG,MAAM,EAAE;QACrB,OAAOJ,OAAO,CAACD,SAAS,CAAC;MAC7B;MAEA,IAAMM,QAAQ,GAAGJ,WAAW,CAACK,GAAG,CAAC,UAAAC,EAAE;QAAA,OAAIA,EAAE,CAACF,QAAQ;MAAA,EAAC,CAACG,IAAI,CAAC,GAAG,CAAC;MAE7D,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,GAAG,CAACL,QAAQ,CAAC,EAAE;QAC3B;AACZ;AACA;QACY,IAAMM,KAAK,GAAGV,WAAW,CAACK,GAAG,CAACd,UAAU,CAAC,CAACoB,MAAM,CAACC,OAAO,CAAiB;QACzE,IAAI,CAACJ,KAAK,CAACK,GAAG,CAACT,QAAQ,EAAEU,sBAAU,CAACC,IAAI,CAACL,KAAK,CAAC,CAAC;MACpD;MAEA,OAAO,IAAI,CAACF,KAAK,CAACQ,GAAG,CAACZ,QAAQ,CAAC,CAACa,OAAO,CAACnB,SAAS,EAAEC,OAAO,CAAC;IAC/D;EAAC;EAAA;AAAA,EArBkCe,sBAAU;AAAA"}
|
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ApolloLinkPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
-
|
|
20
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
14
|
var _nanoid = require("nanoid");
|
|
23
|
-
|
|
24
15
|
var _plugins = require("@webiny/plugins");
|
|
25
|
-
|
|
26
16
|
var ApolloLinkPlugin = /*#__PURE__*/function (_Plugin) {
|
|
27
17
|
(0, _inherits2.default)(ApolloLinkPlugin, _Plugin);
|
|
28
|
-
|
|
29
18
|
var _super = (0, _createSuper2.default)(ApolloLinkPlugin);
|
|
30
|
-
|
|
31
19
|
function ApolloLinkPlugin(factory) {
|
|
32
20
|
var _this;
|
|
33
|
-
|
|
34
21
|
(0, _classCallCheck2.default)(this, ApolloLinkPlugin);
|
|
35
22
|
_this = _super.call(this);
|
|
36
23
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cacheKey", void 0);
|
|
@@ -40,24 +27,20 @@ var ApolloLinkPlugin = /*#__PURE__*/function (_Plugin) {
|
|
|
40
27
|
_this.cacheKey = (0, _nanoid.nanoid)();
|
|
41
28
|
return _this;
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
(0, _createClass2.default)(ApolloLinkPlugin, [{
|
|
45
31
|
key: "createLink",
|
|
46
32
|
value: function createLink() {
|
|
47
33
|
if (this.cache) {
|
|
48
34
|
return this.cache;
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
if (typeof this.factory === "function") {
|
|
52
37
|
this.cache = this.factory();
|
|
53
38
|
return this.cache;
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
throw Error("Missing ApolloLinkFactory in plugin \"".concat(this.name, "\"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the \"createLink\" method."));
|
|
57
41
|
}
|
|
58
42
|
}]);
|
|
59
43
|
return ApolloLinkPlugin;
|
|
60
44
|
}(_plugins.Plugin);
|
|
61
|
-
|
|
62
45
|
exports.ApolloLinkPlugin = ApolloLinkPlugin;
|
|
63
46
|
(0, _defineProperty2.default)(ApolloLinkPlugin, "type", "apollo-link");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApolloLinkPlugin","factory","cacheKey","nanoid","cache","Error","name","Plugin"],"sources":["ApolloLinkPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { nanoid } from \"nanoid\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport interface ApolloLinkFactory {\n (): ApolloLink;\n}\n\nexport class ApolloLinkPlugin extends Plugin {\n public static override readonly type: string = \"apollo-link\";\n public readonly cacheKey;\n private readonly factory?: ApolloLinkFactory;\n private cache?: ApolloLink;\n\n constructor(factory?: ApolloLinkFactory) {\n super();\n this.factory = factory;\n this.cacheKey = nanoid();\n }\n\n public createLink(): ApolloLink {\n if (this.cache) {\n return this.cache;\n }\n\n if (typeof this.factory === \"function\") {\n this.cache = this.factory();\n\n return this.cache;\n }\n\n throw Error(\n `Missing ApolloLinkFactory in plugin \"${this.name}\"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the \"createLink\" method.`\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ApolloLinkPlugin","factory","cacheKey","nanoid","cache","Error","name","Plugin"],"sources":["ApolloLinkPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { nanoid } from \"nanoid\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport interface ApolloLinkFactory {\n (): ApolloLink;\n}\n\nexport class ApolloLinkPlugin extends Plugin {\n public static override readonly type: string = \"apollo-link\";\n public readonly cacheKey;\n private readonly factory?: ApolloLinkFactory;\n private cache?: ApolloLink;\n\n constructor(factory?: ApolloLinkFactory) {\n super();\n this.factory = factory;\n this.cacheKey = nanoid();\n }\n\n public createLink(): ApolloLink {\n if (this.cache) {\n return this.cache;\n }\n\n if (typeof this.factory === \"function\") {\n this.cache = this.factory();\n\n return this.cache;\n }\n\n throw Error(\n `Missing ApolloLinkFactory in plugin \"${this.name}\"! Either pass a factory to ApolloLinkPlugin constructor or extend the class and override the \"createLink\" method.`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;AACA;AAAyC,IAM5BA,gBAAgB;EAAA;EAAA;EAMzB,0BAAYC,OAA2B,EAAE;IAAA;IAAA;IACrC;IAAQ;IAAA;IAAA;IACR,MAAKA,OAAO,GAAGA,OAAO;IACtB,MAAKC,QAAQ,GAAG,IAAAC,cAAM,GAAE;IAAC;EAC7B;EAAC;IAAA;IAAA,OAED,sBAAgC;MAC5B,IAAI,IAAI,CAACC,KAAK,EAAE;QACZ,OAAO,IAAI,CAACA,KAAK;MACrB;MAEA,IAAI,OAAO,IAAI,CAACH,OAAO,KAAK,UAAU,EAAE;QACpC,IAAI,CAACG,KAAK,GAAG,IAAI,CAACH,OAAO,EAAE;QAE3B,OAAO,IAAI,CAACG,KAAK;MACrB;MAEA,MAAMC,KAAK,iDACiC,IAAI,CAACC,IAAI,2HACpD;IACL;EAAC;EAAA;AAAA,EA1BiCC,eAAM;AAAA;AAAA,8BAA/BP,gBAAgB,UACsB,aAAa"}
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ConsoleLinkPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
19
|
-
|
|
20
13
|
var _apolloLink = require("apollo-link");
|
|
21
|
-
|
|
22
14
|
var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
|
|
23
|
-
|
|
24
15
|
/**
|
|
25
16
|
* This link checks for presence of `extensions.console` in the response and logs all items to browser console.
|
|
26
17
|
*/
|
|
27
18
|
var ConsoleLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
28
19
|
(0, _inherits2.default)(ConsoleLinkPlugin, _ApolloLinkPlugin);
|
|
29
|
-
|
|
30
20
|
var _super = (0, _createSuper2.default)(ConsoleLinkPlugin);
|
|
31
|
-
|
|
32
21
|
function ConsoleLinkPlugin() {
|
|
33
22
|
(0, _classCallCheck2.default)(this, ConsoleLinkPlugin);
|
|
34
23
|
return _super.apply(this, arguments);
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
(0, _createClass2.default)(ConsoleLinkPlugin, [{
|
|
38
26
|
key: "createLink",
|
|
39
27
|
value: function createLink() {
|
|
@@ -46,12 +34,10 @@ var ConsoleLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
46
34
|
console.groupCollapsed("Logs for graphQL ".concat(isQuery ? "query" : "mutation", ": %c").concat(operation.operationName || "anonymous operation", " %c").concat(variables, "%c"), "color: #fa5a28", "color: #6b6b6b", "color: black");
|
|
47
35
|
data.extensions.console.forEach(function (log) {
|
|
48
36
|
var _console;
|
|
49
|
-
|
|
50
37
|
(_console = console)[log.method].apply(_console, (0, _toConsumableArray2.default)(log.args));
|
|
51
38
|
});
|
|
52
39
|
console.groupEnd();
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
return data;
|
|
56
42
|
});
|
|
57
43
|
});
|
|
@@ -59,5 +45,4 @@ var ConsoleLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
59
45
|
}]);
|
|
60
46
|
return ConsoleLinkPlugin;
|
|
61
47
|
}(_ApolloLinkPlugin2.ApolloLinkPlugin);
|
|
62
|
-
|
|
63
48
|
exports.ConsoleLinkPlugin = ConsoleLinkPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConsoleLinkPlugin","ApolloLink","operation","forward","firstDefinition","query","definitions","isQuery","map","data","extensions","Array","isArray","console","length","variables","JSON","stringify","groupCollapsed","operationName","forEach","log","method","args","groupEnd","ApolloLinkPlugin"],"sources":["ConsoleLinkPlugin.ts"],"sourcesContent":["import { ApolloLink, FetchResult as BaseFetchResult } from \"apollo-link\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { OperationDefinitionNode } from \"graphql/language/ast\";\n\ninterface Log {\n args: any[];\n method: \"error\" | \"info\" | \"log\" | \"warn\";\n}\n\ninterface FetchResult extends BaseFetchResult {\n extensions?: {\n console?: Log[];\n };\n}\n\n/**\n * This link checks for presence of `extensions.console` in the response and logs all items to browser console.\n */\nexport class ConsoleLinkPlugin extends ApolloLinkPlugin {\n public override createLink() {\n return new ApolloLink((operation, forward) => {\n const firstDefinition = operation.query.definitions[0] as OperationDefinitionNode;\n const isQuery = firstDefinition[\"operation\"] === \"query\";\n\n return forward(operation).map((data: FetchResult) => {\n if (\n data.extensions &&\n Array.isArray(data.extensions.console) &&\n data.extensions.console.length\n ) {\n const variables = isQuery\n ? JSON.stringify(operation.variables)\n : \"{ see request details in the Network tab }\";\n console.groupCollapsed(\n `Logs for graphQL ${isQuery ? \"query\" : \"mutation\"}: %c${\n operation.operationName || \"anonymous operation\"\n } %c${variables}%c`,\n \"color: #fa5a28\",\n \"color: #6b6b6b\",\n \"color: black\"\n );\n data.extensions.console.forEach((log: Log) => {\n console[log.method](...log.args);\n });\n console.groupEnd();\n }\n\n return data;\n });\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ConsoleLinkPlugin","ApolloLink","operation","forward","firstDefinition","query","definitions","isQuery","map","data","extensions","Array","isArray","console","length","variables","JSON","stringify","groupCollapsed","operationName","forEach","log","method","args","groupEnd","ApolloLinkPlugin"],"sources":["ConsoleLinkPlugin.ts"],"sourcesContent":["import { ApolloLink, FetchResult as BaseFetchResult } from \"apollo-link\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { OperationDefinitionNode } from \"graphql/language/ast\";\n\ninterface Log {\n args: any[];\n method: \"error\" | \"info\" | \"log\" | \"warn\";\n}\n\ninterface FetchResult extends BaseFetchResult {\n extensions?: {\n console?: Log[];\n };\n}\n\n/**\n * This link checks for presence of `extensions.console` in the response and logs all items to browser console.\n */\nexport class ConsoleLinkPlugin extends ApolloLinkPlugin {\n public override createLink() {\n return new ApolloLink((operation, forward) => {\n const firstDefinition = operation.query.definitions[0] as OperationDefinitionNode;\n const isQuery = firstDefinition[\"operation\"] === \"query\";\n\n return forward(operation).map((data: FetchResult) => {\n if (\n data.extensions &&\n Array.isArray(data.extensions.console) &&\n data.extensions.console.length\n ) {\n const variables = isQuery\n ? JSON.stringify(operation.variables)\n : \"{ see request details in the Network tab }\";\n console.groupCollapsed(\n `Logs for graphQL ${isQuery ? \"query\" : \"mutation\"}: %c${\n operation.operationName || \"anonymous operation\"\n } %c${variables}%c`,\n \"color: #fa5a28\",\n \"color: #6b6b6b\",\n \"color: black\"\n );\n data.extensions.console.forEach((log: Log) => {\n console[log.method](...log.args);\n });\n console.groupEnd();\n }\n\n return data;\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAcA;AACA;AACA;AAFA,IAGaA,iBAAiB;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA,OAC1B,sBAA6B;MACzB,OAAO,IAAIC,sBAAU,CAAC,UAACC,SAAS,EAAEC,OAAO,EAAK;QAC1C,IAAMC,eAAe,GAAGF,SAAS,CAACG,KAAK,CAACC,WAAW,CAAC,CAAC,CAA4B;QACjF,IAAMC,OAAO,GAAGH,eAAe,CAAC,WAAW,CAAC,KAAK,OAAO;QAExD,OAAOD,OAAO,CAACD,SAAS,CAAC,CAACM,GAAG,CAAC,UAACC,IAAiB,EAAK;UACjD,IACIA,IAAI,CAACC,UAAU,IACfC,KAAK,CAACC,OAAO,CAACH,IAAI,CAACC,UAAU,CAACG,OAAO,CAAC,IACtCJ,IAAI,CAACC,UAAU,CAACG,OAAO,CAACC,MAAM,EAChC;YACE,IAAMC,SAAS,GAAGR,OAAO,GACnBS,IAAI,CAACC,SAAS,CAACf,SAAS,CAACa,SAAS,CAAC,GACnC,4CAA4C;YAClDF,OAAO,CAACK,cAAc,4BACEX,OAAO,GAAG,OAAO,GAAG,UAAU,iBAC9CL,SAAS,CAACiB,aAAa,IAAI,qBAAqB,gBAC9CJ,SAAS,SACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,CACjB;YACDN,IAAI,CAACC,UAAU,CAACG,OAAO,CAACO,OAAO,CAAC,UAACC,GAAQ,EAAK;cAAA;cAC1C,YAAAR,OAAO,EAACQ,GAAG,CAACC,MAAM,CAAC,kDAAID,GAAG,CAACE,IAAI,EAAC;YACpC,CAAC,CAAC;YACFV,OAAO,CAACW,QAAQ,EAAE;UACtB;UAEA,OAAOf,IAAI;QACf,CAAC,CAAC;MACN,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EAhCkCgB,mCAAgB;AAAA"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
|
|
2
2
|
import { ApolloLink } from "apollo-link";
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
__PS_RENDER_LOCALE__: string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
3
|
/**
|
|
9
4
|
* Append `x-i18n-locale` header from URL query (necessary for prerendering service).
|
|
10
5
|
*/
|
|
@@ -1,62 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.LocaleHeaderLinkPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
13
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _apolloLinkContext = require("apollo-link-context");
|
|
25
|
-
|
|
26
16
|
var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
|
|
27
|
-
|
|
17
|
+
var _utils = require("../utils");
|
|
28
18
|
/**
|
|
29
19
|
* Append `x-i18n-locale` header from URL query (necessary for prerendering service).
|
|
30
20
|
*/
|
|
31
21
|
var LocaleHeaderLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
32
22
|
(0, _inherits2.default)(LocaleHeaderLinkPlugin, _ApolloLinkPlugin);
|
|
33
|
-
|
|
34
23
|
var _super = (0, _createSuper2.default)(LocaleHeaderLinkPlugin);
|
|
35
|
-
|
|
36
24
|
function LocaleHeaderLinkPlugin(locale) {
|
|
37
25
|
var _this;
|
|
38
|
-
|
|
39
26
|
(0, _classCallCheck2.default)(this, LocaleHeaderLinkPlugin);
|
|
40
27
|
_this = _super.call(this);
|
|
41
28
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "locale", void 0);
|
|
42
|
-
|
|
43
|
-
if (!locale) {
|
|
44
|
-
var query = new URLSearchParams(location.search);
|
|
45
|
-
locale = query.get("__locale") || window.__PS_RENDER_LOCALE__;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_this.locale = locale;
|
|
29
|
+
_this.locale = locale || (0, _utils.getLocaleCode)();
|
|
49
30
|
return _this;
|
|
50
31
|
}
|
|
51
|
-
|
|
52
32
|
(0, _createClass2.default)(LocaleHeaderLinkPlugin, [{
|
|
53
33
|
key: "createLink",
|
|
54
34
|
value: function createLink() {
|
|
55
35
|
var _this2 = this;
|
|
56
|
-
|
|
57
36
|
return (0, _apolloLinkContext.setContext)(function (_, _ref) {
|
|
58
37
|
var headers = _ref.headers;
|
|
59
|
-
|
|
60
38
|
if (_this2.locale) {
|
|
61
39
|
return {
|
|
62
40
|
headers: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, headers), {}, {
|
|
@@ -64,7 +42,6 @@ var LocaleHeaderLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
64
42
|
})
|
|
65
43
|
};
|
|
66
44
|
}
|
|
67
|
-
|
|
68
45
|
return {
|
|
69
46
|
headers: headers
|
|
70
47
|
};
|
|
@@ -73,5 +50,4 @@ var LocaleHeaderLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
|
|
|
73
50
|
}]);
|
|
74
51
|
return LocaleHeaderLinkPlugin;
|
|
75
52
|
}(_ApolloLinkPlugin2.ApolloLinkPlugin);
|
|
76
|
-
|
|
77
53
|
exports.LocaleHeaderLinkPlugin = LocaleHeaderLinkPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LocaleHeaderLinkPlugin","locale","
|
|
1
|
+
{"version":3,"names":["LocaleHeaderLinkPlugin","locale","getLocaleCode","setContext","_","headers","ApolloLinkPlugin"],"sources":["LocaleHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ApolloLink } from \"apollo-link\";\nimport { getLocaleCode } from \"~/utils\";\n\n/**\n * Append `x-i18n-locale` header from URL query (necessary for prerendering service).\n */\nexport class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly locale: string;\n\n constructor(locale?: string) {\n super();\n\n this.locale = locale || (getLocaleCode() as string);\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n if (this.locale) {\n return {\n headers: {\n ...headers,\n \"x-i18n-locale\": `content:${this.locale};`\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAFA,IAGaA,sBAAsB;EAAA;EAAA;EAG/B,gCAAYC,MAAe,EAAE;IAAA;IAAA;IACzB;IAAQ;IAER,MAAKA,MAAM,GAAGA,MAAM,IAAK,IAAAC,oBAAa,GAAa;IAAC;EACxD;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAAC,6BAAU,EAAC,UAACC,CAAC,QAAkB;QAAA,IAAdC,OAAO,QAAPA,OAAO;QAC3B,IAAI,MAAI,CAACJ,MAAM,EAAE;UACb,OAAO;YACHI,OAAO,8DACAA,OAAO;cACV,eAAe,oBAAa,MAAI,CAACJ,MAAM;YAAG;UAElD,CAAC;QACL;QAEA,OAAO;UAAEI,OAAO,EAAPA;QAAQ,CAAC;MACtB,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EAtBuCC,mCAAgB;AAAA"}
|