@aws-amplify/api-graphql 3.4.29 → 3.4.32
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/lib/GraphQLAPI.d.ts +13 -0
- package/lib/GraphQLAPI.js +13 -0
- package/lib/internals/InternalGraphQLAPI.js +34 -34
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/index.d.ts +18 -0
- package/lib/types/index.js +6 -1
- package/lib-esm/GraphQLAPI.d.ts +13 -0
- package/lib-esm/GraphQLAPI.js +13 -0
- package/lib-esm/internals/InternalGraphQLAPI.js +34 -34
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/index.d.ts +18 -0
- package/lib-esm/types/index.js +5 -0
- package/package.json +23 -16
- package/src/GraphQLAPI.ts +13 -0
- package/src/types/index.ts +18 -0
package/lib/GraphQLAPI.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { GraphQLOptions, GraphQLResult } from './types';
|
|
2
2
|
import { InternalGraphQLAPIClass } from './internals';
|
|
3
3
|
import Observable from 'zen-observable-ts';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
6
|
+
* See the migration guide:
|
|
7
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
8
|
+
*/
|
|
4
9
|
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
|
|
5
10
|
query: any;
|
|
6
11
|
variables: {};
|
|
@@ -8,6 +13,9 @@ export declare const graphqlOperation: (query: any, variables?: {}, authToken?:
|
|
|
8
13
|
};
|
|
9
14
|
/**
|
|
10
15
|
* Export Cloud Logic APIs
|
|
16
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
17
|
+
* See the migration guide:
|
|
18
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
11
19
|
*/
|
|
12
20
|
export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
13
21
|
getModuleName(): string;
|
|
@@ -22,4 +30,9 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
|
22
30
|
[key: string]: string;
|
|
23
31
|
}): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
|
|
24
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
35
|
+
* See the migration guide:
|
|
36
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
37
|
+
*/
|
|
25
38
|
export declare const GraphQLAPI: GraphQLAPIClass;
|
package/lib/GraphQLAPI.js
CHANGED
|
@@ -6,6 +6,11 @@ var tslib_1 = require("tslib");
|
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
var core_1 = require("@aws-amplify/core");
|
|
8
8
|
var internals_1 = require("./internals");
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
11
|
+
* See the migration guide:
|
|
12
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
13
|
+
*/
|
|
9
14
|
var graphqlOperation = function (query, variables, authToken) {
|
|
10
15
|
if (variables === void 0) { variables = {}; }
|
|
11
16
|
return ({
|
|
@@ -17,6 +22,9 @@ var graphqlOperation = function (query, variables, authToken) {
|
|
|
17
22
|
exports.graphqlOperation = graphqlOperation;
|
|
18
23
|
/**
|
|
19
24
|
* Export Cloud Logic APIs
|
|
25
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
26
|
+
* See the migration guide:
|
|
27
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
20
28
|
*/
|
|
21
29
|
var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
22
30
|
tslib_1.__extends(GraphQLAPIClass, _super);
|
|
@@ -39,5 +47,10 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
|
39
47
|
return GraphQLAPIClass;
|
|
40
48
|
}(internals_1.InternalGraphQLAPIClass));
|
|
41
49
|
exports.GraphQLAPIClass = GraphQLAPIClass;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
52
|
+
* See the migration guide:
|
|
53
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
54
|
+
*/
|
|
42
55
|
exports.GraphQLAPI = new GraphQLAPIClass(null);
|
|
43
56
|
core_1.Amplify.register(exports.GraphQLAPI);
|
|
@@ -81,10 +81,10 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
|
|
|
81
81
|
return Promise.reject('API not configured');
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
InternalGraphQLAPIClass.prototype._headerBasedAuth = function (
|
|
85
|
-
|
|
86
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
84
|
+
InternalGraphQLAPIClass.prototype._headerBasedAuth = function (defaultAuthenticationType_1) {
|
|
85
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (defaultAuthenticationType, additionalHeaders) {
|
|
87
86
|
var _a, aws_appsync_authenticationType, apiKey, authenticationType, headers, _b, credentialsOK, token, federatedInfo, currentUser, e_1, session, e_2;
|
|
87
|
+
if (additionalHeaders === void 0) { additionalHeaders = {}; }
|
|
88
88
|
return tslib_1.__generator(this, function (_c) {
|
|
89
89
|
switch (_c.label) {
|
|
90
90
|
case 0:
|
|
@@ -222,47 +222,47 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
|
|
|
222
222
|
throw new Error("invalid operation type: ".concat(operationType));
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
|
-
InternalGraphQLAPIClass.prototype._graphql = function (_a
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return tslib_1.__generator(this, function (
|
|
233
|
-
switch (
|
|
225
|
+
InternalGraphQLAPIClass.prototype._graphql = function (_a) {
|
|
226
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (_b, additionalHeaders, initParams, customUserAgentDetails) {
|
|
227
|
+
var _c, region, appSyncGraphqlEndpoint, _d, graphql_headers, customGraphqlEndpoint, customEndpointRegion, headers, _e, _f, _g, _h, _j, _k, body, init, endpoint, error, response, err_1, errors;
|
|
228
|
+
var _l;
|
|
229
|
+
var query = _b.query, variables = _b.variables, authMode = _b.authMode;
|
|
230
|
+
if (additionalHeaders === void 0) { additionalHeaders = {}; }
|
|
231
|
+
if (initParams === void 0) { initParams = {}; }
|
|
232
|
+
return tslib_1.__generator(this, function (_m) {
|
|
233
|
+
switch (_m.label) {
|
|
234
234
|
case 0:
|
|
235
235
|
this.createInstanceIfNotCreated();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (!
|
|
236
|
+
_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;
|
|
237
|
+
_e = [{}];
|
|
238
|
+
_f = !customGraphqlEndpoint;
|
|
239
|
+
if (!_f) return [3 /*break*/, 2];
|
|
240
240
|
return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
|
|
241
241
|
case 1:
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
_f = (_m.sent());
|
|
243
|
+
_m.label = 2;
|
|
244
244
|
case 2:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (!
|
|
245
|
+
_g = [tslib_1.__assign.apply(void 0, _e.concat([(_f)]))];
|
|
246
|
+
_h = customGraphqlEndpoint;
|
|
247
|
+
if (!_h) return [3 /*break*/, 6];
|
|
248
248
|
if (!customEndpointRegion) return [3 /*break*/, 4];
|
|
249
249
|
return [4 /*yield*/, this._headerBasedAuth(authMode, additionalHeaders)];
|
|
250
250
|
case 3:
|
|
251
|
-
|
|
251
|
+
_j = _m.sent();
|
|
252
252
|
return [3 /*break*/, 5];
|
|
253
253
|
case 4:
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
_j = { Authorization: null };
|
|
255
|
+
_m.label = 5;
|
|
256
256
|
case 5:
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
_h = (_j);
|
|
258
|
+
_m.label = 6;
|
|
259
259
|
case 6:
|
|
260
|
-
|
|
260
|
+
_k = [tslib_1.__assign.apply(void 0, _g.concat([(_h)]))];
|
|
261
261
|
return [4 /*yield*/, graphql_headers({ query: query, variables: variables })];
|
|
262
262
|
case 7:
|
|
263
|
-
headers = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0,
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
headers = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _k.concat([(_m.sent())])), additionalHeaders]), (!customGraphqlEndpoint && (_l = {},
|
|
264
|
+
_l[USER_AGENT_HEADER] = (0, core_1.getAmplifyUserAgent)(customUserAgentDetails),
|
|
265
|
+
_l))]);
|
|
266
266
|
body = {
|
|
267
267
|
query: (0, graphql_1.print)(query),
|
|
268
268
|
variables: variables,
|
|
@@ -283,15 +283,15 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
|
|
|
283
283
|
errors: [error],
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
|
-
|
|
286
|
+
_m.label = 8;
|
|
287
287
|
case 8:
|
|
288
|
-
|
|
288
|
+
_m.trys.push([8, 10, , 11]);
|
|
289
289
|
return [4 /*yield*/, this._api.post(endpoint, init)];
|
|
290
290
|
case 9:
|
|
291
|
-
response =
|
|
291
|
+
response = _m.sent();
|
|
292
292
|
return [3 /*break*/, 11];
|
|
293
293
|
case 10:
|
|
294
|
-
err_1 =
|
|
294
|
+
err_1 = _m.sent();
|
|
295
295
|
// If the exception is because user intentionally
|
|
296
296
|
// cancelled the request, do not modify the exception
|
|
297
297
|
// so that clients can identify the exception correctly.
|