@aws-amplify/api-graphql 4.0.25-unstable.3a01869.0 → 4.0.25
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/dist/cjs/internals/APIClient.js +0 -14
- package/dist/cjs/internals/APIClient.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +38 -36
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/utils/errors/index.js +1 -3
- package/dist/cjs/utils/errors/index.js.map +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js +6 -6
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
- package/dist/esm/internals/APIClient.mjs +0 -14
- package/dist/esm/internals/APIClient.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +40 -40
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +1 -2
- package/dist/esm/utils/errors/index.d.ts +0 -1
- package/dist/esm/utils/errors/index.mjs +0 -1
- package/dist/esm/utils/errors/index.mjs.map +1 -1
- package/dist/esm/utils/errors/repackageAuthError.d.ts +7 -3
- package/dist/esm/utils/errors/repackageAuthError.mjs +5 -5
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
- package/dist/esm/utils/resolveConfig.mjs +0 -1
- package/dist/esm/utils/resolveConfig.mjs.map +1 -1
- package/package.json +5 -5
- package/src/internals/APIClient.ts +0 -20
- package/src/internals/InternalGraphQLAPI.ts +56 -50
- package/src/types/index.ts +0 -2
- package/src/utils/errors/index.ts +0 -1
- package/src/utils/errors/repackageAuthError.ts +10 -8
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js +0 -15
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +0 -1
- package/dist/cjs/utils/errors/constants.js +0 -47
- package/dist/cjs/utils/errors/constants.js.map +0 -1
- package/dist/cjs/utils/errors/createGraphQLResultWithError.js +0 -15
- package/dist/cjs/utils/errors/createGraphQLResultWithError.js.map +0 -1
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.d.ts +0 -2
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs +0 -12
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs.map +0 -1
- package/dist/esm/utils/errors/constants.d.ts +0 -7
- package/dist/esm/utils/errors/constants.mjs +0 -46
- package/dist/esm/utils/errors/constants.mjs.map +0 -1
- package/dist/esm/utils/errors/createGraphQLResultWithError.d.ts +0 -2
- package/dist/esm/utils/errors/createGraphQLResultWithError.mjs +0 -13
- package/dist/esm/utils/errors/createGraphQLResultWithError.mjs.map +0 -1
- package/src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts +0 -15
- package/src/utils/errors/constants.ts +0 -56
- package/src/utils/errors/createGraphQLResultWithError.ts +0 -15
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { GraphQLApiError } from './GraphQLApiError';
|
|
2
2
|
export { assertValidationError } from './assertValidationError';
|
|
3
3
|
export { APIValidationErrorCode, validationErrorMap } from './validation';
|
|
4
|
-
export { createGraphQLResultWithError } from './createGraphQLResultWithError';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { GraphQLApiError } from './GraphQLApiError.mjs';
|
|
2
2
|
export { assertValidationError } from './assertValidationError.mjs';
|
|
3
3
|
export { APIValidationErrorCode, validationErrorMap } from './validation.mjs';
|
|
4
|
-
export { createGraphQLResultWithError } from './createGraphQLResultWithError.mjs';
|
|
5
4
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
interface ErrorObject {
|
|
3
|
+
errors: AmplifyErrorParams[];
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Checks to see if the given response or subscription message contains an
|
|
4
|
-
*
|
|
7
|
+
* unauth error. If it does, it changes the error message to include instructions
|
|
5
8
|
* for the app developer.
|
|
6
9
|
*/
|
|
7
|
-
export declare function
|
|
10
|
+
export declare function repackageUnauthError<T extends ErrorObject>(content: T): T;
|
|
11
|
+
export {};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
/**
|
|
4
4
|
* Checks to see if the given response or subscription message contains an
|
|
5
|
-
*
|
|
5
|
+
* unauth error. If it does, it changes the error message to include instructions
|
|
6
6
|
* for the app developer.
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function repackageUnauthError(content) {
|
|
9
9
|
if (content.errors && Array.isArray(content.errors)) {
|
|
10
10
|
content.errors.forEach(e => {
|
|
11
|
-
if (
|
|
11
|
+
if (isUnauthError(e)) {
|
|
12
12
|
e.message = 'Unauthorized';
|
|
13
13
|
e.recoverySuggestion =
|
|
14
14
|
`If you're calling an Amplify-generated API, make sure ` +
|
|
@@ -19,7 +19,7 @@ function repackageUnauthorizedError(content) {
|
|
|
19
19
|
}
|
|
20
20
|
return content;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function isUnauthError(error) {
|
|
23
23
|
// Error pattern corresponding to appsync calls
|
|
24
24
|
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
25
25
|
return true;
|
|
@@ -32,5 +32,5 @@ function isUnauthorizedError(error) {
|
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { repackageUnauthError };
|
|
36
36
|
//# sourceMappingURL=repackageAuthError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Checks to see if the given response or subscription message contains an\n *
|
|
1
|
+
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Checks to see if the given response or subscription message contains an\n * unauth error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nexport function repackageUnauthError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nfunction isUnauthError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.originalError?.name?.startsWith('UnauthorizedException')) {\n return true;\n }\n // Error pattern corresponding to appsync subscriptions\n if (error.message?.startsWith('Connection failed:') &&\n error.message?.includes('Permission denied')) {\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,OAAO,EAAE;AAC9C,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzD,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;AACpC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;AAClC,gBAAgB,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;AAC3C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC,CAAC;AAC/F,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B;AACA,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;AACA,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC;AACvD,QAAQ,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE;AACtD,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;;;"}
|
|
@@ -2,7 +2,6 @@ import { ConsoleLogger } from '@aws-amplify/core';
|
|
|
2
2
|
import '@aws-amplify/core/internals/utils';
|
|
3
3
|
import { assertValidationError } from './errors/assertValidationError.mjs';
|
|
4
4
|
import { APIValidationErrorCode } from './errors/validation.mjs';
|
|
5
|
-
import 'graphql';
|
|
6
5
|
|
|
7
6
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveConfig.mjs","sources":["../../../src/utils/resolveConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { APIValidationErrorCode, assertValidationError } from './errors';\nconst logger = new ConsoleLogger('GraphQLAPI resolveConfig');\n/**\n * @internal\n */\nexport const resolveConfig = (amplify) => {\n const config = amplify.getConfig();\n if (!config.API?.GraphQL) {\n logger.warn('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');\n }\n const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = config.API?.GraphQL ?? {};\n // TODO: re-enable when working in all test environments:\n // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);\n assertValidationError(!(!customEndpoint && customEndpointRegion), APIValidationErrorCode.NoCustomEndpoint);\n return {\n apiKey,\n customEndpoint,\n customEndpointRegion,\n defaultAuthMode,\n endpoint,\n region,\n };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveConfig.mjs","sources":["../../../src/utils/resolveConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { APIValidationErrorCode, assertValidationError } from './errors';\nconst logger = new ConsoleLogger('GraphQLAPI resolveConfig');\n/**\n * @internal\n */\nexport const resolveConfig = (amplify) => {\n const config = amplify.getConfig();\n if (!config.API?.GraphQL) {\n logger.warn('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');\n }\n const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = config.API?.GraphQL ?? {};\n // TODO: re-enable when working in all test environments:\n // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);\n assertValidationError(!(!customEndpoint && customEndpointRegion), APIValidationErrorCode.NoCustomEndpoint);\n return {\n apiKey,\n customEndpoint,\n customEndpointRegion,\n defaultAuthMode,\n endpoint,\n region,\n };\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,0BAA0B,CAAC,CAAC;AAC7D;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,OAAO,KAAK;AAC1C,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;AACvC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE;AAC9B,QAAQ,MAAM,CAAC,IAAI,CAAC,yHAAyH,CAAC,CAAC;AAC/I,KAAK;AACL,IAAI,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAC;AAC3H;AACA;AACA,IAAI,qBAAqB,CAAC,EAAE,CAAC,cAAc,IAAI,oBAAoB,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;AAC/G,IAAI,OAAO;AACX,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,oBAAoB;AAC5B,QAAQ,eAAe;AACvB,QAAQ,QAAQ;AAChB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/api-graphql",
|
|
3
|
-
"version": "4.0.25
|
|
3
|
+
"version": "4.0.25",
|
|
4
4
|
"description": "Api-graphql category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"server"
|
|
86
86
|
],
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@aws-amplify/api-rest": "4.0.25
|
|
89
|
-
"@aws-amplify/core": "6.0.25
|
|
90
|
-
"@aws-amplify/data-schema-types": "^0.7.
|
|
88
|
+
"@aws-amplify/api-rest": "4.0.25",
|
|
89
|
+
"@aws-amplify/core": "6.0.25",
|
|
90
|
+
"@aws-amplify/data-schema-types": "^0.7.11",
|
|
91
91
|
"@aws-sdk/types": "3.387.0",
|
|
92
92
|
"graphql": "15.8.0",
|
|
93
93
|
"rxjs": "^7.8.1",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"limit": "91.7 kB"
|
|
103
103
|
}
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "e6f59d689097a85d5847b00cde685dfaf8a86ed9"
|
|
106
106
|
}
|
|
@@ -732,16 +732,6 @@ export function generateGraphQLDocument(
|
|
|
732
732
|
graphQLArguments ??
|
|
733
733
|
(graphQLArguments = {
|
|
734
734
|
filter: `Model${name}FilterInput`,
|
|
735
|
-
...(sortKeyFieldNames.length > 0
|
|
736
|
-
? [primaryKeyFieldName, ...sortKeyFieldNames].reduce(
|
|
737
|
-
(acc: Record<string, any>, fieldName) => {
|
|
738
|
-
acc[fieldName] = `${fields[fieldName].type}`;
|
|
739
|
-
|
|
740
|
-
return acc;
|
|
741
|
-
},
|
|
742
|
-
{ sortDirection: 'ModelSortDirection' },
|
|
743
|
-
)
|
|
744
|
-
: []),
|
|
745
735
|
limit: 'Int',
|
|
746
736
|
nextToken: 'String',
|
|
747
737
|
});
|
|
@@ -755,7 +745,6 @@ export function generateGraphQLDocument(
|
|
|
755
745
|
(graphQLArguments = {
|
|
756
746
|
...indexQueryArgs!,
|
|
757
747
|
filter: `Model${name}FilterInput`,
|
|
758
|
-
sortDirection: 'ModelSortDirection',
|
|
759
748
|
limit: 'Int',
|
|
760
749
|
nextToken: 'String',
|
|
761
750
|
});
|
|
@@ -869,10 +858,6 @@ export function buildGraphQLVariables(
|
|
|
869
858
|
if (arg?.filter) {
|
|
870
859
|
variables.filter = arg.filter;
|
|
871
860
|
}
|
|
872
|
-
if (arg?.sortDirection) {
|
|
873
|
-
variables.sortDirection = arg.sortDirection;
|
|
874
|
-
variables[primaryKeyFieldName] = arg[primaryKeyFieldName];
|
|
875
|
-
}
|
|
876
861
|
if (arg?.nextToken) {
|
|
877
862
|
variables.nextToken = arg.nextToken;
|
|
878
863
|
}
|
|
@@ -892,11 +877,6 @@ export function buildGraphQLVariables(
|
|
|
892
877
|
if (arg?.filter) {
|
|
893
878
|
variables.filter = arg.filter;
|
|
894
879
|
}
|
|
895
|
-
|
|
896
|
-
if (arg?.sortDirection) {
|
|
897
|
-
variables.sortDirection = arg.sortDirection;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
880
|
if (arg?.nextToken) {
|
|
901
881
|
variables.nextToken = arg.nextToken;
|
|
902
882
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
4
|
DocumentNode,
|
|
5
|
+
GraphQLError,
|
|
5
6
|
OperationDefinitionNode,
|
|
6
7
|
OperationTypeNode,
|
|
7
8
|
parse,
|
|
@@ -24,20 +25,14 @@ import {
|
|
|
24
25
|
import { CustomHeaders, RequestOptions } from '@aws-amplify/data-schema-types';
|
|
25
26
|
|
|
26
27
|
import { AWSAppSyncRealTimeProvider } from '../Providers/AWSAppSyncRealTimeProvider';
|
|
27
|
-
import { GraphQLOperation, GraphQLOptions, GraphQLResult } from '../types';
|
|
28
|
-
import { resolveConfig, resolveLibraryOptions } from '../utils';
|
|
29
|
-
import { repackageUnauthorizedError } from '../utils/errors/repackageAuthError';
|
|
30
28
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from '../utils/errors/
|
|
38
|
-
import { GraphQLApiError, createGraphQLResultWithError } from '../utils/errors';
|
|
39
|
-
|
|
40
|
-
import { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors';
|
|
29
|
+
GraphQLAuthError,
|
|
30
|
+
GraphQLOperation,
|
|
31
|
+
GraphQLOptions,
|
|
32
|
+
GraphQLResult,
|
|
33
|
+
} from '../types';
|
|
34
|
+
import { resolveConfig, resolveLibraryOptions } from '../utils';
|
|
35
|
+
import { repackageUnauthError } from '../utils/errors/repackageAuthError';
|
|
41
36
|
|
|
42
37
|
const USER_AGENT_HEADER = 'x-amz-user-agent';
|
|
43
38
|
|
|
@@ -81,7 +76,7 @@ export class InternalGraphQLAPIClass {
|
|
|
81
76
|
switch (authMode) {
|
|
82
77
|
case 'apiKey':
|
|
83
78
|
if (!apiKey) {
|
|
84
|
-
throw new
|
|
79
|
+
throw new Error(GraphQLAuthError.NO_API_KEY);
|
|
85
80
|
}
|
|
86
81
|
headers = {
|
|
87
82
|
'X-Api-Key': apiKey,
|
|
@@ -90,44 +85,33 @@ export class InternalGraphQLAPIClass {
|
|
|
90
85
|
case 'iam': {
|
|
91
86
|
const session = await amplify.Auth.fetchAuthSession();
|
|
92
87
|
if (session.credentials === undefined) {
|
|
93
|
-
throw new
|
|
88
|
+
throw new Error(GraphQLAuthError.NO_CREDENTIALS);
|
|
94
89
|
}
|
|
95
90
|
break;
|
|
96
91
|
}
|
|
97
92
|
case 'oidc':
|
|
98
|
-
case 'userPool':
|
|
99
|
-
let token: string | undefined;
|
|
100
|
-
|
|
93
|
+
case 'userPool':
|
|
101
94
|
try {
|
|
102
|
-
token = (
|
|
95
|
+
const token = (
|
|
103
96
|
await amplify.Auth.fetchAuthSession()
|
|
104
97
|
).tokens?.accessToken.toString();
|
|
105
|
-
} catch (e) {
|
|
106
|
-
// fetchAuthSession failed
|
|
107
|
-
throw new GraphQLApiError({
|
|
108
|
-
...NO_SIGNED_IN_USER,
|
|
109
|
-
underlyingError: e,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
98
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
99
|
+
if (!token) {
|
|
100
|
+
throw new Error(GraphQLAuthError.NO_FEDERATED_JWT);
|
|
101
|
+
}
|
|
102
|
+
headers = {
|
|
103
|
+
Authorization: token,
|
|
104
|
+
};
|
|
105
|
+
} catch (e) {
|
|
106
|
+
throw new Error(GraphQLAuthError.NO_CURRENT_USER);
|
|
118
107
|
}
|
|
119
|
-
|
|
120
|
-
headers = {
|
|
121
|
-
Authorization: token,
|
|
122
|
-
};
|
|
123
108
|
break;
|
|
124
|
-
}
|
|
125
109
|
case 'lambda':
|
|
126
110
|
if (
|
|
127
111
|
typeof additionalHeaders === 'object' &&
|
|
128
112
|
!additionalHeaders.Authorization
|
|
129
113
|
) {
|
|
130
|
-
throw new
|
|
114
|
+
throw new Error(GraphQLAuthError.NO_AUTH_TOKEN);
|
|
131
115
|
}
|
|
132
116
|
|
|
133
117
|
headers = {
|
|
@@ -366,15 +350,18 @@ export class InternalGraphQLAPIClass {
|
|
|
366
350
|
const endpoint = customEndpoint || appSyncGraphqlEndpoint;
|
|
367
351
|
|
|
368
352
|
if (!endpoint) {
|
|
369
|
-
|
|
353
|
+
const error = new GraphQLError('No graphql endpoint provided.');
|
|
354
|
+
// TODO(Eslint): refactor this to throw an Error instead of a plain object
|
|
355
|
+
// eslint-disable-next-line no-throw-literal
|
|
356
|
+
throw {
|
|
357
|
+
data: {},
|
|
358
|
+
errors: [error],
|
|
359
|
+
};
|
|
370
360
|
}
|
|
371
361
|
|
|
372
362
|
let response: any;
|
|
373
363
|
|
|
374
364
|
try {
|
|
375
|
-
// See the inline doc of the REST `post()` API for possible errors to be thrown.
|
|
376
|
-
// As these errors are catastrophic they should be caught and handled by GraphQL
|
|
377
|
-
// API consumers.
|
|
378
365
|
const { body: responseBody } = await this._api.post(amplify, {
|
|
379
366
|
url: new AmplifyUrl(endpoint),
|
|
380
367
|
options: {
|
|
@@ -386,20 +373,39 @@ export class InternalGraphQLAPIClass {
|
|
|
386
373
|
abortController,
|
|
387
374
|
});
|
|
388
375
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
376
|
+
const result = await responseBody.json();
|
|
377
|
+
|
|
378
|
+
response = result;
|
|
379
|
+
} catch (err) {
|
|
380
|
+
// If the exception is because user intentionally
|
|
381
|
+
// cancelled the request, do not modify the exception
|
|
382
|
+
// so that clients can identify the exception correctly.
|
|
383
|
+
if (this.isCancelError(err)) {
|
|
384
|
+
throw err;
|
|
393
385
|
}
|
|
394
386
|
|
|
395
|
-
response =
|
|
387
|
+
response = {
|
|
388
|
+
data: {},
|
|
389
|
+
errors: [
|
|
390
|
+
new GraphQLError(
|
|
391
|
+
(err as any).message,
|
|
392
|
+
null,
|
|
393
|
+
null,
|
|
394
|
+
null,
|
|
395
|
+
null,
|
|
396
|
+
err as any,
|
|
397
|
+
),
|
|
398
|
+
],
|
|
399
|
+
};
|
|
396
400
|
}
|
|
397
401
|
|
|
398
|
-
|
|
399
|
-
|
|
402
|
+
const { errors } = response;
|
|
403
|
+
|
|
404
|
+
if (errors && errors.length) {
|
|
405
|
+
throw repackageUnauthError(response);
|
|
400
406
|
}
|
|
401
407
|
|
|
402
|
-
return response
|
|
408
|
+
return response;
|
|
403
409
|
}
|
|
404
410
|
|
|
405
411
|
/**
|
|
@@ -457,7 +463,7 @@ export class InternalGraphQLAPIClass {
|
|
|
457
463
|
.pipe(
|
|
458
464
|
catchError(e => {
|
|
459
465
|
if (e.errors) {
|
|
460
|
-
throw
|
|
466
|
+
throw repackageUnauthError(e);
|
|
461
467
|
}
|
|
462
468
|
throw e;
|
|
463
469
|
}),
|
package/src/types/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
CustomQueries,
|
|
8
8
|
CustomSubscriptions,
|
|
9
9
|
EnumTypes,
|
|
10
|
-
ModelSortDirection,
|
|
11
10
|
ModelTypes,
|
|
12
11
|
} from '@aws-amplify/data-schema-types';
|
|
13
12
|
import { DocumentNode, GraphQLError, Source } from 'graphql';
|
|
@@ -465,7 +464,6 @@ export type QueryArgs = Record<string, unknown>;
|
|
|
465
464
|
export interface ListArgs extends Record<string, unknown> {
|
|
466
465
|
selectionSet?: string[];
|
|
467
466
|
filter?: Record<string, unknown>;
|
|
468
|
-
sortDirection?: ModelSortDirection;
|
|
469
467
|
headers?: CustomHeaders;
|
|
470
468
|
}
|
|
471
469
|
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
export { GraphQLApiError } from './GraphQLApiError';
|
|
5
5
|
export { assertValidationError } from './assertValidationError';
|
|
6
6
|
export { APIValidationErrorCode, validationErrorMap } from './validation';
|
|
7
|
-
export { createGraphQLResultWithError } from './createGraphQLResultWithError';
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
|
|
6
|
+
interface ErrorObject {
|
|
7
|
+
errors: AmplifyErrorParams[];
|
|
8
|
+
}
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Checks to see if the given response or subscription message contains an
|
|
8
|
-
*
|
|
12
|
+
* unauth error. If it does, it changes the error message to include instructions
|
|
9
13
|
* for the app developer.
|
|
10
14
|
*/
|
|
11
|
-
export function
|
|
12
|
-
content: T,
|
|
13
|
-
): T {
|
|
15
|
+
export function repackageUnauthError<T extends ErrorObject>(content: T): T {
|
|
14
16
|
if (content.errors && Array.isArray(content.errors)) {
|
|
15
17
|
content.errors.forEach(e => {
|
|
16
|
-
if (
|
|
18
|
+
if (isUnauthError(e)) {
|
|
17
19
|
e.message = 'Unauthorized';
|
|
18
|
-
|
|
20
|
+
e.recoverySuggestion =
|
|
19
21
|
`If you're calling an Amplify-generated API, make sure ` +
|
|
20
22
|
`to set the "authMode" in generateClient({ authMode: '...' }) to the backend authorization ` +
|
|
21
23
|
`rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;
|
|
@@ -26,7 +28,7 @@ export function repackageUnauthorizedError<T extends GraphQLResult<any>>(
|
|
|
26
28
|
return content;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
function
|
|
31
|
+
function isUnauthError(error: any): boolean {
|
|
30
32
|
// Error pattern corresponding to appsync calls
|
|
31
33
|
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
32
34
|
return true;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isGraphQLResponseWithErrors = void 0;
|
|
7
|
-
function isGraphQLResponseWithErrors(response) {
|
|
8
|
-
if (!response) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
const r = response;
|
|
12
|
-
return Array.isArray(r.errors) && r.errors.length > 0;
|
|
13
|
-
}
|
|
14
|
-
exports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;
|
|
15
|
-
//# sourceMappingURL=isGraphQLResponseWithErrors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isGraphQLResponseWithErrors.js","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isGraphQLResponseWithErrors = void 0;\nfunction isGraphQLResponseWithErrors(response) {\n if (!response) {\n return false;\n }\n const r = response;\n return Array.isArray(r.errors) && r.errors.length > 0;\n}\nexports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,SAAS,2BAA2B,CAAC,QAAQ,EAAE;AAC/C,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC;AACvB,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1D,CAAC;AACD,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NO_ENDPOINT = exports.NO_AUTH_TOKEN_HEADER = exports.NO_SIGNED_IN_USER = exports.NO_VALID_AUTH_TOKEN = exports.NO_VALID_CREDENTIALS = exports.NO_API_KEY = void 0;
|
|
7
|
-
const types_1 = require("../../types");
|
|
8
|
-
exports.NO_API_KEY = {
|
|
9
|
-
name: 'NoApiKey',
|
|
10
|
-
// ideal: No API key configured.
|
|
11
|
-
message: types_1.GraphQLAuthError.NO_API_KEY,
|
|
12
|
-
recoverySuggestion: 'The API request was made with `authMode: "apiKey"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',
|
|
13
|
-
};
|
|
14
|
-
exports.NO_VALID_CREDENTIALS = {
|
|
15
|
-
name: 'NoCredentials',
|
|
16
|
-
// ideal: No auth credentials available.
|
|
17
|
-
message: types_1.GraphQLAuthError.NO_CREDENTIALS,
|
|
18
|
-
recoverySuggestion: `The API request was made with \`authMode: "iam"\` but no authentication credentials are available.
|
|
19
|
-
|
|
20
|
-
If you intended to make a request using an authenticated role, review if your user is signed in before making the request.
|
|
21
|
-
|
|
22
|
-
If you intend to make a request using an unauthenticated role or also known as "guest access", verify if "Auth.Cognito.allowGuestAccess" is set to "true" in the \`Amplify.configure()\` function.`,
|
|
23
|
-
};
|
|
24
|
-
exports.NO_VALID_AUTH_TOKEN = {
|
|
25
|
-
name: 'NoValidAuthTokens',
|
|
26
|
-
// ideal: No valid JWT auth token provided to make the API request..
|
|
27
|
-
message: types_1.GraphQLAuthError.NO_FEDERATED_JWT,
|
|
28
|
-
recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
29
|
-
};
|
|
30
|
-
exports.NO_SIGNED_IN_USER = {
|
|
31
|
-
name: 'NoSignedUser',
|
|
32
|
-
// ideal: Couldn't retrieve authentication credentials to make the API request.
|
|
33
|
-
message: types_1.GraphQLAuthError.NO_CURRENT_USER,
|
|
34
|
-
recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
35
|
-
};
|
|
36
|
-
exports.NO_AUTH_TOKEN_HEADER = {
|
|
37
|
-
name: 'NoAuthorizationHeader',
|
|
38
|
-
// ideal: Authorization header not specified.
|
|
39
|
-
message: types_1.GraphQLAuthError.NO_AUTH_TOKEN,
|
|
40
|
-
recoverySuggestion: 'The API request was made with `authMode: "lambda"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',
|
|
41
|
-
};
|
|
42
|
-
exports.NO_ENDPOINT = {
|
|
43
|
-
name: 'NoEndpoint',
|
|
44
|
-
message: 'No GraphQL endpoint configured in `Amplify.configure()`.',
|
|
45
|
-
recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/utils/errors/constants.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.NO_ENDPOINT = exports.NO_AUTH_TOKEN_HEADER = exports.NO_SIGNED_IN_USER = exports.NO_VALID_AUTH_TOKEN = exports.NO_VALID_CREDENTIALS = exports.NO_API_KEY = void 0;\nconst types_1 = require(\"../../types\");\nexports.NO_API_KEY = {\n name: 'NoApiKey',\n // ideal: No API key configured.\n message: types_1.GraphQLAuthError.NO_API_KEY,\n recoverySuggestion: 'The API request was made with `authMode: \"apiKey\"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',\n};\nexports.NO_VALID_CREDENTIALS = {\n name: 'NoCredentials',\n // ideal: No auth credentials available.\n message: types_1.GraphQLAuthError.NO_CREDENTIALS,\n recoverySuggestion: `The API request was made with \\`authMode: \"iam\"\\` but no authentication credentials are available.\n\nIf you intended to make a request using an authenticated role, review if your user is signed in before making the request.\n\nIf you intend to make a request using an unauthenticated role or also known as \"guest access\", verify if \"Auth.Cognito.allowGuestAccess\" is set to \"true\" in the \\`Amplify.configure()\\` function.`,\n};\nexports.NO_VALID_AUTH_TOKEN = {\n name: 'NoValidAuthTokens',\n // ideal: No valid JWT auth token provided to make the API request..\n message: types_1.GraphQLAuthError.NO_FEDERATED_JWT,\n recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexports.NO_SIGNED_IN_USER = {\n name: 'NoSignedUser',\n // ideal: Couldn't retrieve authentication credentials to make the API request.\n message: types_1.GraphQLAuthError.NO_CURRENT_USER,\n recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexports.NO_AUTH_TOKEN_HEADER = {\n name: 'NoAuthorizationHeader',\n // ideal: Authorization header not specified.\n message: types_1.GraphQLAuthError.NO_AUTH_TOKEN,\n recoverySuggestion: 'The API request was made with `authMode: \"lambda\"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',\n};\nexports.NO_ENDPOINT = {\n name: 'NoEndpoint',\n message: 'No GraphQL endpoint configured in `Amplify.configure()`.',\n recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC1K,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,OAAO,CAAC,UAAU,GAAG;AACrB,IAAI,IAAI,EAAE,UAAU;AACpB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU;AAChD,IAAI,kBAAkB,EAAE,oLAAoL;AAC5M,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,IAAI,EAAE,eAAe;AACzB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,cAAc;AACpD,IAAI,kBAAkB,EAAE,CAAC;AACzB;AACA;AACA;AACA,kMAAkM,CAAC;AACnM,CAAC,CAAC;AACF,OAAO,CAAC,mBAAmB,GAAG;AAC9B,IAAI,IAAI,EAAE,mBAAmB;AAC7B;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,gBAAgB;AACtD,IAAI,kBAAkB,EAAE,gGAAgG;AACxH,CAAC,CAAC;AACF,OAAO,CAAC,iBAAiB,GAAG;AAC5B,IAAI,IAAI,EAAE,cAAc;AACxB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe;AACrD,IAAI,kBAAkB,EAAE,wJAAwJ;AAChL,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,IAAI,EAAE,uBAAuB;AACjC;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,aAAa;AACnD,IAAI,kBAAkB,EAAE,wLAAwL;AAChN,CAAC,CAAC;AACF,OAAO,CAAC,WAAW,GAAG;AACtB,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,kFAAkF;AAC1G,CAAC;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createGraphQLResultWithError = void 0;
|
|
7
|
-
const graphql_1 = require("graphql");
|
|
8
|
-
const createGraphQLResultWithError = (error) => {
|
|
9
|
-
return {
|
|
10
|
-
data: {},
|
|
11
|
-
errors: [new graphql_1.GraphQLError(error.message, null, null, null, null, error)],
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.createGraphQLResultWithError = createGraphQLResultWithError;
|
|
15
|
-
//# sourceMappingURL=createGraphQLResultWithError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphQLResultWithError.js","sources":["../../../../src/utils/errors/createGraphQLResultWithError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createGraphQLResultWithError = void 0;\nconst graphql_1 = require(\"graphql\");\nconst createGraphQLResultWithError = (error) => {\n return {\n data: {},\n errors: [new graphql_1.GraphQLError(error.message, null, null, null, null, error)],\n };\n};\nexports.createGraphQLResultWithError = createGraphQLResultWithError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,4BAA4B,GAAG,KAAK,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,MAAM,4BAA4B,GAAG,CAAC,KAAK,KAAK;AAChD,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,EAAE;AAChB,QAAQ,MAAM,EAAE,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1F,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
function isGraphQLResponseWithErrors(response) {
|
|
4
|
-
if (!response) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
const r = response;
|
|
8
|
-
return Array.isArray(r.errors) && r.errors.length > 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { isGraphQLResponseWithErrors };
|
|
12
|
-
//# sourceMappingURL=isGraphQLResponseWithErrors.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isGraphQLResponseWithErrors.mjs","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isGraphQLResponseWithErrors(response) {\n if (!response) {\n return false;\n }\n const r = response;\n return Array.isArray(r.errors) && r.errors.length > 0;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,2BAA2B,CAAC,QAAQ,EAAE;AACtD,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC;AACvB,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1D;;;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
export declare const NO_API_KEY: AmplifyErrorParams;
|
|
3
|
-
export declare const NO_VALID_CREDENTIALS: AmplifyErrorParams;
|
|
4
|
-
export declare const NO_VALID_AUTH_TOKEN: AmplifyErrorParams;
|
|
5
|
-
export declare const NO_SIGNED_IN_USER: AmplifyErrorParams;
|
|
6
|
-
export declare const NO_AUTH_TOKEN_HEADER: AmplifyErrorParams;
|
|
7
|
-
export declare const NO_ENDPOINT: AmplifyErrorParams;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { GraphQLAuthError } from '../../types/index.mjs';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
const NO_API_KEY = {
|
|
6
|
-
name: 'NoApiKey',
|
|
7
|
-
// ideal: No API key configured.
|
|
8
|
-
message: GraphQLAuthError.NO_API_KEY,
|
|
9
|
-
recoverySuggestion: 'The API request was made with `authMode: "apiKey"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',
|
|
10
|
-
};
|
|
11
|
-
const NO_VALID_CREDENTIALS = {
|
|
12
|
-
name: 'NoCredentials',
|
|
13
|
-
// ideal: No auth credentials available.
|
|
14
|
-
message: GraphQLAuthError.NO_CREDENTIALS,
|
|
15
|
-
recoverySuggestion: `The API request was made with \`authMode: "iam"\` but no authentication credentials are available.
|
|
16
|
-
|
|
17
|
-
If you intended to make a request using an authenticated role, review if your user is signed in before making the request.
|
|
18
|
-
|
|
19
|
-
If you intend to make a request using an unauthenticated role or also known as "guest access", verify if "Auth.Cognito.allowGuestAccess" is set to "true" in the \`Amplify.configure()\` function.`,
|
|
20
|
-
};
|
|
21
|
-
const NO_VALID_AUTH_TOKEN = {
|
|
22
|
-
name: 'NoValidAuthTokens',
|
|
23
|
-
// ideal: No valid JWT auth token provided to make the API request..
|
|
24
|
-
message: GraphQLAuthError.NO_FEDERATED_JWT,
|
|
25
|
-
recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
26
|
-
};
|
|
27
|
-
const NO_SIGNED_IN_USER = {
|
|
28
|
-
name: 'NoSignedUser',
|
|
29
|
-
// ideal: Couldn't retrieve authentication credentials to make the API request.
|
|
30
|
-
message: GraphQLAuthError.NO_CURRENT_USER,
|
|
31
|
-
recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
32
|
-
};
|
|
33
|
-
const NO_AUTH_TOKEN_HEADER = {
|
|
34
|
-
name: 'NoAuthorizationHeader',
|
|
35
|
-
// ideal: Authorization header not specified.
|
|
36
|
-
message: GraphQLAuthError.NO_AUTH_TOKEN,
|
|
37
|
-
recoverySuggestion: 'The API request was made with `authMode: "lambda"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',
|
|
38
|
-
};
|
|
39
|
-
const NO_ENDPOINT = {
|
|
40
|
-
name: 'NoEndpoint',
|
|
41
|
-
message: 'No GraphQL endpoint configured in `Amplify.configure()`.',
|
|
42
|
-
recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { NO_API_KEY, NO_AUTH_TOKEN_HEADER, NO_ENDPOINT, NO_SIGNED_IN_USER, NO_VALID_AUTH_TOKEN, NO_VALID_CREDENTIALS };
|
|
46
|
-
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../../src/utils/errors/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLAuthError } from '../../types';\nexport const NO_API_KEY = {\n name: 'NoApiKey',\n // ideal: No API key configured.\n message: GraphQLAuthError.NO_API_KEY,\n recoverySuggestion: 'The API request was made with `authMode: \"apiKey\"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',\n};\nexport const NO_VALID_CREDENTIALS = {\n name: 'NoCredentials',\n // ideal: No auth credentials available.\n message: GraphQLAuthError.NO_CREDENTIALS,\n recoverySuggestion: `The API request was made with \\`authMode: \"iam\"\\` but no authentication credentials are available.\n\nIf you intended to make a request using an authenticated role, review if your user is signed in before making the request.\n\nIf you intend to make a request using an unauthenticated role or also known as \"guest access\", verify if \"Auth.Cognito.allowGuestAccess\" is set to \"true\" in the \\`Amplify.configure()\\` function.`,\n};\nexport const NO_VALID_AUTH_TOKEN = {\n name: 'NoValidAuthTokens',\n // ideal: No valid JWT auth token provided to make the API request..\n message: GraphQLAuthError.NO_FEDERATED_JWT,\n recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexport const NO_SIGNED_IN_USER = {\n name: 'NoSignedUser',\n // ideal: Couldn't retrieve authentication credentials to make the API request.\n message: GraphQLAuthError.NO_CURRENT_USER,\n recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexport const NO_AUTH_TOKEN_HEADER = {\n name: 'NoAuthorizationHeader',\n // ideal: Authorization header not specified.\n message: GraphQLAuthError.NO_AUTH_TOKEN,\n recoverySuggestion: 'The API request was made with `authMode: \"lambda\"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',\n};\nexport const NO_ENDPOINT = {\n name: 'NoEndpoint',\n message: 'No GraphQL endpoint configured in `Amplify.configure()`.',\n recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,UAAU,GAAG;AAC1B,IAAI,IAAI,EAAE,UAAU;AACpB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,UAAU;AACxC,IAAI,kBAAkB,EAAE,oLAAoL;AAC5M,EAAE;AACU,MAAC,oBAAoB,GAAG;AACpC,IAAI,IAAI,EAAE,eAAe;AACzB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,cAAc;AAC5C,IAAI,kBAAkB,EAAE,CAAC;AACzB;AACA;AACA;AACA,kMAAkM,CAAC;AACnM,EAAE;AACU,MAAC,mBAAmB,GAAG;AACnC,IAAI,IAAI,EAAE,mBAAmB;AAC7B;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,gBAAgB;AAC9C,IAAI,kBAAkB,EAAE,gGAAgG;AACxH,EAAE;AACU,MAAC,iBAAiB,GAAG;AACjC,IAAI,IAAI,EAAE,cAAc;AACxB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,eAAe;AAC7C,IAAI,kBAAkB,EAAE,wJAAwJ;AAChL,EAAE;AACU,MAAC,oBAAoB,GAAG;AACpC,IAAI,IAAI,EAAE,uBAAuB;AACjC;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,aAAa;AAC3C,IAAI,kBAAkB,EAAE,wLAAwL;AAChN,EAAE;AACU,MAAC,WAAW,GAAG;AAC3B,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,kFAAkF;AAC1G;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
const createGraphQLResultWithError = (error) => {
|
|
6
|
-
return {
|
|
7
|
-
data: {},
|
|
8
|
-
errors: [new GraphQLError(error.message, null, null, null, null, error)],
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { createGraphQLResultWithError };
|
|
13
|
-
//# sourceMappingURL=createGraphQLResultWithError.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createGraphQLResultWithError.mjs","sources":["../../../../src/utils/errors/createGraphQLResultWithError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLError } from 'graphql';\nexport const createGraphQLResultWithError = (error) => {\n return {\n data: {},\n errors: [new GraphQLError(error.message, null, null, null, null, error)],\n };\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,4BAA4B,GAAG,CAAC,KAAK,KAAK;AACvD,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,EAAE;AAChB,QAAQ,MAAM,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAChF,KAAK,CAAC;AACN;;;;"}
|