@aws-amplify/api-graphql 3.4.29 → 3.4.31

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.
@@ -10,4 +10,4 @@ var GraphQLAuthError;
10
10
  GraphQLAuthError["NO_CREDENTIALS"] = "No credentials";
11
11
  GraphQLAuthError["NO_FEDERATED_JWT"] = "No federated jwt";
12
12
  GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
13
- })(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));
13
+ })(GraphQLAuthError || (exports.GraphQLAuthError = GraphQLAuthError = {}));
@@ -77,10 +77,10 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
77
77
  return Promise.reject('API not configured');
78
78
  }
79
79
  };
80
- InternalGraphQLAPIClass.prototype._headerBasedAuth = function (defaultAuthenticationType, additionalHeaders) {
81
- if (additionalHeaders === void 0) { additionalHeaders = {}; }
82
- return __awaiter(this, void 0, void 0, function () {
80
+ InternalGraphQLAPIClass.prototype._headerBasedAuth = function (defaultAuthenticationType_1) {
81
+ return __awaiter(this, arguments, void 0, function (defaultAuthenticationType, additionalHeaders) {
83
82
  var _a, aws_appsync_authenticationType, apiKey, authenticationType, headers, _b, credentialsOK, token, federatedInfo, currentUser, e_1, session, e_2;
83
+ if (additionalHeaders === void 0) { additionalHeaders = {}; }
84
84
  return __generator(this, function (_c) {
85
85
  switch (_c.label) {
86
86
  case 0:
@@ -218,47 +218,47 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
218
218
  throw new Error("invalid operation type: ".concat(operationType));
219
219
  }
220
220
  };
221
- InternalGraphQLAPIClass.prototype._graphql = function (_a, additionalHeaders, initParams, customUserAgentDetails) {
222
- var query = _a.query, variables = _a.variables, authMode = _a.authMode;
223
- if (additionalHeaders === void 0) { additionalHeaders = {}; }
224
- if (initParams === void 0) { initParams = {}; }
225
- return __awaiter(this, void 0, void 0, function () {
226
- var _b, region, appSyncGraphqlEndpoint, _c, graphql_headers, customGraphqlEndpoint, customEndpointRegion, headers, _d, _e, _f, _g, _h, _j, body, init, endpoint, error, response, err_1, errors;
227
- var _k;
228
- return __generator(this, function (_l) {
229
- switch (_l.label) {
221
+ InternalGraphQLAPIClass.prototype._graphql = function (_a) {
222
+ return __awaiter(this, arguments, void 0, function (_b, additionalHeaders, initParams, customUserAgentDetails) {
223
+ var _c, region, appSyncGraphqlEndpoint, _d, graphql_headers, customGraphqlEndpoint, customEndpointRegion, headers, _e, _f, _g, _h, _j, _k, body, init, endpoint, error, response, err_1, errors;
224
+ var _l;
225
+ var query = _b.query, variables = _b.variables, authMode = _b.authMode;
226
+ if (additionalHeaders === void 0) { additionalHeaders = {}; }
227
+ if (initParams === void 0) { initParams = {}; }
228
+ return __generator(this, function (_m) {
229
+ switch (_m.label) {
230
230
  case 0:
231
231
  this.createInstanceIfNotCreated();
232
- _b = this._options, region = _b.aws_appsync_region, appSyncGraphqlEndpoint = _b.aws_appsync_graphqlEndpoint, _c = _b.graphql_headers, graphql_headers = _c === void 0 ? function () { return ({}); } : _c, customGraphqlEndpoint = _b.graphql_endpoint, customEndpointRegion = _b.graphql_endpoint_iam_region;
233
- _d = [{}];
234
- _e = !customGraphqlEndpoint;
235
- if (!_e) return [3 /*break*/, 2];
232
+ _c = this._options, region = _c.aws_appsync_region, appSyncGraphqlEndpoint = _c.aws_appsync_graphqlEndpoint, _d = _c.graphql_headers, graphql_headers = _d === void 0 ? function () { return ({}); } : _d, customGraphqlEndpoint = _c.graphql_endpoint, customEndpointRegion = _c.graphql_endpoint_iam_region;
233
+ _e = [{}];
234
+ _f = !customGraphqlEndpoint;
235
+ if (!_f) return [3 /*break*/, 2];
236
236
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
237
237
  case 1:
238
- _e = (_l.sent());
239
- _l.label = 2;
238
+ _f = (_m.sent());
239
+ _m.label = 2;
240
240
  case 2:
241
- _f = [__assign.apply(void 0, _d.concat([(_e)]))];
242
- _g = customGraphqlEndpoint;
243
- if (!_g) return [3 /*break*/, 6];
241
+ _g = [__assign.apply(void 0, _e.concat([(_f)]))];
242
+ _h = customGraphqlEndpoint;
243
+ if (!_h) return [3 /*break*/, 6];
244
244
  if (!customEndpointRegion) return [3 /*break*/, 4];
245
245
  return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
246
246
  case 3:
247
- _h = _l.sent();
247
+ _j = _m.sent();
248
248
  return [3 /*break*/, 5];
249
249
  case 4:
250
- _h = { Authorization: null };
251
- _l.label = 5;
250
+ _j = { Authorization: null };
251
+ _m.label = 5;
252
252
  case 5:
253
- _g = (_h);
254
- _l.label = 6;
253
+ _h = (_j);
254
+ _m.label = 6;
255
255
  case 6:
256
- _j = [__assign.apply(void 0, _f.concat([(_g)]))];
256
+ _k = [__assign.apply(void 0, _g.concat([(_h)]))];
257
257
  return [4 /*yield*/, graphql_headers({ query: query, variables: variables })];
258
258
  case 7:
259
- headers = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _j.concat([(_l.sent())])), additionalHeaders]), (!customGraphqlEndpoint && (_k = {},
260
- _k[USER_AGENT_HEADER] = getAmplifyUserAgent(customUserAgentDetails),
261
- _k))]);
259
+ headers = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _k.concat([(_m.sent())])), additionalHeaders]), (!customGraphqlEndpoint && (_l = {},
260
+ _l[USER_AGENT_HEADER] = getAmplifyUserAgent(customUserAgentDetails),
261
+ _l))]);
262
262
  body = {
263
263
  query: print(query),
264
264
  variables: variables,
@@ -279,15 +279,15 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
279
279
  errors: [error],
280
280
  };
281
281
  }
282
- _l.label = 8;
282
+ _m.label = 8;
283
283
  case 8:
284
- _l.trys.push([8, 10, , 11]);
284
+ _m.trys.push([8, 10, , 11]);
285
285
  return [4 /*yield*/, this._api.post(endpoint, init)];
286
286
  case 9:
287
- response = _l.sent();
287
+ response = _m.sent();
288
288
  return [3 /*break*/, 11];
289
289
  case 10:
290
- err_1 = _l.sent();
290
+ err_1 = _m.sent();
291
291
  // If the exception is because user intentionally
292
292
  // cancelled the request, do not modify the exception
293
293
  // so that clients can identify the exception correctly.