@aws-amplify/api-graphql 3.4.12-api-v6-models.b3abc9b.0 → 4.0.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/README.md +3 -0
- package/lib/GraphQLAPI.d.ts +17 -4
- package/lib/GraphQLAPI.js +33 -27
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +690 -0
- package/lib/Providers/constants.d.ts +95 -0
- package/lib/Providers/constants.js +103 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +6 -10
- package/lib/internals/InternalGraphQLAPI.d.ts +11 -34
- package/lib/internals/InternalGraphQLAPI.js +219 -345
- package/lib/internals/index.d.ts +1 -1
- package/lib/internals/index.js +2 -1
- package/lib/internals/v6.d.ts +14 -2
- package/lib/internals/v6.js +21 -3
- package/lib/tsconfig.tsbuildinfo +6813 -0
- package/lib/types/PubSub.d.ts +27 -0
- package/lib/types/PubSub.js +46 -0
- package/lib/types/index.d.ts +119 -12
- package/lib/types/index.js +4 -3
- package/lib/utils/ConnectionStateMonitor.d.ts +41 -0
- package/lib/utils/ConnectionStateMonitor.js +131 -0
- package/lib/utils/ReachabilityMonitor/index.d.ts +1 -0
- package/lib/utils/ReachabilityMonitor/index.js +6 -0
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -0
- package/lib/utils/ReachabilityMonitor/index.native.js +8 -0
- package/lib/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib/utils/ReconnectionMonitor.js +68 -0
- package/lib/utils/errors/APIError.d.ts +7 -0
- package/lib/utils/errors/APIError.js +18 -0
- package/lib/utils/errors/assertValidationError.d.ts +5 -0
- package/lib/utils/errors/assertValidationError.js +16 -0
- package/lib/utils/errors/index.d.ts +3 -0
- package/lib/utils/errors/index.js +11 -0
- package/lib/utils/errors/validation.d.ts +7 -0
- package/lib/utils/errors/validation.js +25 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/resolveConfig.d.ts +12 -0
- package/lib/utils/resolveConfig.js +22 -0
- package/lib/utils/resolveLibraryOptions.d.ts +11 -0
- package/lib/utils/resolveLibraryOptions.js +12 -0
- package/lib-esm/GraphQLAPI.d.ts +17 -4
- package/lib-esm/GraphQLAPI.js +33 -28
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +687 -0
- package/lib-esm/Providers/constants.d.ts +95 -0
- package/lib-esm/Providers/constants.js +100 -0
- package/lib-esm/index.d.ts +1 -3
- package/lib-esm/index.js +1 -4
- package/lib-esm/internals/InternalGraphQLAPI.d.ts +11 -34
- package/lib-esm/internals/InternalGraphQLAPI.js +218 -345
- package/lib-esm/internals/index.d.ts +1 -1
- package/lib-esm/internals/index.js +1 -2
- package/lib-esm/internals/v6.d.ts +14 -2
- package/lib-esm/internals/v6.js +18 -2
- package/lib-esm/tsconfig.tsbuildinfo +6813 -0
- package/lib-esm/types/PubSub.d.ts +27 -0
- package/lib-esm/types/PubSub.js +44 -0
- package/lib-esm/types/index.d.ts +119 -12
- package/lib-esm/types/index.js +2 -3
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +41 -0
- package/lib-esm/utils/ConnectionStateMonitor.js +128 -0
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js +4 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +5 -0
- package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib-esm/utils/ReconnectionMonitor.js +65 -0
- package/lib-esm/utils/errors/APIError.d.ts +7 -0
- package/lib-esm/utils/errors/APIError.js +15 -0
- package/lib-esm/utils/errors/assertValidationError.d.ts +5 -0
- package/lib-esm/utils/errors/assertValidationError.js +13 -0
- package/lib-esm/utils/errors/index.d.ts +3 -0
- package/lib-esm/utils/errors/index.js +5 -0
- package/lib-esm/utils/errors/validation.d.ts +7 -0
- package/lib-esm/utils/errors/validation.js +23 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +4 -0
- package/lib-esm/utils/resolveConfig.d.ts +12 -0
- package/lib-esm/utils/resolveConfig.js +20 -0
- package/lib-esm/utils/resolveLibraryOptions.d.ts +11 -0
- package/lib-esm/utils/resolveLibraryOptions.js +10 -0
- package/package.json +122 -118
- package/src/GraphQLAPI.ts +26 -4
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +998 -0
- package/src/Providers/constants.ts +110 -0
- package/src/index.ts +2 -3
- package/src/internals/InternalGraphQLAPI.ts +181 -218
- package/src/internals/index.ts +1 -1
- package/src/internals/v6.ts +34 -2
- package/src/types/PubSub.ts +56 -0
- package/src/types/index.ts +175 -15
- package/src/utils/ConnectionStateMonitor.ts +199 -0
- package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
- package/src/utils/ReachabilityMonitor/index.ts +4 -0
- package/src/utils/ReconnectionMonitor.ts +76 -0
- package/src/utils/errors/APIError.ts +21 -0
- package/src/utils/errors/assertValidationError.ts +19 -0
- package/src/utils/errors/index.ts +6 -0
- package/src/utils/errors/validation.ts +26 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/resolveConfig.ts +35 -0
- package/src/utils/resolveLibraryOptions.ts +13 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/GraphQLAPI.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/internals/InternalGraphQLAPI.js.map +0 -1
- package/lib/internals/index.js.map +0 -1
- package/lib/internals/v6.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/GraphQLAPI.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
- package/lib-esm/internals/index.js.map +0 -1
- package/lib-esm/internals/v6.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolveConfig: (amplify: AmplifyClassV6) => {
|
|
6
|
+
apiKey: string | undefined;
|
|
7
|
+
customEndpoint: string | undefined;
|
|
8
|
+
customEndpointRegion: string | undefined;
|
|
9
|
+
defaultAuthMode: "apiKey" | "oidc" | "userPool" | "iam" | "lambda" | "none" | undefined;
|
|
10
|
+
endpoint: string | undefined;
|
|
11
|
+
region: string | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { APIValidationErrorCode, assertValidationError } from './errors';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export const resolveConfig = (amplify) => {
|
|
8
|
+
const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};
|
|
9
|
+
// TODO: re-enable when working in all test environments:
|
|
10
|
+
// assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
|
|
11
|
+
assertValidationError(!(!customEndpoint && customEndpointRegion), APIValidationErrorCode.NoCustomEndpoint);
|
|
12
|
+
return {
|
|
13
|
+
apiKey,
|
|
14
|
+
customEndpoint,
|
|
15
|
+
customEndpointRegion,
|
|
16
|
+
defaultAuthMode,
|
|
17
|
+
endpoint,
|
|
18
|
+
region,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
|
|
6
|
+
headers: ((options: {
|
|
7
|
+
query: string;
|
|
8
|
+
variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
|
|
9
|
+
}) => Promise<Record<string, string>>) | undefined;
|
|
10
|
+
withCredentials: boolean | undefined;
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export const resolveLibraryOptions = (amplify) => {
|
|
7
|
+
const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
|
|
8
|
+
const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
|
|
9
|
+
return { headers, withCredentials };
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,120 +1,124 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
2
|
+
"name": "@aws-amplify/api-graphql",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Api-graphql category of aws-amplify",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib-esm/index.js",
|
|
7
|
+
"typings": "./lib-esm/index.d.ts",
|
|
8
|
+
"react-native": {
|
|
9
|
+
"./lib/index": "./lib-esm/index.js"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"./lib/GraphQLAPI.js",
|
|
13
|
+
"./lib-esm/GraphQLAPI.js"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "npm run lint && jest -w 1 --coverage",
|
|
20
|
+
"test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
|
|
21
|
+
"build-with-test": "npm run clean && npm test && tsc && webpack",
|
|
22
|
+
"build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js",
|
|
23
|
+
"build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm",
|
|
24
|
+
"build:cjs:watch": "rimraf lib && tsc -m commonjs --outDir lib --watch",
|
|
25
|
+
"build:esm:watch": "rimraf lib-esm && tsc -m esnext --outDir lib-esm --watch",
|
|
26
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
27
|
+
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
28
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
29
|
+
"format": "echo \"Not implemented\"",
|
|
30
|
+
"lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
|
|
31
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 70.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "Amazon Web Services",
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
43
|
+
"files": [
|
|
44
|
+
"lib",
|
|
45
|
+
"lib-esm",
|
|
46
|
+
"src",
|
|
47
|
+
"internals"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@aws-amplify/api-rest": "4.0.0",
|
|
51
|
+
"@aws-amplify/auth": "6.0.0",
|
|
52
|
+
"@aws-amplify/core": "6.0.0",
|
|
53
|
+
"@aws-sdk/types": "3.387.0",
|
|
54
|
+
"graphql": "15.8.0",
|
|
55
|
+
"rxjs": "^7.8.1",
|
|
56
|
+
"tslib": "^2.5.0"
|
|
57
|
+
},
|
|
58
|
+
"size-limit": [
|
|
59
|
+
{
|
|
60
|
+
"name": "API (GraphQL client)",
|
|
61
|
+
"path": "./lib-esm/index.js",
|
|
62
|
+
"import": "{ Amplify, GraphQLAPI }",
|
|
63
|
+
"limit": "91.7 kB"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"jest": {
|
|
67
|
+
"globals": {
|
|
68
|
+
"ts-jest": {
|
|
69
|
+
"diagnostics": {
|
|
70
|
+
"pathRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$"
|
|
71
|
+
},
|
|
72
|
+
"tsConfig": {
|
|
73
|
+
"lib": [
|
|
74
|
+
"es5",
|
|
75
|
+
"es2015",
|
|
76
|
+
"dom",
|
|
77
|
+
"esnext.asynciterable",
|
|
78
|
+
"es2017.object"
|
|
79
|
+
],
|
|
80
|
+
"allowJs": true,
|
|
81
|
+
"noEmitOnError": false,
|
|
82
|
+
"strictNullChecks": true,
|
|
83
|
+
"types": [
|
|
84
|
+
"@types/jest"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"transform": {
|
|
90
|
+
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
|
|
91
|
+
},
|
|
92
|
+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
|
|
93
|
+
"testPathIgnorePatterns": [
|
|
94
|
+
"<rootDir>/__tests__/helpers.ts",
|
|
95
|
+
"<rootDir>/__tests__/fixtures/",
|
|
96
|
+
"<rootDir>/__tests__/utils/"
|
|
97
|
+
],
|
|
98
|
+
"moduleFileExtensions": [
|
|
99
|
+
"ts",
|
|
100
|
+
"tsx",
|
|
101
|
+
"js",
|
|
102
|
+
"json",
|
|
103
|
+
"jsx"
|
|
104
|
+
],
|
|
105
|
+
"testEnvironment": "jsdom",
|
|
106
|
+
"testURL": "http://localhost/",
|
|
107
|
+
"coverageThreshold": {
|
|
108
|
+
"global": {
|
|
109
|
+
"branches": 0,
|
|
110
|
+
"functions": 0,
|
|
111
|
+
"lines": 0,
|
|
112
|
+
"statements": 0
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"coveragePathIgnorePatterns": [
|
|
116
|
+
"<rootDir>/node_modules/",
|
|
117
|
+
"<rootDir>/dist",
|
|
118
|
+
"<rootDir>/lib",
|
|
119
|
+
"<rootDir>/lib-esm",
|
|
120
|
+
"<rootDir>/__tests__"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"gitHead": "d505105326d7f6214f6bd1e06eb20be3a3651377"
|
|
120
124
|
}
|
package/src/GraphQLAPI.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
3
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
4
|
+
import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
|
|
4
5
|
import { GraphQLOptions, GraphQLResult } from './types';
|
|
5
6
|
import { InternalGraphQLAPIClass } from './internals';
|
|
6
|
-
import Observable from '
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
7
8
|
|
|
8
9
|
export const graphqlOperation = (
|
|
9
10
|
query,
|
|
@@ -31,12 +32,33 @@ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
|
31
32
|
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
32
33
|
*/
|
|
33
34
|
graphql<T = any>(
|
|
35
|
+
amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>),
|
|
34
36
|
options: GraphQLOptions,
|
|
35
37
|
additionalHeaders?: { [key: string]: string }
|
|
36
38
|
): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>> {
|
|
37
|
-
return super.graphql(options, additionalHeaders
|
|
39
|
+
return super.graphql(amplify, options, additionalHeaders, {
|
|
40
|
+
category: Category.API,
|
|
41
|
+
action: ApiAction.GraphQl,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
47
|
+
* @param error - Any error
|
|
48
|
+
* @returns A boolean indicating if the error was from an api request cancellation
|
|
49
|
+
*/
|
|
50
|
+
isCancelError(error: any): boolean {
|
|
51
|
+
return super.isCancelError(error);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
56
|
+
* @param {any} request - request to cancel
|
|
57
|
+
* @returns A boolean indicating if the request was cancelled
|
|
58
|
+
*/
|
|
59
|
+
cancel(request: Promise<any>, message?: string): boolean {
|
|
60
|
+
return super.cancel(request, message);
|
|
38
61
|
}
|
|
39
62
|
}
|
|
40
63
|
|
|
41
64
|
export const GraphQLAPI = new GraphQLAPIClass(null);
|
|
42
|
-
Amplify.register(GraphQLAPI);
|