@aws-amplify/datastore 3.12.13-unstable.13 → 3.12.13-unstable.15

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.
@@ -57970,6 +57970,7 @@ var GraphQLAPIClass = /** @class */function () {
57970
57970
  switch (operationType) {
57971
57971
  case 'query':
57972
57972
  case 'mutation':
57973
+ this.createInstanceIfNotCreated();
57973
57974
  var cancellableToken = this._api.getCancellableToken();
57974
57975
  var initParams = {
57975
57976
  cancellableToken: cancellableToken
@@ -58009,46 +58010,41 @@ var GraphQLAPIClass = /** @class */function () {
58009
58010
  return __generator(this, function (_l) {
58010
58011
  switch (_l.label) {
58011
58012
  case 0:
58012
- if (!!this._api) return [3 /*break*/, 2];
58013
- return [4 /*yield*/, this.createInstance()];
58014
- case 1:
58015
- _l.sent();
58016
- _l.label = 2;
58017
- case 2:
58013
+ this.createInstanceIfNotCreated();
58018
58014
  _b = this._options, region = _b.aws_appsync_region, appSyncGraphqlEndpoint = _b.aws_appsync_graphqlEndpoint, _c = _b.graphql_headers, graphql_headers = _c === void 0 ? function () {
58019
58015
  return {};
58020
58016
  } : _c, customGraphqlEndpoint = _b.graphql_endpoint, customEndpointRegion = _b.graphql_endpoint_iam_region;
58021
58017
  _d = [{}];
58022
58018
  _e = !customGraphqlEndpoint;
58023
- if (!_e) return [3 /*break*/, 4];
58019
+ if (!_e) return [3 /*break*/, 2];
58024
58020
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
58025
- case 3:
58021
+ case 1:
58026
58022
  _e = _l.sent();
58027
- _l.label = 4;
58028
- case 4:
58023
+ _l.label = 2;
58024
+ case 2:
58029
58025
  _f = [__assign.apply(void 0, _d.concat([_e]))];
58030
58026
  _g = customGraphqlEndpoint;
58031
- if (!_g) return [3 /*break*/, 8];
58032
- if (!customEndpointRegion) return [3 /*break*/, 6];
58027
+ if (!_g) return [3 /*break*/, 6];
58028
+ if (!customEndpointRegion) return [3 /*break*/, 4];
58033
58029
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
58034
- case 5:
58030
+ case 3:
58035
58031
  _h = _l.sent();
58036
- return [3 /*break*/, 7];
58037
- case 6:
58032
+ return [3 /*break*/, 5];
58033
+ case 4:
58038
58034
  _h = {
58039
58035
  Authorization: null
58040
58036
  };
58041
- _l.label = 7;
58042
- case 7:
58037
+ _l.label = 5;
58038
+ case 5:
58043
58039
  _g = _h;
58044
- _l.label = 8;
58045
- case 8:
58040
+ _l.label = 6;
58041
+ case 6:
58046
58042
  _j = [__assign.apply(void 0, _f.concat([_g]))];
58047
58043
  return [4 /*yield*/, graphql_headers({
58048
58044
  query: query,
58049
58045
  variables: variables
58050
58046
  })];
58051
- case 9:
58047
+ case 7:
58052
58048
  headers = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _j.concat([_l.sent()])), additionalHeaders]), !customGraphqlEndpoint && (_k = {}, _k[USER_AGENT_HEADER] = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["getAmplifyUserAgent"])(userAgentSuffix), _k)]);
58053
58049
  body = {
58054
58050
  query: Object(graphql__WEBPACK_IMPORTED_MODULE_0__["print"])(query),
@@ -58070,14 +58066,14 @@ var GraphQLAPIClass = /** @class */function () {
58070
58066
  errors: [error]
58071
58067
  };
58072
58068
  }
58073
- _l.label = 10;
58074
- case 10:
58075
- _l.trys.push([10, 12,, 13]);
58069
+ _l.label = 8;
58070
+ case 8:
58071
+ _l.trys.push([8, 10,, 11]);
58076
58072
  return [4 /*yield*/, this._api.post(endpoint, init)];
58077
- case 11:
58073
+ case 9:
58078
58074
  response = _l.sent();
58079
- return [3 /*break*/, 13];
58080
- case 12:
58075
+ return [3 /*break*/, 11];
58076
+ case 10:
58081
58077
  err_1 = _l.sent();
58082
58078
  // If the exception is because user intentionally
58083
58079
  // cancelled the request, do not modify the exception
@@ -58089,8 +58085,8 @@ var GraphQLAPIClass = /** @class */function () {
58089
58085
  data: {},
58090
58086
  errors: [new graphql__WEBPACK_IMPORTED_MODULE_0__["GraphQLError"](err_1.message, null, null, null, null, err_1)]
58091
58087
  };
58092
- return [3 /*break*/, 13];
58093
- case 13:
58088
+ return [3 /*break*/, 11];
58089
+ case 11:
58094
58090
  errors = response.errors;
58095
58091
  if (errors && errors.length) {
58096
58092
  throw response;
@@ -58100,6 +58096,22 @@ var GraphQLAPIClass = /** @class */function () {
58100
58096
  });
58101
58097
  });
58102
58098
  };
58099
+ GraphQLAPIClass.prototype.createInstanceIfNotCreated = function () {
58100
+ return __awaiter(this, void 0, void 0, function () {
58101
+ return __generator(this, function (_a) {
58102
+ switch (_a.label) {
58103
+ case 0:
58104
+ if (!!this._api) return [3 /*break*/, 2];
58105
+ return [4 /*yield*/, this.createInstance()];
58106
+ case 1:
58107
+ _a.sent();
58108
+ _a.label = 2;
58109
+ case 2:
58110
+ return [2 /*return*/];
58111
+ }
58112
+ });
58113
+ });
58114
+ };
58103
58115
  /**
58104
58116
  * Checks to see if an error thrown is from an api request cancellation
58105
58117
  * @param {any} error - Any error