@aws-amplify/api-graphql 4.0.1-console-preview.3d7f188.0 → 4.0.1-server-generate-client.1e317a1.0
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 +2 -2
- package/lib/GraphQLAPI.js +4 -6
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +36 -36
- package/lib/Providers/constants.js +5 -4
- package/lib/index.js +5 -4
- package/lib/internals/APIClient.d.ts +101 -0
- package/lib/internals/APIClient.js +443 -0
- package/lib/internals/InternalGraphQLAPI.d.ts +2 -2
- package/lib/internals/InternalGraphQLAPI.js +36 -18
- package/lib/internals/generateClient.d.ts +12 -0
- package/lib/internals/generateClient.js +30 -0
- package/lib/internals/generateModelsProperty.d.ts +4 -0
- package/lib/internals/generateModelsProperty.js +169 -0
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +8 -5
- package/lib/internals/types.d.ts +10 -0
- package/lib/internals/types.js +2 -0
- package/lib/internals/v6.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -6619
- package/lib/types/PubSub.d.ts +2 -2
- package/lib/types/PubSub.js +3 -2
- package/lib/types/index.d.ts +25 -22
- package/lib/types/index.js +4 -3
- package/lib/utils/ConnectionStateMonitor.d.ts +3 -3
- package/lib/utils/ConnectionStateMonitor.js +7 -6
- package/lib/utils/ReachabilityMonitor/index.d.ts +1 -1
- package/lib/utils/ReachabilityMonitor/index.js +3 -1
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -1
- package/lib/utils/ReachabilityMonitor/index.native.js +3 -1
- package/lib/utils/ReconnectionMonitor.js +2 -1
- package/lib/utils/errors/APIError.js +1 -0
- package/lib/utils/errors/assertValidationError.js +1 -0
- package/lib/utils/errors/index.js +5 -4
- package/lib/utils/errors/validation.js +2 -1
- package/lib/utils/index.js +3 -2
- package/lib/utils/resolveConfig.d.ts +1 -1
- package/lib/utils/resolveConfig.js +4 -2
- package/lib/utils/resolveLibraryOptions.d.ts +1 -1
- package/lib/utils/resolveLibraryOptions.js +3 -1
- package/lib/utils/resolveOwnerFields.d.ts +12 -0
- package/lib/utils/resolveOwnerFields.js +63 -0
- package/lib-esm/GraphQLAPI.d.ts +2 -2
- package/lib-esm/GraphQLAPI.js +1 -5
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +28 -29
- package/lib-esm/internals/APIClient.d.ts +101 -0
- package/lib-esm/internals/APIClient.js +432 -0
- package/lib-esm/internals/InternalGraphQLAPI.d.ts +2 -2
- package/lib-esm/internals/InternalGraphQLAPI.js +22 -6
- package/lib-esm/internals/generateClient.d.ts +12 -0
- package/lib-esm/internals/generateClient.js +26 -0
- package/lib-esm/internals/generateModelsProperty.d.ts +4 -0
- package/lib-esm/internals/generateModelsProperty.js +165 -0
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +1 -0
- package/lib-esm/internals/types.d.ts +10 -0
- package/lib-esm/internals/types.js +1 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -6619
- package/lib-esm/types/PubSub.d.ts +2 -2
- package/lib-esm/types/index.d.ts +25 -22
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +3 -3
- package/lib-esm/utils/ConnectionStateMonitor.js +2 -2
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -1
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -1
- package/lib-esm/utils/resolveConfig.d.ts +1 -1
- package/lib-esm/utils/resolveLibraryOptions.d.ts +1 -1
- package/lib-esm/utils/resolveOwnerFields.d.ts +12 -0
- package/lib-esm/utils/resolveOwnerFields.js +59 -0
- package/package.json +12 -6
- package/src/GraphQLAPI.ts +2 -6
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +2 -3
- package/src/internals/APIClient.ts +583 -0
- package/src/internals/InternalGraphQLAPI.ts +36 -10
- package/src/internals/generateClient.ts +30 -0
- package/src/internals/generateModelsProperty.ts +192 -0
- package/src/internals/index.ts +1 -0
- package/src/internals/types.ts +15 -0
- package/src/types/index.ts +7 -1
- package/src/utils/resolveOwnerFields.ts +65 -0
|
@@ -3,6 +3,7 @@ import { __assign, __awaiter, __generator, __read } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { GraphQLError } from 'graphql';
|
|
6
|
+
import * as url from 'url';
|
|
6
7
|
import { Buffer } from 'buffer';
|
|
7
8
|
import { Hub, fetchAuthSession, ConsoleLogger } from '@aws-amplify/core';
|
|
8
9
|
import { signRequest } from '@aws-amplify/core/internals/aws-client-utils';
|
|
@@ -19,8 +20,8 @@ var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,
|
|
|
19
20
|
var customDomainPath = '/realtime';
|
|
20
21
|
var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
21
22
|
function AWSAppSyncRealTimeProvider(options) {
|
|
22
|
-
var _this = this;
|
|
23
23
|
if (options === void 0) { options = {}; }
|
|
24
|
+
var _this = this;
|
|
24
25
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
25
26
|
this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
|
|
26
27
|
this.subscriptionObserverMap = new Map();
|
|
@@ -36,7 +37,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
36
37
|
provider: _this,
|
|
37
38
|
connectionState: connectionState,
|
|
38
39
|
},
|
|
39
|
-
message: "Connection state is "
|
|
40
|
+
message: "Connection state is ".concat(connectionState),
|
|
40
41
|
});
|
|
41
42
|
_this.connectionState = connectionState;
|
|
42
43
|
// Trigger START_RECONNECT when the connection is disrupted
|
|
@@ -111,7 +112,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
111
112
|
subscriptionId: subscriptionId_1,
|
|
112
113
|
customUserAgentDetails: customUserAgentDetails,
|
|
113
114
|
}).catch(function (err) {
|
|
114
|
-
logger.debug(CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR
|
|
115
|
+
logger.debug("".concat(CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR, ": ").concat(err));
|
|
115
116
|
_this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
116
117
|
});
|
|
117
118
|
startSubscriptionPromise.finally(function () {
|
|
@@ -156,7 +157,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
156
157
|
return [3 /*break*/, 5];
|
|
157
158
|
case 3:
|
|
158
159
|
err_1 = _a.sent();
|
|
159
|
-
logger.debug("Error while unsubscribing "
|
|
160
|
+
logger.debug("Error while unsubscribing ".concat(err_1));
|
|
160
161
|
return [3 /*break*/, 5];
|
|
161
162
|
case 4:
|
|
162
163
|
this._removeSubscriptionObserver(subscriptionId_1);
|
|
@@ -169,8 +170,8 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
169
170
|
});
|
|
170
171
|
};
|
|
171
172
|
AWSAppSyncRealTimeProvider.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
|
|
172
|
-
var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId, customUserAgentDetails = _a.customUserAgentDetails;
|
|
173
173
|
var _b;
|
|
174
|
+
var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId, customUserAgentDetails = _a.customUserAgentDetails;
|
|
174
175
|
return __awaiter(this, void 0, void 0, function () {
|
|
175
176
|
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _c, graphql_headers, _d, additionalHeaders, subscriptionState, data, dataString, headerObj, _e, _f, subscriptionMessage, stringToAWSRealTime, err_2, _g, subscriptionFailedCallback, subscriptionReadyCallback;
|
|
176
177
|
var _h;
|
|
@@ -272,12 +273,12 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
272
273
|
if (isNonRetryableError(err)) {
|
|
273
274
|
observer.error({
|
|
274
275
|
errors: [
|
|
275
|
-
__assign({}, new GraphQLError(CONTROL_MSG.CONNECTION_FAILED
|
|
276
|
+
__assign({}, new GraphQLError("".concat(CONTROL_MSG.CONNECTION_FAILED, ": ").concat(message))),
|
|
276
277
|
],
|
|
277
278
|
});
|
|
278
279
|
}
|
|
279
280
|
else {
|
|
280
|
-
logger.debug(CONTROL_MSG.CONNECTION_FAILED
|
|
281
|
+
logger.debug("".concat(CONTROL_MSG.CONNECTION_FAILED, ": ").concat(message));
|
|
281
282
|
}
|
|
282
283
|
var subscriptionFailedCallback = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback;
|
|
283
284
|
// Notify concurrent unsubscription
|
|
@@ -375,7 +376,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
375
376
|
if (typeof message.data !== 'string') {
|
|
376
377
|
return;
|
|
377
378
|
}
|
|
378
|
-
logger.debug("subscription message from AWS AppSync RealTime: "
|
|
379
|
+
logger.debug("subscription message from AWS AppSync RealTime: ".concat(message.data));
|
|
379
380
|
var _a = JSON.parse(String(message.data)), _b = _a.id, id = _b === void 0 ? '' : _b, payload = _a.payload, type = _a.type;
|
|
380
381
|
var _c = this.subscriptionObserverMap.get(id) || {}, _d = _c.observer, observer = _d === void 0 ? null : _d, _e = _c.query, query = _e === void 0 ? '' : _e, _f = _c.variables, variables = _f === void 0 ? {} : _f, startAckTimeoutId = _c.startAckTimeoutId, subscriptionReadyCallback = _c.subscriptionReadyCallback, subscriptionFailedCallback = _c.subscriptionFailedCallback;
|
|
381
382
|
logger.debug({ id: id, observer: observer, query: query, variables: variables });
|
|
@@ -384,12 +385,12 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
384
385
|
observer.next(payload);
|
|
385
386
|
}
|
|
386
387
|
else {
|
|
387
|
-
logger.debug("observer not found for id: "
|
|
388
|
+
logger.debug("observer not found for id: ".concat(id));
|
|
388
389
|
}
|
|
389
390
|
return;
|
|
390
391
|
}
|
|
391
392
|
if (type === MESSAGE_TYPES.GQL_START_ACK) {
|
|
392
|
-
logger.debug("subscription ready for "
|
|
393
|
+
logger.debug("subscription ready for ".concat(JSON.stringify({ query: query, variables: variables })));
|
|
393
394
|
if (typeof subscriptionReadyCallback === 'function') {
|
|
394
395
|
subscriptionReadyCallback();
|
|
395
396
|
}
|
|
@@ -439,10 +440,10 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
439
440
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
440
441
|
subscriptionState: subscriptionState,
|
|
441
442
|
});
|
|
442
|
-
logger.debug(CONTROL_MSG.CONNECTION_FAILED
|
|
443
|
+
logger.debug("".concat(CONTROL_MSG.CONNECTION_FAILED, ": ").concat(JSON.stringify(payload)));
|
|
443
444
|
observer.error({
|
|
444
445
|
errors: [
|
|
445
|
-
__assign({}, new GraphQLError(CONTROL_MSG.CONNECTION_FAILED
|
|
446
|
+
__assign({}, new GraphQLError("".concat(CONTROL_MSG.CONNECTION_FAILED, ": ").concat(JSON.stringify(payload)))),
|
|
446
447
|
],
|
|
447
448
|
});
|
|
448
449
|
if (startAckTimeoutId)
|
|
@@ -454,7 +455,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
454
455
|
}
|
|
455
456
|
};
|
|
456
457
|
AWSAppSyncRealTimeProvider.prototype._errorDisconnect = function (msg) {
|
|
457
|
-
logger.debug("Disconnect error: "
|
|
458
|
+
logger.debug("Disconnect error: ".concat(msg));
|
|
458
459
|
if (this.awsRealTimeSocket) {
|
|
459
460
|
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
460
461
|
this.awsRealTimeSocket.close();
|
|
@@ -524,7 +525,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
524
525
|
discoverableEndpoint = discoverableEndpoint
|
|
525
526
|
.replace('https://', protocol)
|
|
526
527
|
.replace('http://', protocol);
|
|
527
|
-
awsRealTimeUrl = discoverableEndpoint
|
|
528
|
+
awsRealTimeUrl = "".concat(discoverableEndpoint, "?header=").concat(headerQs, "&payload=").concat(payloadQs);
|
|
528
529
|
return [4 /*yield*/, this._initializeRetryableHandshake(awsRealTimeUrl)];
|
|
529
530
|
case 3:
|
|
530
531
|
_a.sent();
|
|
@@ -577,7 +578,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
577
578
|
return __generator(this, function (_b) {
|
|
578
579
|
switch (_b.label) {
|
|
579
580
|
case 0:
|
|
580
|
-
logger.debug("Initializing handshake "
|
|
581
|
+
logger.debug("Initializing handshake ".concat(awsRealTimeUrl));
|
|
581
582
|
_b.label = 1;
|
|
582
583
|
case 1:
|
|
583
584
|
_b.trys.push([1, 4, , 5]);
|
|
@@ -604,19 +605,19 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
604
605
|
if (_this.awsRealTimeSocket) {
|
|
605
606
|
var ackOk_1 = false;
|
|
606
607
|
_this.awsRealTimeSocket.onerror = function (error) {
|
|
607
|
-
logger.debug("WebSocket error "
|
|
608
|
+
logger.debug("WebSocket error ".concat(JSON.stringify(error)));
|
|
608
609
|
};
|
|
609
610
|
_this.awsRealTimeSocket.onclose = function (event) {
|
|
610
|
-
logger.debug("WebSocket closed "
|
|
611
|
+
logger.debug("WebSocket closed ".concat(event.reason));
|
|
611
612
|
rej(new Error(JSON.stringify(event)));
|
|
612
613
|
};
|
|
613
614
|
_this.awsRealTimeSocket.onmessage = function (message) {
|
|
614
615
|
if (typeof message.data !== 'string') {
|
|
615
616
|
return;
|
|
616
617
|
}
|
|
617
|
-
logger.debug("subscription message from AWS AppSyncRealTime: "
|
|
618
|
+
logger.debug("subscription message from AWS AppSyncRealTime: ".concat(message.data, " "));
|
|
618
619
|
var data = JSON.parse(message.data);
|
|
619
|
-
var type = data.type, _a = data.payload, _b =
|
|
620
|
+
var type = data.type, _a = data.payload, _b = _a === void 0 ? {} : _a, _c = _b.connectionTimeoutMs, connectionTimeoutMs = _c === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _c;
|
|
620
621
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
|
|
621
622
|
ackOk_1 = true;
|
|
622
623
|
if (_this.awsRealTimeSocket) {
|
|
@@ -628,7 +629,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
628
629
|
_this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);
|
|
629
630
|
};
|
|
630
631
|
_this.awsRealTimeSocket.onclose = function (event) {
|
|
631
|
-
logger.debug("WebSocket closed "
|
|
632
|
+
logger.debug("WebSocket closed ".concat(event.reason));
|
|
632
633
|
_this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);
|
|
633
634
|
};
|
|
634
635
|
}
|
|
@@ -636,7 +637,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
636
637
|
return;
|
|
637
638
|
}
|
|
638
639
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
|
|
639
|
-
var
|
|
640
|
+
var _d = data.payload, _e = _d === void 0 ? {} : _d, _f = _e.errors, _g = _f === void 0 ? [] : _f, _h = __read(_g, 1), _j = _h[0], _k = _j === void 0 ? {} : _j, _l = _k.errorType, errorType = _l === void 0 ? '' : _l, _m = _k.errorCode, errorCode = _m === void 0 ? 0 : _m;
|
|
640
641
|
rej({ errorType: errorType, errorCode: errorCode });
|
|
641
642
|
}
|
|
642
643
|
};
|
|
@@ -647,7 +648,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
647
648
|
var checkAckOk_1 = function (ackOk) {
|
|
648
649
|
if (!ackOk) {
|
|
649
650
|
_this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);
|
|
650
|
-
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after "
|
|
651
|
+
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after ".concat(CONNECTION_INIT_TIMEOUT, " ms")));
|
|
651
652
|
}
|
|
652
653
|
};
|
|
653
654
|
setTimeout(function () { return checkAckOk_1(ackOk_1); }, CONNECTION_INIT_TIMEOUT);
|
|
@@ -692,14 +693,12 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
692
693
|
none: this._customAuthHeader,
|
|
693
694
|
};
|
|
694
695
|
if (!(!authenticationType || !headerHandler[authenticationType])) return [3 /*break*/, 1];
|
|
695
|
-
logger.debug("Authentication type "
|
|
696
|
+
logger.debug("Authentication type ".concat(authenticationType, " not supported"));
|
|
696
697
|
return [2 /*return*/, undefined];
|
|
697
698
|
case 1:
|
|
698
699
|
handler = headerHandler[authenticationType];
|
|
699
|
-
host = appSyncGraphqlEndpoint
|
|
700
|
-
|
|
701
|
-
: undefined;
|
|
702
|
-
logger.debug("Authenticating with " + JSON.stringify(authenticationType));
|
|
700
|
+
host = url.parse(appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
|
|
701
|
+
logger.debug("Authenticating with ".concat(JSON.stringify(authenticationType)));
|
|
703
702
|
resolvedApiKey = void 0;
|
|
704
703
|
if (authenticationType === 'apiKey') {
|
|
705
704
|
resolvedApiKey = apiKey;
|
|
@@ -721,8 +720,8 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
721
720
|
});
|
|
722
721
|
};
|
|
723
722
|
AWSAppSyncRealTimeProvider.prototype._awsAuthTokenHeader = function (_a) {
|
|
724
|
-
var host = _a.host;
|
|
725
723
|
var _b, _c;
|
|
724
|
+
var host = _a.host;
|
|
726
725
|
return __awaiter(this, void 0, void 0, function () {
|
|
727
726
|
var session;
|
|
728
727
|
return __generator(this, function (_d) {
|
|
@@ -768,7 +767,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
|
|
|
768
767
|
case 1:
|
|
769
768
|
creds = (_b.sent()).credentials;
|
|
770
769
|
request = {
|
|
771
|
-
url: ""
|
|
770
|
+
url: "".concat(appSyncGraphqlEndpoint).concat(canonicalUri),
|
|
772
771
|
data: payload,
|
|
773
772
|
method: 'POST',
|
|
774
773
|
headers: __assign({}, AWS_APPSYNC_REALTIME_HEADERS),
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
type ListArgs = {
|
|
2
|
+
selectionSet?: string[];
|
|
3
|
+
filter?: {};
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param GraphQL response object
|
|
8
|
+
* @returns response object with `items` properties flattened
|
|
9
|
+
*/
|
|
10
|
+
export declare const flattenItems: (obj: Record<string, any>) => Record<string, any>;
|
|
11
|
+
export declare function initializeModel(client: any, modelName: string, result: any[], modelIntrospection: any): any[];
|
|
12
|
+
export declare const graphQLOperationsInfo: {
|
|
13
|
+
CREATE: {
|
|
14
|
+
operationPrefix: "create";
|
|
15
|
+
usePlural: boolean;
|
|
16
|
+
};
|
|
17
|
+
READ: {
|
|
18
|
+
operationPrefix: "get";
|
|
19
|
+
usePlural: boolean;
|
|
20
|
+
};
|
|
21
|
+
UPDATE: {
|
|
22
|
+
operationPrefix: "update";
|
|
23
|
+
usePlural: boolean;
|
|
24
|
+
};
|
|
25
|
+
DELETE: {
|
|
26
|
+
operationPrefix: "delete";
|
|
27
|
+
usePlural: boolean;
|
|
28
|
+
};
|
|
29
|
+
LIST: {
|
|
30
|
+
operationPrefix: "list";
|
|
31
|
+
usePlural: boolean;
|
|
32
|
+
};
|
|
33
|
+
ONCREATE: {
|
|
34
|
+
operationPrefix: "onCreate";
|
|
35
|
+
usePlural: boolean;
|
|
36
|
+
};
|
|
37
|
+
ONUPDATE: {
|
|
38
|
+
operationPrefix: "onUpdate";
|
|
39
|
+
usePlural: boolean;
|
|
40
|
+
};
|
|
41
|
+
ONDELETE: {
|
|
42
|
+
operationPrefix: "onDelete";
|
|
43
|
+
usePlural: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type ModelOperation = keyof typeof graphQLOperationsInfo;
|
|
47
|
+
/**
|
|
48
|
+
* Generates nested Custom Selection Set IR from path
|
|
49
|
+
*
|
|
50
|
+
* @param modelIntrospection
|
|
51
|
+
* @param modelName
|
|
52
|
+
* @param selectionSet - array of object paths
|
|
53
|
+
* @example
|
|
54
|
+
* ### Given
|
|
55
|
+
* `selectionSet = ['id', 'comments.post.id']`
|
|
56
|
+
* ### Returns
|
|
57
|
+
* ```ts
|
|
58
|
+
* {
|
|
59
|
+
* id: '',
|
|
60
|
+
* comments: {
|
|
61
|
+
* items: { post: { id: '' } }
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function customSelectionSetToIR(modelIntrospection: any, modelName: string, selectionSet: string[]): Record<string, string | object>;
|
|
67
|
+
/**
|
|
68
|
+
* Stringifies selection set IR
|
|
69
|
+
* * @example
|
|
70
|
+
* ### Given
|
|
71
|
+
* ```ts
|
|
72
|
+
* {
|
|
73
|
+
* id: '',
|
|
74
|
+
* comments: {
|
|
75
|
+
* items: { post: { id: '' } }
|
|
76
|
+
* }
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
* ### Returns
|
|
80
|
+
* `'id comments { items { post { id } } }'`
|
|
81
|
+
*/
|
|
82
|
+
export declare function selectionSetIRToString(obj: Record<string, string | any>): string;
|
|
83
|
+
export declare function generateSelectionSet(modelIntrospection: any, modelName: string, selectionSet?: string[]): string;
|
|
84
|
+
export declare function generateGraphQLDocument(modelIntrospection: any, modelName: string, modelOperation: ModelOperation, listArgs?: ListArgs): string;
|
|
85
|
+
export declare function buildGraphQLVariables(modelDefinition: any, operation: ModelOperation, arg: any, modelIntrospection: any): object;
|
|
86
|
+
/**
|
|
87
|
+
* Iterates over mutation input values and resolves any model inputs to their corresponding join fields/values
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ### Usage
|
|
91
|
+
* ```ts
|
|
92
|
+
* const result = normalizeMutationInput({ post: post }, model, modelDefinition);
|
|
93
|
+
* ```
|
|
94
|
+
* ### Result
|
|
95
|
+
* ```ts
|
|
96
|
+
* { postId: "abc123" }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
export declare function normalizeMutationInput(mutationInput: any, model: any, modelDefinition: any): Record<string, unknown>;
|
|
101
|
+
export {};
|