@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/types/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { Source, DocumentNode, GraphQLError } from 'graphql';
|
|
|
2
2
|
export { OperationTypeNode } from 'graphql';
|
|
3
3
|
import { GRAPHQL_AUTH_MODE } from '@aws-amplify/auth';
|
|
4
4
|
export { GRAPHQL_AUTH_MODE };
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
7
|
+
* See the migration guide:
|
|
8
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
9
|
+
*/
|
|
5
10
|
export interface GraphQLOptions {
|
|
6
11
|
query: string | DocumentNode;
|
|
7
12
|
variables?: object;
|
|
@@ -12,6 +17,11 @@ export interface GraphQLOptions {
|
|
|
12
17
|
*/
|
|
13
18
|
userAgentSuffix?: string;
|
|
14
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
22
|
+
* See the migration guide:
|
|
23
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
24
|
+
*/
|
|
15
25
|
export interface GraphQLResult<T = object> {
|
|
16
26
|
data?: T;
|
|
17
27
|
errors?: GraphQLError[];
|
|
@@ -19,6 +29,11 @@ export interface GraphQLResult<T = object> {
|
|
|
19
29
|
[key: string]: any;
|
|
20
30
|
};
|
|
21
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
34
|
+
* See the migration guide:
|
|
35
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
36
|
+
*/
|
|
22
37
|
export declare enum GraphQLAuthError {
|
|
23
38
|
NO_API_KEY = "No api-key configured",
|
|
24
39
|
NO_CURRENT_USER = "No current user",
|
|
@@ -29,5 +44,8 @@ export declare enum GraphQLAuthError {
|
|
|
29
44
|
/**
|
|
30
45
|
* GraphQLSource or string, the type of the parameter for calling graphql.parse
|
|
31
46
|
* @see: https://graphql.org/graphql-js/language/#parse
|
|
47
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
48
|
+
* See the migration guide:
|
|
49
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
32
50
|
*/
|
|
33
51
|
export type GraphQLOperation = Source | string;
|
package/lib/types/index.js
CHANGED
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GraphQLAuthError = exports.GRAPHQL_AUTH_MODE = void 0;
|
|
4
4
|
var auth_1 = require("@aws-amplify/auth");
|
|
5
5
|
Object.defineProperty(exports, "GRAPHQL_AUTH_MODE", { enumerable: true, get: function () { return auth_1.GRAPHQL_AUTH_MODE; } });
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
8
|
+
* See the migration guide:
|
|
9
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
10
|
+
*/
|
|
6
11
|
var GraphQLAuthError;
|
|
7
12
|
(function (GraphQLAuthError) {
|
|
8
13
|
GraphQLAuthError["NO_API_KEY"] = "No api-key configured";
|
|
@@ -10,4 +15,4 @@ var GraphQLAuthError;
|
|
|
10
15
|
GraphQLAuthError["NO_CREDENTIALS"] = "No credentials";
|
|
11
16
|
GraphQLAuthError["NO_FEDERATED_JWT"] = "No federated jwt";
|
|
12
17
|
GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
|
|
13
|
-
})(GraphQLAuthError
|
|
18
|
+
})(GraphQLAuthError || (exports.GraphQLAuthError = GraphQLAuthError = {}));
|
package/lib-esm/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-esm/GraphQLAPI.js
CHANGED
|
@@ -3,6 +3,11 @@ import { __extends } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { Amplify } from '@aws-amplify/core';
|
|
5
5
|
import { InternalGraphQLAPIClass } from './internals';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
8
|
+
* See the migration guide:
|
|
9
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
10
|
+
*/
|
|
6
11
|
export var graphqlOperation = function (query, variables, authToken) {
|
|
7
12
|
if (variables === void 0) { variables = {}; }
|
|
8
13
|
return ({
|
|
@@ -13,6 +18,9 @@ export var graphqlOperation = function (query, variables, authToken) {
|
|
|
13
18
|
};
|
|
14
19
|
/**
|
|
15
20
|
* Export Cloud Logic APIs
|
|
21
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
22
|
+
* See the migration guide:
|
|
23
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
16
24
|
*/
|
|
17
25
|
var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
18
26
|
__extends(GraphQLAPIClass, _super);
|
|
@@ -35,5 +43,10 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
|
35
43
|
return GraphQLAPIClass;
|
|
36
44
|
}(InternalGraphQLAPIClass));
|
|
37
45
|
export { GraphQLAPIClass };
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Amplify JavaScript v5 is in maintenance mode. Upgrade to v6.
|
|
48
|
+
* See the migration guide:
|
|
49
|
+
* https://docs.amplify.aws/gen1/javascript/build-a-backend/troubleshooting/migrate-from-javascript-v5-to-v6/
|
|
50
|
+
*/
|
|
38
51
|
export var GraphQLAPI = new GraphQLAPIClass(null);
|
|
39
52
|
Amplify.register(GraphQLAPI);
|
|
@@ -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 (
|
|
81
|
-
|
|
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
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return __generator(this, function (
|
|
229
|
-
switch (
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (!
|
|
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
|
-
|
|
239
|
-
|
|
238
|
+
_f = (_m.sent());
|
|
239
|
+
_m.label = 2;
|
|
240
240
|
case 2:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (!
|
|
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
|
-
|
|
247
|
+
_j = _m.sent();
|
|
248
248
|
return [3 /*break*/, 5];
|
|
249
249
|
case 4:
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
_j = { Authorization: null };
|
|
251
|
+
_m.label = 5;
|
|
252
252
|
case 5:
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
_h = (_j);
|
|
254
|
+
_m.label = 6;
|
|
255
255
|
case 6:
|
|
256
|
-
|
|
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,
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
282
|
+
_m.label = 8;
|
|
283
283
|
case 8:
|
|
284
|
-
|
|
284
|
+
_m.trys.push([8, 10, , 11]);
|
|
285
285
|
return [4 /*yield*/, this._api.post(endpoint, init)];
|
|
286
286
|
case 9:
|
|
287
|
-
response =
|
|
287
|
+
response = _m.sent();
|
|
288
288
|
return [3 /*break*/, 11];
|
|
289
289
|
case 10:
|
|
290
|
-
err_1 =
|
|
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.
|