@khanacademy/wonder-blocks-data 8.0.4 → 8.0.5
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/CHANGELOG.md +6 -0
- package/dist/es/index.js +66 -66
- package/dist/index.js +118 -114
- package/package.json +1 -1
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -719,6 +719,71 @@ const getGqlRequestId = (operation, variables, context) => {
|
|
|
719
719
|
return parts.join("|");
|
|
720
720
|
};
|
|
721
721
|
|
|
722
|
+
const GqlErrors = Object.freeze({
|
|
723
|
+
Internal: "Internal",
|
|
724
|
+
BadResponse: "BadResponse",
|
|
725
|
+
ErrorResult: "ErrorResult"
|
|
726
|
+
});
|
|
727
|
+
class GqlError extends KindError {
|
|
728
|
+
constructor(message, kind, {
|
|
729
|
+
metadata,
|
|
730
|
+
cause
|
|
731
|
+
} = {}) {
|
|
732
|
+
super(message, kind, {
|
|
733
|
+
metadata,
|
|
734
|
+
cause,
|
|
735
|
+
name: "Gql"
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const getGqlDataFromResponse = async response => {
|
|
742
|
+
const bodyText = await response.text();
|
|
743
|
+
let result;
|
|
744
|
+
|
|
745
|
+
try {
|
|
746
|
+
result = JSON.parse(bodyText);
|
|
747
|
+
} catch (e) {
|
|
748
|
+
throw new DataError("Failed to parse response", DataErrors.Parse, {
|
|
749
|
+
metadata: {
|
|
750
|
+
statusCode: response.status,
|
|
751
|
+
bodyText
|
|
752
|
+
},
|
|
753
|
+
cause: e
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (response.status >= 300) {
|
|
758
|
+
throw new DataError("Response unsuccessful", DataErrors.Network, {
|
|
759
|
+
metadata: {
|
|
760
|
+
statusCode: response.status,
|
|
761
|
+
result
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (!Object.prototype.hasOwnProperty.call(result, "data") && !Object.prototype.hasOwnProperty.call(result, "errors")) {
|
|
767
|
+
throw new GqlError("Server response missing", GqlErrors.BadResponse, {
|
|
768
|
+
metadata: {
|
|
769
|
+
statusCode: response.status,
|
|
770
|
+
result
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (result.errors != null && Array.isArray(result.errors) && result.errors.length > 0) {
|
|
776
|
+
throw new GqlError("GraphQL errors", GqlErrors.ErrorResult, {
|
|
777
|
+
metadata: {
|
|
778
|
+
statusCode: response.status,
|
|
779
|
+
result
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
return result.data;
|
|
785
|
+
};
|
|
786
|
+
|
|
722
787
|
const DocumentTypes = Object.freeze({
|
|
723
788
|
query: "query",
|
|
724
789
|
mutation: "mutation"
|
|
@@ -823,25 +888,6 @@ const mergeGqlContext = (defaultContext, overrides) => {
|
|
|
823
888
|
}, _extends({}, defaultContext));
|
|
824
889
|
};
|
|
825
890
|
|
|
826
|
-
const GqlErrors = Object.freeze({
|
|
827
|
-
Internal: "Internal",
|
|
828
|
-
BadResponse: "BadResponse",
|
|
829
|
-
ErrorResult: "ErrorResult"
|
|
830
|
-
});
|
|
831
|
-
class GqlError extends KindError {
|
|
832
|
-
constructor(message, kind, {
|
|
833
|
-
metadata,
|
|
834
|
-
cause
|
|
835
|
-
} = {}) {
|
|
836
|
-
super(message, kind, {
|
|
837
|
-
metadata,
|
|
838
|
-
cause,
|
|
839
|
-
name: "Gql"
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
|
|
845
891
|
const useGqlRouterContext = (contextOverrides = {}) => {
|
|
846
892
|
const gqlRouterContext = useContext(GqlRouterContext);
|
|
847
893
|
|
|
@@ -871,52 +917,6 @@ const useGqlRouterContext = (contextOverrides = {}) => {
|
|
|
871
917
|
return finalRouterContext;
|
|
872
918
|
};
|
|
873
919
|
|
|
874
|
-
const getGqlDataFromResponse = async response => {
|
|
875
|
-
const bodyText = await response.text();
|
|
876
|
-
let result;
|
|
877
|
-
|
|
878
|
-
try {
|
|
879
|
-
result = JSON.parse(bodyText);
|
|
880
|
-
} catch (e) {
|
|
881
|
-
throw new DataError("Failed to parse response", DataErrors.Parse, {
|
|
882
|
-
metadata: {
|
|
883
|
-
statusCode: response.status,
|
|
884
|
-
bodyText
|
|
885
|
-
},
|
|
886
|
-
cause: e
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
if (response.status >= 300) {
|
|
891
|
-
throw new DataError("Response unsuccessful", DataErrors.Network, {
|
|
892
|
-
metadata: {
|
|
893
|
-
statusCode: response.status,
|
|
894
|
-
result
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
if (!Object.prototype.hasOwnProperty.call(result, "data") && !Object.prototype.hasOwnProperty.call(result, "errors")) {
|
|
900
|
-
throw new GqlError("Server response missing", GqlErrors.BadResponse, {
|
|
901
|
-
metadata: {
|
|
902
|
-
statusCode: response.status,
|
|
903
|
-
result
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
if (result.errors != null && Array.isArray(result.errors) && result.errors.length > 0) {
|
|
909
|
-
throw new GqlError("GraphQL errors", GqlErrors.ErrorResult, {
|
|
910
|
-
metadata: {
|
|
911
|
-
statusCode: response.status,
|
|
912
|
-
result
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
return result.data;
|
|
918
|
-
};
|
|
919
|
-
|
|
920
920
|
const useGql = (context = {}) => {
|
|
921
921
|
const gqlRouterContext = useGqlRouterContext(context);
|
|
922
922
|
const gqlFetch = useCallback((operation, options = Object.freeze({})) => {
|
|
@@ -934,4 +934,4 @@ const useGql = (context = {}) => {
|
|
|
934
934
|
return gqlFetch;
|
|
935
935
|
};
|
|
936
936
|
|
|
937
|
-
export { Data, DataError, DataErrors, FetchPolicy, GqlError, GqlErrors, GqlRouter, InterceptRequests, ScopedInMemoryCache, SerializableInMemoryCache, Status, TrackData, WhenClientSide, abortInflightRequests, fetchTrackedRequests, getGqlRequestId, graphQLDocumentNodeParser, hasTrackedRequestsToBeFetched, initializeHydrationCache, purgeCaches, purgeHydrationCache, purgeSharedCache, toGqlOperation, useCachedEffect, useGql, useHydratableEffect, useServerEffect, useSharedCache };
|
|
937
|
+
export { Data, DataError, DataErrors, FetchPolicy, GqlError, GqlErrors, GqlRouter, InterceptRequests, ScopedInMemoryCache, SerializableInMemoryCache, Status, TrackData, WhenClientSide, abortInflightRequests, fetchTrackedRequests, getGqlDataFromResponse, getGqlRequestId, graphQLDocumentNodeParser, hasTrackedRequestsToBeFetched, initializeHydrationCache, purgeCaches, purgeHydrationCache, purgeSharedCache, toGqlOperation, useCachedEffect, useGql, useHydratableEffect, useServerEffect, useSharedCache };
|
package/dist/index.js
CHANGED
|
@@ -178,7 +178,7 @@ module.exports = require("@khanacademy/wonder-blocks-core");
|
|
|
178
178
|
/**
|
|
179
179
|
* Defines the various fetch policies that can be applied to requests.
|
|
180
180
|
*/
|
|
181
|
-
const FetchPolicy = __webpack_require__(
|
|
181
|
+
const FetchPolicy = __webpack_require__(23).Mirrored(["CacheBeforeNetwork", "CacheAndNetwork", "CacheOnly", "NetworkOnly"]);
|
|
182
182
|
/**
|
|
183
183
|
* Define what can be cached.
|
|
184
184
|
*
|
|
@@ -924,7 +924,7 @@ class ScopedInMemoryCache {
|
|
|
924
924
|
/**
|
|
925
925
|
* Policies to define how a hydratable effect should behave client-side.
|
|
926
926
|
*/
|
|
927
|
-
const WhenClientSide = __webpack_require__(
|
|
927
|
+
const WhenClientSide = __webpack_require__(23).Mirrored(["DoNotHydrate", "ExecuteWhenNoResult", "ExecuteWhenNoSuccessResult", "AlwaysExecute"]);
|
|
928
928
|
const DefaultScope = "useHydratableEffect";
|
|
929
929
|
/**
|
|
930
930
|
* Hook to execute an async operation on server and client.
|
|
@@ -1118,8 +1118,8 @@ const purgeHydrationCache = predicate => _ssr_cache_js__WEBPACK_IMPORTED_MODULE_
|
|
|
1118
1118
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
1119
1119
|
/* harmony import */ var _util_request_tracking_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
|
|
1120
1120
|
/* harmony import */ var _util_ssr_cache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
1121
|
-
/* harmony import */ var _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
1122
|
-
/* harmony import */ var _use_request_interception_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
1121
|
+
/* harmony import */ var _util_result_from_cache_response_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(33);
|
|
1122
|
+
/* harmony import */ var _use_request_interception_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(20);
|
|
1123
1123
|
|
|
1124
1124
|
|
|
1125
1125
|
|
|
@@ -1183,7 +1183,7 @@ const useServerEffect = (requestId, handler, options = {}) => {
|
|
|
1183
1183
|
/* harmony import */ var _util_request_fulfillment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
|
|
1184
1184
|
/* harmony import */ var _util_status_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6);
|
|
1185
1185
|
/* harmony import */ var _use_shared_cache_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
1186
|
-
/* harmony import */ var _use_request_interception_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
1186
|
+
/* harmony import */ var _use_request_interception_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(20);
|
|
1187
1187
|
/* harmony import */ var _util_types_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3);
|
|
1188
1188
|
|
|
1189
1189
|
|
|
@@ -1392,6 +1392,76 @@ const useCachedEffect = (requestId, handler, options = {}) => {
|
|
|
1392
1392
|
/* 18 */
|
|
1393
1393
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1394
1394
|
|
|
1395
|
+
"use strict";
|
|
1396
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getGqlDataFromResponse; });
|
|
1397
|
+
/* harmony import */ var _data_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1398
|
+
/* harmony import */ var _gql_error_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Validate a GQL operation response and extract the data.
|
|
1403
|
+
*/
|
|
1404
|
+
|
|
1405
|
+
const getGqlDataFromResponse = async response => {
|
|
1406
|
+
// Get the response as text, that way we can use the text in error
|
|
1407
|
+
// messaging, should our parsing fail.
|
|
1408
|
+
const bodyText = await response.text();
|
|
1409
|
+
let result;
|
|
1410
|
+
|
|
1411
|
+
try {
|
|
1412
|
+
result = JSON.parse(bodyText);
|
|
1413
|
+
} catch (e) {
|
|
1414
|
+
throw new _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataError */ "a"]("Failed to parse response", _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataErrors */ "b"].Parse, {
|
|
1415
|
+
metadata: {
|
|
1416
|
+
statusCode: response.status,
|
|
1417
|
+
bodyText
|
|
1418
|
+
},
|
|
1419
|
+
cause: e
|
|
1420
|
+
});
|
|
1421
|
+
} // Check for a bad status code.
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
if (response.status >= 300) {
|
|
1425
|
+
throw new _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataError */ "a"]("Response unsuccessful", _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataErrors */ "b"].Network, {
|
|
1426
|
+
metadata: {
|
|
1427
|
+
statusCode: response.status,
|
|
1428
|
+
result
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
} // Check that we have a valid result payload.
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
if ( // Flow shouldn't be warning about this.
|
|
1435
|
+
// $FlowIgnore[method-unbinding]
|
|
1436
|
+
!Object.prototype.hasOwnProperty.call(result, "data") && // Flow shouldn't be warning about this.
|
|
1437
|
+
// $FlowIgnore[method-unbinding]
|
|
1438
|
+
!Object.prototype.hasOwnProperty.call(result, "errors")) {
|
|
1439
|
+
throw new _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlError */ "a"]("Server response missing", _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlErrors */ "b"].BadResponse, {
|
|
1440
|
+
metadata: {
|
|
1441
|
+
statusCode: response.status,
|
|
1442
|
+
result
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
} // If the response payload has errors, throw an error.
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
if (result.errors != null && Array.isArray(result.errors) && result.errors.length > 0) {
|
|
1449
|
+
throw new _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlError */ "a"]("GraphQL errors", _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlErrors */ "b"].ErrorResult, {
|
|
1450
|
+
metadata: {
|
|
1451
|
+
statusCode: response.status,
|
|
1452
|
+
result
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
} // We got here, so return the data.
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
return result.data;
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
/***/ }),
|
|
1462
|
+
/* 19 */
|
|
1463
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1464
|
+
|
|
1395
1465
|
"use strict";
|
|
1396
1466
|
/* unused harmony export DocumentTypes */
|
|
1397
1467
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return graphQLDocumentNodeParser; });
|
|
@@ -1470,7 +1540,7 @@ function graphQLDocumentNodeParser(document) {
|
|
|
1470
1540
|
}
|
|
1471
1541
|
|
|
1472
1542
|
/***/ }),
|
|
1473
|
-
/*
|
|
1543
|
+
/* 20 */
|
|
1474
1544
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1475
1545
|
|
|
1476
1546
|
"use strict";
|
|
@@ -1521,7 +1591,7 @@ const useRequestInterception = (requestId, handler) => {
|
|
|
1521
1591
|
};
|
|
1522
1592
|
|
|
1523
1593
|
/***/ }),
|
|
1524
|
-
/*
|
|
1594
|
+
/* 21 */
|
|
1525
1595
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1526
1596
|
|
|
1527
1597
|
"use strict";
|
|
@@ -1532,7 +1602,7 @@ const useRequestInterception = (requestId, handler) => {
|
|
|
1532
1602
|
const GqlRouterContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createContext"](null);
|
|
1533
1603
|
|
|
1534
1604
|
/***/ }),
|
|
1535
|
-
/*
|
|
1605
|
+
/* 22 */
|
|
1536
1606
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1537
1607
|
|
|
1538
1608
|
"use strict";
|
|
@@ -1566,13 +1636,13 @@ const mergeGqlContext = (defaultContext, overrides) => {
|
|
|
1566
1636
|
};
|
|
1567
1637
|
|
|
1568
1638
|
/***/ }),
|
|
1569
|
-
/*
|
|
1639
|
+
/* 23 */
|
|
1570
1640
|
/***/ (function(module, exports) {
|
|
1571
1641
|
|
|
1572
1642
|
module.exports = require("flow-enums-runtime");
|
|
1573
1643
|
|
|
1574
1644
|
/***/ }),
|
|
1575
|
-
/*
|
|
1645
|
+
/* 24 */
|
|
1576
1646
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1577
1647
|
|
|
1578
1648
|
"use strict";
|
|
@@ -1649,7 +1719,7 @@ const abortInflightRequests = () => {
|
|
|
1649
1719
|
};
|
|
1650
1720
|
|
|
1651
1721
|
/***/ }),
|
|
1652
|
-
/*
|
|
1722
|
+
/* 25 */
|
|
1653
1723
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1654
1724
|
|
|
1655
1725
|
"use strict";
|
|
@@ -1672,7 +1742,7 @@ const purgeCaches = () => {
|
|
|
1672
1742
|
};
|
|
1673
1743
|
|
|
1674
1744
|
/***/ }),
|
|
1675
|
-
/*
|
|
1745
|
+
/* 26 */
|
|
1676
1746
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1677
1747
|
|
|
1678
1748
|
"use strict";
|
|
@@ -1703,7 +1773,7 @@ class TrackData extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1703
1773
|
}
|
|
1704
1774
|
|
|
1705
1775
|
/***/ }),
|
|
1706
|
-
/*
|
|
1776
|
+
/* 27 */
|
|
1707
1777
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1708
1778
|
|
|
1709
1779
|
"use strict";
|
|
@@ -1735,7 +1805,7 @@ const Data = ({
|
|
|
1735
1805
|
/* harmony default export */ __webpack_exports__["a"] = (Data);
|
|
1736
1806
|
|
|
1737
1807
|
/***/ }),
|
|
1738
|
-
/*
|
|
1808
|
+
/* 28 */
|
|
1739
1809
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1740
1810
|
|
|
1741
1811
|
"use strict";
|
|
@@ -1776,7 +1846,7 @@ const InterceptRequests = ({
|
|
|
1776
1846
|
/* harmony default export */ __webpack_exports__["a"] = (InterceptRequests);
|
|
1777
1847
|
|
|
1778
1848
|
/***/ }),
|
|
1779
|
-
/*
|
|
1849
|
+
/* 29 */
|
|
1780
1850
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1781
1851
|
|
|
1782
1852
|
"use strict";
|
|
@@ -1825,12 +1895,12 @@ const getGqlRequestId = (operation, variables, context) => {
|
|
|
1825
1895
|
};
|
|
1826
1896
|
|
|
1827
1897
|
/***/ }),
|
|
1828
|
-
/*
|
|
1898
|
+
/* 30 */
|
|
1829
1899
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1830
1900
|
|
|
1831
1901
|
"use strict";
|
|
1832
1902
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return toGqlOperation; });
|
|
1833
|
-
/* harmony import */ var _graphql_document_node_parser_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
1903
|
+
/* harmony import */ var _graphql_document_node_parser_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
|
|
1834
1904
|
|
|
1835
1905
|
|
|
1836
1906
|
/**
|
|
@@ -1872,14 +1942,14 @@ const toGqlOperation = documentNode => {
|
|
|
1872
1942
|
};
|
|
1873
1943
|
|
|
1874
1944
|
/***/ }),
|
|
1875
|
-
/*
|
|
1945
|
+
/* 31 */
|
|
1876
1946
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1877
1947
|
|
|
1878
1948
|
"use strict";
|
|
1879
1949
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GqlRouter; });
|
|
1880
1950
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
1881
1951
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1882
|
-
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1952
|
+
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
|
|
1883
1953
|
|
|
1884
1954
|
|
|
1885
1955
|
|
|
@@ -1916,16 +1986,16 @@ const GqlRouter = ({
|
|
|
1916
1986
|
};
|
|
1917
1987
|
|
|
1918
1988
|
/***/ }),
|
|
1919
|
-
/*
|
|
1989
|
+
/* 32 */
|
|
1920
1990
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1921
1991
|
|
|
1922
1992
|
"use strict";
|
|
1923
1993
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useGql; });
|
|
1924
1994
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
1925
1995
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1926
|
-
/* harmony import */ var _util_merge_gql_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1927
|
-
/* harmony import */ var _use_gql_router_context_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
1928
|
-
/* harmony import */ var _util_get_gql_data_from_response_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
1996
|
+
/* harmony import */ var _util_merge_gql_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
|
|
1997
|
+
/* harmony import */ var _use_gql_router_context_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(34);
|
|
1998
|
+
/* harmony import */ var _util_get_gql_data_from_response_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
|
|
1929
1999
|
|
|
1930
2000
|
|
|
1931
2001
|
|
|
@@ -1966,7 +2036,7 @@ const useGql = (context = {}) => {
|
|
|
1966
2036
|
};
|
|
1967
2037
|
|
|
1968
2038
|
/***/ }),
|
|
1969
|
-
/*
|
|
2039
|
+
/* 33 */
|
|
1970
2040
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1971
2041
|
|
|
1972
2042
|
"use strict";
|
|
@@ -2006,15 +2076,15 @@ const resultFromCachedResponse = cacheEntry => {
|
|
|
2006
2076
|
};
|
|
2007
2077
|
|
|
2008
2078
|
/***/ }),
|
|
2009
|
-
/*
|
|
2079
|
+
/* 34 */
|
|
2010
2080
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2011
2081
|
|
|
2012
2082
|
"use strict";
|
|
2013
2083
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useGqlRouterContext; });
|
|
2014
2084
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
2015
2085
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2016
|
-
/* harmony import */ var _util_merge_gql_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
2017
|
-
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
2086
|
+
/* harmony import */ var _util_merge_gql_context_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
|
|
2087
|
+
/* harmony import */ var _util_gql_router_context_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
|
|
2018
2088
|
/* harmony import */ var _util_gql_error_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
2019
2089
|
|
|
2020
2090
|
|
|
@@ -2057,76 +2127,6 @@ const useGqlRouterContext = (contextOverrides = {}) => {
|
|
|
2057
2127
|
return finalRouterContext;
|
|
2058
2128
|
};
|
|
2059
2129
|
|
|
2060
|
-
/***/ }),
|
|
2061
|
-
/* 34 */
|
|
2062
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2063
|
-
|
|
2064
|
-
"use strict";
|
|
2065
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getGqlDataFromResponse; });
|
|
2066
|
-
/* harmony import */ var _data_error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
2067
|
-
/* harmony import */ var _gql_error_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
/**
|
|
2071
|
-
* Validate a GQL operation response and extract the data.
|
|
2072
|
-
*/
|
|
2073
|
-
|
|
2074
|
-
const getGqlDataFromResponse = async response => {
|
|
2075
|
-
// Get the response as text, that way we can use the text in error
|
|
2076
|
-
// messaging, should our parsing fail.
|
|
2077
|
-
const bodyText = await response.text();
|
|
2078
|
-
let result;
|
|
2079
|
-
|
|
2080
|
-
try {
|
|
2081
|
-
result = JSON.parse(bodyText);
|
|
2082
|
-
} catch (e) {
|
|
2083
|
-
throw new _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataError */ "a"]("Failed to parse response", _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataErrors */ "b"].Parse, {
|
|
2084
|
-
metadata: {
|
|
2085
|
-
statusCode: response.status,
|
|
2086
|
-
bodyText
|
|
2087
|
-
},
|
|
2088
|
-
cause: e
|
|
2089
|
-
});
|
|
2090
|
-
} // Check for a bad status code.
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
if (response.status >= 300) {
|
|
2094
|
-
throw new _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataError */ "a"]("Response unsuccessful", _data_error_js__WEBPACK_IMPORTED_MODULE_0__[/* DataErrors */ "b"].Network, {
|
|
2095
|
-
metadata: {
|
|
2096
|
-
statusCode: response.status,
|
|
2097
|
-
result
|
|
2098
|
-
}
|
|
2099
|
-
});
|
|
2100
|
-
} // Check that we have a valid result payload.
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
if ( // Flow shouldn't be warning about this.
|
|
2104
|
-
// $FlowIgnore[method-unbinding]
|
|
2105
|
-
!Object.prototype.hasOwnProperty.call(result, "data") && // Flow shouldn't be warning about this.
|
|
2106
|
-
// $FlowIgnore[method-unbinding]
|
|
2107
|
-
!Object.prototype.hasOwnProperty.call(result, "errors")) {
|
|
2108
|
-
throw new _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlError */ "a"]("Server response missing", _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlErrors */ "b"].BadResponse, {
|
|
2109
|
-
metadata: {
|
|
2110
|
-
statusCode: response.status,
|
|
2111
|
-
result
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
} // If the response payload has errors, throw an error.
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
if (result.errors != null && Array.isArray(result.errors) && result.errors.length > 0) {
|
|
2118
|
-
throw new _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlError */ "a"]("GraphQL errors", _gql_error_js__WEBPACK_IMPORTED_MODULE_1__[/* GqlErrors */ "b"].ErrorResult, {
|
|
2119
|
-
metadata: {
|
|
2120
|
-
statusCode: response.status,
|
|
2121
|
-
result
|
|
2122
|
-
}
|
|
2123
|
-
});
|
|
2124
|
-
} // We got here, so return the data.
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
return result.data;
|
|
2128
|
-
};
|
|
2129
|
-
|
|
2130
2130
|
/***/ }),
|
|
2131
2131
|
/* 35 */
|
|
2132
2132
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
@@ -2141,23 +2141,23 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2141
2141
|
|
|
2142
2142
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "purgeHydrationCache", function() { return _util_hydration_cache_api_js__WEBPACK_IMPORTED_MODULE_1__["b"]; });
|
|
2143
2143
|
|
|
2144
|
-
/* harmony import */ var _util_request_api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
2144
|
+
/* harmony import */ var _util_request_api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24);
|
|
2145
2145
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fetchTrackedRequests", function() { return _util_request_api_js__WEBPACK_IMPORTED_MODULE_2__["b"]; });
|
|
2146
2146
|
|
|
2147
2147
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "hasTrackedRequestsToBeFetched", function() { return _util_request_api_js__WEBPACK_IMPORTED_MODULE_2__["c"]; });
|
|
2148
2148
|
|
|
2149
2149
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "abortInflightRequests", function() { return _util_request_api_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
2150
2150
|
|
|
2151
|
-
/* harmony import */ var _util_purge_caches_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
2151
|
+
/* harmony import */ var _util_purge_caches_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(25);
|
|
2152
2152
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "purgeCaches", function() { return _util_purge_caches_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
2153
2153
|
|
|
2154
|
-
/* harmony import */ var _components_track_data_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
2154
|
+
/* harmony import */ var _components_track_data_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26);
|
|
2155
2155
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrackData", function() { return _components_track_data_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
2156
2156
|
|
|
2157
|
-
/* harmony import */ var _components_data_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
2157
|
+
/* harmony import */ var _components_data_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(27);
|
|
2158
2158
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Data", function() { return _components_data_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
2159
2159
|
|
|
2160
|
-
/* harmony import */ var _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
2160
|
+
/* harmony import */ var _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28);
|
|
2161
2161
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterceptRequests", function() { return _components_intercept_requests_js__WEBPACK_IMPORTED_MODULE_6__["a"]; });
|
|
2162
2162
|
|
|
2163
2163
|
/* harmony import */ var _util_data_error_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(0);
|
|
@@ -2190,25 +2190,28 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2190
2190
|
/* harmony import */ var _util_status_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(6);
|
|
2191
2191
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Status", function() { return _util_status_js__WEBPACK_IMPORTED_MODULE_14__["a"]; });
|
|
2192
2192
|
|
|
2193
|
-
/* harmony import */ var _util_get_gql_request_id_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(
|
|
2193
|
+
/* harmony import */ var _util_get_gql_request_id_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(29);
|
|
2194
2194
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getGqlRequestId", function() { return _util_get_gql_request_id_js__WEBPACK_IMPORTED_MODULE_15__["a"]; });
|
|
2195
2195
|
|
|
2196
|
-
/* harmony import */ var
|
|
2197
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
2196
|
+
/* harmony import */ var _util_get_gql_data_from_response_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(18);
|
|
2197
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getGqlDataFromResponse", function() { return _util_get_gql_data_from_response_js__WEBPACK_IMPORTED_MODULE_16__["a"]; });
|
|
2198
2198
|
|
|
2199
|
-
/* harmony import */ var
|
|
2200
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
2199
|
+
/* harmony import */ var _util_graphql_document_node_parser_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(19);
|
|
2200
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "graphQLDocumentNodeParser", function() { return _util_graphql_document_node_parser_js__WEBPACK_IMPORTED_MODULE_17__["a"]; });
|
|
2201
2201
|
|
|
2202
|
-
/* harmony import */ var
|
|
2203
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
2202
|
+
/* harmony import */ var _util_to_gql_operation_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(30);
|
|
2203
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "toGqlOperation", function() { return _util_to_gql_operation_js__WEBPACK_IMPORTED_MODULE_18__["a"]; });
|
|
2204
2204
|
|
|
2205
|
-
/* harmony import */ var
|
|
2206
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
2205
|
+
/* harmony import */ var _components_gql_router_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(31);
|
|
2206
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlRouter", function() { return _components_gql_router_js__WEBPACK_IMPORTED_MODULE_19__["a"]; });
|
|
2207
2207
|
|
|
2208
|
-
/* harmony import */ var
|
|
2209
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
2208
|
+
/* harmony import */ var _hooks_use_gql_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(32);
|
|
2209
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useGql", function() { return _hooks_use_gql_js__WEBPACK_IMPORTED_MODULE_20__["a"]; });
|
|
2210
2210
|
|
|
2211
|
-
/* harmony
|
|
2211
|
+
/* harmony import */ var _util_gql_error_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(4);
|
|
2212
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlError", function() { return _util_gql_error_js__WEBPACK_IMPORTED_MODULE_21__["a"]; });
|
|
2213
|
+
|
|
2214
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GqlErrors", function() { return _util_gql_error_js__WEBPACK_IMPORTED_MODULE_21__["b"]; });
|
|
2212
2215
|
|
|
2213
2216
|
// TODO(somewhatabstract, FEI-4174): Update eslint-plugin-import when they
|
|
2214
2217
|
// have fixed:
|
|
@@ -2239,5 +2242,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2239
2242
|
|
|
2240
2243
|
|
|
2241
2244
|
|
|
2245
|
+
|
|
2242
2246
|
/***/ })
|
|
2243
2247
|
/******/ ]);
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export {Status} from "./util/status.js";
|
|
|
39
39
|
// GraphQL
|
|
40
40
|
////////////////////////////////////////////////////////////////////////////////
|
|
41
41
|
export {getGqlRequestId} from "./util/get-gql-request-id.js";
|
|
42
|
+
export {getGqlDataFromResponse} from "./util/get-gql-data-from-response.js";
|
|
42
43
|
export {graphQLDocumentNodeParser} from "./util/graphql-document-node-parser.js";
|
|
43
44
|
export {toGqlOperation} from "./util/to-gql-operation.js";
|
|
44
45
|
export {GqlRouter} from "./components/gql-router.js";
|