@aws-amplify/api-graphql 4.0.1-console-preview.d745d43.0 → 4.0.1-ssr-api.df60e41.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.
Files changed (41) hide show
  1. package/lib/GraphQLAPI.d.ts +1 -1
  2. package/lib/GraphQLAPI.js +23 -30
  3. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +467 -582
  4. package/lib/index.js +1 -1
  5. package/lib/internals/InternalGraphQLAPI.d.ts +1 -1
  6. package/lib/internals/InternalGraphQLAPI.js +204 -246
  7. package/lib/internals/v6.js +3 -3
  8. package/lib/tsconfig.tsbuildinfo +180 -20
  9. package/lib/types/index.d.ts +17 -3
  10. package/lib/utils/ConnectionStateMonitor.js +51 -64
  11. package/lib/utils/ReachabilityMonitor/index.js +2 -2
  12. package/lib/utils/ReachabilityMonitor/index.native.js +4 -6
  13. package/lib/utils/ReconnectionMonitor.js +20 -24
  14. package/lib/utils/errors/APIError.js +7 -11
  15. package/lib/utils/errors/assertValidationError.js +4 -4
  16. package/lib/utils/errors/validation.js +5 -6
  17. package/lib/utils/resolveConfig.js +9 -10
  18. package/lib/utils/resolveLibraryOptions.js +4 -5
  19. package/lib-esm/GraphQLAPI.d.ts +1 -1
  20. package/lib-esm/GraphQLAPI.js +22 -30
  21. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +458 -574
  22. package/lib-esm/Providers/constants.js +10 -10
  23. package/lib-esm/internals/InternalGraphQLAPI.d.ts +1 -1
  24. package/lib-esm/internals/InternalGraphQLAPI.js +201 -244
  25. package/lib-esm/internals/v6.js +1 -1
  26. package/lib-esm/tsconfig.tsbuildinfo +180 -20
  27. package/lib-esm/types/index.d.ts +17 -3
  28. package/lib-esm/types/index.js +1 -1
  29. package/lib-esm/utils/ConnectionStateMonitor.js +49 -63
  30. package/lib-esm/utils/ReachabilityMonitor/index.js +1 -1
  31. package/lib-esm/utils/ReachabilityMonitor/index.native.js +1 -3
  32. package/lib-esm/utils/ReconnectionMonitor.js +19 -24
  33. package/lib-esm/utils/errors/APIError.js +6 -11
  34. package/lib-esm/utils/errors/assertValidationError.js +2 -2
  35. package/lib-esm/utils/errors/validation.js +5 -6
  36. package/lib-esm/utils/resolveConfig.js +8 -9
  37. package/lib-esm/utils/resolveLibraryOptions.js +4 -5
  38. package/package.json +6 -6
  39. package/src/GraphQLAPI.ts +3 -2
  40. package/src/internals/InternalGraphQLAPI.ts +35 -10
  41. package/src/types/index.ts +38 -8
@@ -19,7 +19,7 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
19
19
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
20
20
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
21
21
  */
22
- graphql<T = any>(amplify: AmplifyClassV6, options: GraphQLOptions, additionalHeaders?: {
22
+ graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: {
23
23
  [key: string]: string;
24
24
  }): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
25
25
  /**
package/lib/GraphQLAPI.js CHANGED
@@ -1,27 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
- var internals_1 = require("./internals");
6
- exports.graphqlOperation = function (query, variables, authToken) {
7
- if (variables === void 0) { variables = {}; }
8
- return ({
9
- query: query,
10
- variables: variables,
11
- authToken: authToken,
12
- });
13
- };
3
+ const utils_1 = require("@aws-amplify/core/internals/utils");
4
+ const internals_1 = require("./internals");
5
+ exports.graphqlOperation = (query, variables = {}, authToken) => ({
6
+ query,
7
+ variables,
8
+ authToken,
9
+ });
14
10
  /**
15
11
  * Export Cloud Logic APIs
16
12
  */
17
- var GraphQLAPIClass = /** @class */ (function (_super) {
18
- tslib_1.__extends(GraphQLAPIClass, _super);
19
- function GraphQLAPIClass() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- GraphQLAPIClass.prototype.getModuleName = function () {
13
+ class GraphQLAPIClass extends internals_1.InternalGraphQLAPIClass {
14
+ getModuleName() {
23
15
  return 'GraphQLAPI';
24
- };
16
+ }
25
17
  /**
26
18
  * Executes a GraphQL operation
27
19
  *
@@ -29,29 +21,30 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
29
21
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
30
22
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
31
23
  */
32
- GraphQLAPIClass.prototype.graphql = function (amplify, options, additionalHeaders) {
33
- return _super.prototype.graphql.call(this, amplify, options, additionalHeaders, {
24
+ graphql(amplify,
25
+ // amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>),
26
+ options, additionalHeaders) {
27
+ return super.graphql(amplify, options, additionalHeaders, {
34
28
  category: utils_1.Category.API,
35
- action: utils_1.ApiAction.GraphQl
29
+ action: utils_1.ApiAction.GraphQl,
36
30
  });
37
- };
31
+ }
38
32
  /**
39
33
  * Checks to see if an error thrown is from an api request cancellation
40
34
  * @param error - Any error
41
35
  * @returns A boolean indicating if the error was from an api request cancellation
42
36
  */
43
- GraphQLAPIClass.prototype.isCancelError = function (error) {
44
- return _super.prototype.isCancelError.call(this, error);
45
- };
37
+ isCancelError(error) {
38
+ return super.isCancelError(error);
39
+ }
46
40
  /**
47
41
  * Cancels an inflight request. Only applicable for graphql queries and mutations
48
42
  * @param {any} request - request to cancel
49
43
  * @returns A boolean indicating if the request was cancelled
50
44
  */
51
- GraphQLAPIClass.prototype.cancel = function (request, message) {
52
- return _super.prototype.cancel.call(this, request, message);
53
- };
54
- return GraphQLAPIClass;
55
- }(internals_1.InternalGraphQLAPIClass));
45
+ cancel(request, message) {
46
+ return super.cancel(request, message);
47
+ }
48
+ }
56
49
  exports.GraphQLAPIClass = GraphQLAPIClass;
57
50
  exports.GraphQLAPI = new GraphQLAPIClass(null);