@aws-amplify/api-graphql 2.3.20-unstable.11 → 2.3.20-unstable.14

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.
@@ -14067,6 +14067,7 @@ var GraphQLAPIClass = /** @class */function () {
14067
14067
  switch (operationType) {
14068
14068
  case 'query':
14069
14069
  case 'mutation':
14070
+ this.createInstanceIfNotCreated();
14070
14071
  var cancellableToken = this._api.getCancellableToken();
14071
14072
  var initParams = {
14072
14073
  cancellableToken: cancellableToken
@@ -14106,46 +14107,41 @@ var GraphQLAPIClass = /** @class */function () {
14106
14107
  return __generator(this, function (_l) {
14107
14108
  switch (_l.label) {
14108
14109
  case 0:
14109
- if (!!this._api) return [3 /*break*/, 2];
14110
- return [4 /*yield*/, this.createInstance()];
14111
- case 1:
14112
- _l.sent();
14113
- _l.label = 2;
14114
- case 2:
14110
+ this.createInstanceIfNotCreated();
14115
14111
  _b = this._options, region = _b.aws_appsync_region, appSyncGraphqlEndpoint = _b.aws_appsync_graphqlEndpoint, _c = _b.graphql_headers, graphql_headers = _c === void 0 ? function () {
14116
14112
  return {};
14117
14113
  } : _c, customGraphqlEndpoint = _b.graphql_endpoint, customEndpointRegion = _b.graphql_endpoint_iam_region;
14118
14114
  _d = [{}];
14119
14115
  _e = !customGraphqlEndpoint;
14120
- if (!_e) return [3 /*break*/, 4];
14116
+ if (!_e) return [3 /*break*/, 2];
14121
14117
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
14122
- case 3:
14118
+ case 1:
14123
14119
  _e = _l.sent();
14124
- _l.label = 4;
14125
- case 4:
14120
+ _l.label = 2;
14121
+ case 2:
14126
14122
  _f = [__assign.apply(void 0, _d.concat([_e]))];
14127
14123
  _g = customGraphqlEndpoint;
14128
- if (!_g) return [3 /*break*/, 8];
14129
- if (!customEndpointRegion) return [3 /*break*/, 6];
14124
+ if (!_g) return [3 /*break*/, 6];
14125
+ if (!customEndpointRegion) return [3 /*break*/, 4];
14130
14126
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
14131
- case 5:
14127
+ case 3:
14132
14128
  _h = _l.sent();
14133
- return [3 /*break*/, 7];
14134
- case 6:
14129
+ return [3 /*break*/, 5];
14130
+ case 4:
14135
14131
  _h = {
14136
14132
  Authorization: null
14137
14133
  };
14138
- _l.label = 7;
14139
- case 7:
14134
+ _l.label = 5;
14135
+ case 5:
14140
14136
  _g = _h;
14141
- _l.label = 8;
14142
- case 8:
14137
+ _l.label = 6;
14138
+ case 6:
14143
14139
  _j = [__assign.apply(void 0, _f.concat([_g]))];
14144
14140
  return [4 /*yield*/, graphql_headers({
14145
14141
  query: query,
14146
14142
  variables: variables
14147
14143
  })];
14148
- case 9:
14144
+ case 7:
14149
14145
  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)]);
14150
14146
  body = {
14151
14147
  query: Object(graphql__WEBPACK_IMPORTED_MODULE_0__["print"])(query),
@@ -14167,14 +14163,14 @@ var GraphQLAPIClass = /** @class */function () {
14167
14163
  errors: [error]
14168
14164
  };
14169
14165
  }
14170
- _l.label = 10;
14171
- case 10:
14172
- _l.trys.push([10, 12,, 13]);
14166
+ _l.label = 8;
14167
+ case 8:
14168
+ _l.trys.push([8, 10,, 11]);
14173
14169
  return [4 /*yield*/, this._api.post(endpoint, init)];
14174
- case 11:
14170
+ case 9:
14175
14171
  response = _l.sent();
14176
- return [3 /*break*/, 13];
14177
- case 12:
14172
+ return [3 /*break*/, 11];
14173
+ case 10:
14178
14174
  err_1 = _l.sent();
14179
14175
  // If the exception is because user intentionally
14180
14176
  // cancelled the request, do not modify the exception
@@ -14186,8 +14182,8 @@ var GraphQLAPIClass = /** @class */function () {
14186
14182
  data: {},
14187
14183
  errors: [new graphql__WEBPACK_IMPORTED_MODULE_0__["GraphQLError"](err_1.message, null, null, null, null, err_1)]
14188
14184
  };
14189
- return [3 /*break*/, 13];
14190
- case 13:
14185
+ return [3 /*break*/, 11];
14186
+ case 11:
14191
14187
  errors = response.errors;
14192
14188
  if (errors && errors.length) {
14193
14189
  throw response;
@@ -14197,6 +14193,22 @@ var GraphQLAPIClass = /** @class */function () {
14197
14193
  });
14198
14194
  });
14199
14195
  };
14196
+ GraphQLAPIClass.prototype.createInstanceIfNotCreated = function () {
14197
+ return __awaiter(this, void 0, void 0, function () {
14198
+ return __generator(this, function (_a) {
14199
+ switch (_a.label) {
14200
+ case 0:
14201
+ if (!!this._api) return [3 /*break*/, 2];
14202
+ return [4 /*yield*/, this.createInstance()];
14203
+ case 1:
14204
+ _a.sent();
14205
+ _a.label = 2;
14206
+ case 2:
14207
+ return [2 /*return*/];
14208
+ }
14209
+ });
14210
+ });
14211
+ };
14200
14212
  /**
14201
14213
  * Checks to see if an error thrown is from an api request cancellation
14202
14214
  * @param {any} error - Any error