|
- exports.id = 6371;
- exports.ids = [6371];
- exports.modules = {
-
- /***/ 4367:
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- // Apollo Value Configuration
- const ApolloConfig = {
- graphql_uri: process.env.API_GRAPHQL_URI
- };
- /* harmony default export */ __webpack_exports__["default"] = (ApolloConfig);
-
- /***/ }),
-
- /***/ 6371:
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
- "use strict";
-
-
- var _client = __webpack_require__(8074);
-
- var _apolloConfig = _interopRequireDefault(__webpack_require__(4367));
-
- var _crossFetch = _interopRequireDefault(__webpack_require__(1683));
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function errorHandler(object) {
- return object.graphQLErrors.length != 0 ? object.graphQLErrors[0].message : object.networkError && object.networkError.result ? object.networkError.result.errors.join(" ; ") : object.networkError ? object.networkError[Object.keys(object.networkError)[0]].toString() : "Fetch failed";
- }
-
- function initApollo(token) {
- const httpLink = (0, _client.createHttpLink)({
- uri: _apolloConfig.default.graphql_uri,
- fetch: _crossFetch.default,
- headers: token != "" ? {
- Authorization: `Bearer ${token}`
- } : null
- });
- return new _client.ApolloClient({
- ssrMode: false,
- cache: new _client.InMemoryCache({
- addTypename: false
- }),
- link: httpLink
- });
- }
-
- async function query(query, token = "", variables = {}, cache = false) {
- const client = initApollo(token);
- var res;
-
- try {
- var sql = await client.query({
- query: (0, _client.gql)`
- ${query}
- `,
- variables: variables,
- fetchPolicy: cache ? "cache-first" : "no-cache"
- });
- res = {
- STATUS: 1,
- DATA: sql.data
- };
- } catch (e) {
- res = {
- STATUS: 0,
- DATA: errorHandler(e)
- };
- }
-
- return res;
- }
-
- async function mutation(mutation, token = "", variables = {}) {
- const client = initApollo(token);
- var res;
-
- try {
- var sql = await client.mutate({
- mutation: (0, _client.gql)`
- ${mutation}
- `,
- variables: variables
- });
- res = {
- STATUS: 1,
- DATA: sql.data
- };
- } catch (e) {
- console.log(e.networkError.result);
- res = {
- STATUS: 0,
- DATA: errorHandler(e)
- };
- }
-
- return res;
- }
-
- module.exports = {
- query: query,
- mutation: mutation
- };
-
- /***/ })
-
- };
- ;
|