@aws-amplify/api-graphql 4.0.21 → 4.0.22-unstable.1aafa48.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/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/internals/APIClient.js +34 -19
- package/dist/cjs/internals/APIClient.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +10 -9
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +1 -1
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/operations/custom.js +2 -2
- package/dist/cjs/internals/operations/custom.js.map +1 -1
- package/dist/cjs/internals/operations/list.js +1 -1
- package/dist/cjs/internals/operations/list.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
- package/dist/cjs/internals/v6.js +0 -2
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
- package/dist/esm/GraphQLAPI.d.ts +2 -2
- package/dist/esm/GraphQLAPI.mjs.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +40 -31
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/internals/APIClient.d.ts +5 -6
- package/dist/esm/internals/APIClient.mjs +34 -19
- package/dist/esm/internals/APIClient.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +10 -9
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.mjs +1 -1
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/generateCustomOperationsProperty.d.ts +2 -2
- package/dist/esm/internals/operations/custom.d.ts +1 -1
- package/dist/esm/internals/operations/custom.mjs +2 -2
- package/dist/esm/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/internals/operations/get.d.ts +1 -1
- package/dist/esm/internals/operations/get.mjs.map +1 -1
- package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
- package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/internals/operations/list.d.ts +1 -1
- package/dist/esm/internals/operations/list.mjs +1 -1
- package/dist/esm/internals/operations/list.mjs.map +1 -1
- package/dist/esm/internals/operations/subscription.d.ts +1 -1
- package/dist/esm/internals/operations/subscription.mjs.map +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/server/generateModelsProperty.d.ts +1 -2
- package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +2 -2
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +1 -1
- package/dist/esm/internals/v6.d.ts +1 -1
- package/dist/esm/internals/v6.mjs +0 -2
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +33 -35
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
- package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
- package/dist/esm/utils/errors/repackageAuthError.d.ts +2 -2
- package/dist/esm/utils/errors/repackageAuthError.mjs +1 -1
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +1 -1
- package/package.json +6 -5
- package/src/GraphQLAPI.ts +4 -3
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
- package/src/internals/APIClient.ts +59 -27
- package/src/internals/InternalGraphQLAPI.ts +26 -30
- package/src/internals/clientUtils.ts +1 -1
- package/src/internals/generateClient.ts +12 -10
- package/src/internals/generateCustomOperationsProperty.ts +7 -6
- package/src/internals/operations/custom.ts +16 -13
- package/src/internals/operations/get.ts +9 -8
- package/src/internals/operations/indexQuery.ts +12 -11
- package/src/internals/operations/list.ts +11 -15
- package/src/internals/operations/observeQuery.ts +3 -1
- package/src/internals/operations/subscription.ts +12 -10
- package/src/internals/server/generateClientWithAmplifyInstance.ts +7 -7
- package/src/internals/server/generateModelsProperty.ts +7 -4
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/clientProperties/generateEnumsProperty.ts +7 -6
- package/src/internals/utils/clientProperties/generateModelsProperty.ts +7 -6
- package/src/internals/v6.ts +6 -4
- package/src/server/generateClient.ts +4 -1
- package/src/types/PubSub.ts +1 -0
- package/src/types/index.ts +49 -47
- package/src/utils/ConnectionStateMonitor.ts +8 -3
- package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
- package/src/utils/ReachabilityMonitor/index.ts +1 -0
- package/src/utils/ReconnectionMonitor.ts +1 -0
- package/src/utils/errors/repackageAuthError.ts +6 -7
- package/src/utils/findIndexByFields.ts +1 -1
- package/src/utils/resolveConfig.ts +1 -0
- package/src/utils/resolveLibraryOptions.ts +1 -0
- package/src/utils/resolveOwnerFields.ts +7 -5
- package/src/utils/resolvePKFields.ts +1 -0
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
ModelIntrospectionSchema,
|
|
6
|
+
SchemaModel,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
authModeParams,
|
|
7
11
|
buildGraphQLVariables,
|
|
8
12
|
flattenItems,
|
|
9
|
-
|
|
13
|
+
generateGraphQLDocument,
|
|
10
14
|
getCustomHeaders,
|
|
15
|
+
initializeModel,
|
|
11
16
|
} from '../APIClient';
|
|
12
17
|
import {
|
|
13
18
|
AuthModeParams,
|
|
14
19
|
ClientWithModels,
|
|
20
|
+
GraphQLResult,
|
|
15
21
|
ListArgs,
|
|
16
22
|
V6Client,
|
|
17
23
|
V6ClientSSRRequest,
|
|
18
|
-
GraphQLResult,
|
|
19
24
|
} from '../../types';
|
|
20
|
-
import {
|
|
21
|
-
ModelIntrospectionSchema,
|
|
22
|
-
SchemaModel,
|
|
23
|
-
} from '@aws-amplify/core/internals/utils';
|
|
24
25
|
|
|
25
26
|
export function listFactory(
|
|
26
27
|
client: ClientWithModels,
|
|
@@ -51,12 +52,7 @@ async function _list(
|
|
|
51
52
|
) {
|
|
52
53
|
const { name } = model;
|
|
53
54
|
|
|
54
|
-
const query = generateGraphQLDocument(
|
|
55
|
-
modelIntrospection,
|
|
56
|
-
name,
|
|
57
|
-
'LIST',
|
|
58
|
-
args,
|
|
59
|
-
);
|
|
55
|
+
const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);
|
|
60
56
|
const variables = buildGraphQLVariables(
|
|
61
57
|
model,
|
|
62
58
|
'LIST',
|
|
@@ -69,7 +65,7 @@ async function _list(
|
|
|
69
65
|
|
|
70
66
|
const headers = getCustomHeaders(client, args?.headers);
|
|
71
67
|
|
|
72
|
-
const { data, extensions } =
|
|
68
|
+
const { data, extensions } = contextSpec
|
|
73
69
|
? ((await (client as V6ClientSSRRequest<Record<string, any>>).graphql(
|
|
74
70
|
contextSpec,
|
|
75
71
|
{
|
|
@@ -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
3
|
import { Observable } from 'rxjs';
|
|
4
|
-
import { findIndexByFields, resolvePKFields } from '../../utils';
|
|
5
4
|
import { SchemaModel } from '@aws-amplify/core/internals/utils';
|
|
6
5
|
|
|
6
|
+
import { findIndexByFields, resolvePKFields } from '../../utils';
|
|
7
|
+
|
|
7
8
|
export function observeQueryFactory(models: any, model: SchemaModel) {
|
|
8
9
|
const { name } = model;
|
|
9
10
|
|
|
@@ -124,6 +125,7 @@ export function observeQueryFactory(models: any, model: SchemaModel) {
|
|
|
124
125
|
// switch the queue to write directly to the items collection
|
|
125
126
|
receiveMessages = (...messages: typeof messageQueue) => {
|
|
126
127
|
ingestMessages(messages);
|
|
128
|
+
|
|
127
129
|
return items.length;
|
|
128
130
|
};
|
|
129
131
|
})();
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { map } from 'rxjs';
|
|
5
|
-
import { V6Client, GraphqlSubscriptionResult } from '../../types';
|
|
6
|
-
import {
|
|
7
|
-
initializeModel,
|
|
8
|
-
generateGraphQLDocument,
|
|
9
|
-
buildGraphQLVariables,
|
|
10
|
-
authModeParams,
|
|
11
|
-
ModelOperation,
|
|
12
|
-
getCustomHeaders,
|
|
13
|
-
} from '../APIClient';
|
|
14
5
|
import {
|
|
15
6
|
ModelIntrospectionSchema,
|
|
16
7
|
SchemaModel,
|
|
17
8
|
} from '@aws-amplify/core/internals/utils';
|
|
18
9
|
|
|
10
|
+
import { GraphqlSubscriptionResult, V6Client } from '../../types';
|
|
11
|
+
import {
|
|
12
|
+
ModelOperation,
|
|
13
|
+
authModeParams,
|
|
14
|
+
buildGraphQLVariables,
|
|
15
|
+
generateGraphQLDocument,
|
|
16
|
+
getCustomHeaders,
|
|
17
|
+
initializeModel,
|
|
18
|
+
} from '../APIClient';
|
|
19
|
+
|
|
19
20
|
export function subscriptionFactory(
|
|
20
21
|
client: any,
|
|
21
22
|
modelIntrospection: ModelIntrospectionSchema,
|
|
@@ -29,7 +30,7 @@ export function subscriptionFactory(
|
|
|
29
30
|
modelIntrospection,
|
|
30
31
|
name,
|
|
31
32
|
operation,
|
|
32
|
-
args
|
|
33
|
+
args,
|
|
33
34
|
);
|
|
34
35
|
|
|
35
36
|
const variables = buildGraphQLVariables(
|
|
@@ -64,6 +65,7 @@ export function subscriptionFactory(
|
|
|
64
65
|
auth.authMode,
|
|
65
66
|
auth.authToken,
|
|
66
67
|
);
|
|
68
|
+
|
|
67
69
|
return initialized;
|
|
68
70
|
}),
|
|
69
71
|
);
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { generateModelsProperty } from './generateModelsProperty';
|
|
6
|
-
import { Hub } from '@aws-amplify/core';
|
|
4
|
+
import { cancel, graphql, isCancelError } from '..';
|
|
7
5
|
import {
|
|
6
|
+
CommonPublicClientOptions,
|
|
7
|
+
ServerClientGenerationParams,
|
|
8
|
+
V6ClientSSRCookies,
|
|
9
|
+
V6ClientSSRRequest,
|
|
8
10
|
__amplify,
|
|
9
11
|
__authMode,
|
|
10
12
|
__authToken,
|
|
11
13
|
__headers,
|
|
12
|
-
V6ClientSSRRequest,
|
|
13
|
-
V6ClientSSRCookies,
|
|
14
|
-
ServerClientGenerationParams,
|
|
15
|
-
CommonPublicClientOptions,
|
|
16
14
|
} from '../../types';
|
|
17
15
|
import { isApiGraphQLConfig } from '../utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
|
|
18
16
|
import { generateEnumsProperty } from '../utils/clientProperties/generateEnumsProperty';
|
|
@@ -21,6 +19,8 @@ import {
|
|
|
21
19
|
generateCustomQueriesProperty,
|
|
22
20
|
} from '../generateCustomOperationsProperty';
|
|
23
21
|
|
|
22
|
+
import { generateModelsProperty } from './generateModelsProperty';
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* @private
|
|
26
26
|
*
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
4
|
-
import { graphQLOperationsInfo, ModelOperation } from '../APIClient';
|
|
5
|
-
import { ServerClientGenerationParams } from '../../types/';
|
|
6
|
-
import { V6ClientSSRRequest, V6ClientSSRCookies } from '../../types';
|
|
7
4
|
import { ModelIntrospectionSchema } from '@aws-amplify/core/internals/utils';
|
|
8
5
|
|
|
6
|
+
import { ModelOperation, graphQLOperationsInfo } from '../APIClient';
|
|
7
|
+
import {
|
|
8
|
+
ServerClientGenerationParams,
|
|
9
|
+
V6ClientSSRCookies,
|
|
10
|
+
V6ClientSSRRequest,
|
|
11
|
+
} from '../../types/';
|
|
9
12
|
import { listFactory } from '../operations/list';
|
|
10
13
|
import { indexQueryFactory } from '../operations/indexQuery';
|
|
11
14
|
import { getFactory } from '../operations/get';
|
|
@@ -20,7 +23,7 @@ export function generateModelsProperty<
|
|
|
20
23
|
>,
|
|
21
24
|
>(client: ClientType, params: ServerClientGenerationParams): ClientType {
|
|
22
25
|
const models = {} as any;
|
|
23
|
-
const config = params
|
|
26
|
+
const { config } = params;
|
|
24
27
|
const useContext = params.amplify === null;
|
|
25
28
|
|
|
26
29
|
if (!config) {
|
package/src/internals/types.ts
CHANGED
|
@@ -16,8 +16,8 @@ export type ClientGenerationParams = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Common options that can be used on public `generateClient()` interfaces.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export interface CommonPublicClientOptions {
|
|
20
20
|
authMode?: GraphQLAuthMode;
|
|
21
21
|
authToken?: string;
|
|
22
22
|
headers?: CustomHeaders;
|
|
23
|
-
}
|
|
23
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
ModelIntrospectionSchema,
|
|
6
5
|
GraphQLProviderConfig,
|
|
6
|
+
ModelIntrospectionSchema,
|
|
7
7
|
} from '@aws-amplify/core/internals/utils';
|
|
8
8
|
import { EnumTypes } from '@aws-amplify/data-schema-types';
|
|
9
9
|
|
|
@@ -17,11 +17,12 @@ export const generateEnumsProperty = <T extends Record<any, any> = never>(
|
|
|
17
17
|
return {} as EnumTypes<never>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const enums:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const enums: Record<
|
|
21
|
+
string,
|
|
22
|
+
{
|
|
23
|
+
values(): string[];
|
|
24
|
+
}
|
|
25
|
+
> = {};
|
|
25
26
|
|
|
26
27
|
for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {
|
|
27
28
|
enums[enumData.name] = {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
GraphQLProviderConfig,
|
|
6
|
+
ModelIntrospectionSchema,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
import { ModelOperation, graphQLOperationsInfo } from '../../APIClient';
|
|
10
|
+
import { V6Client } from '../../../types';
|
|
6
11
|
import { listFactory } from '../../operations/list';
|
|
7
12
|
import { indexQueryFactory } from '../../operations/indexQuery';
|
|
8
13
|
import { getFactory } from '../../operations/get';
|
|
9
14
|
import { subscriptionFactory } from '../../operations/subscription';
|
|
10
15
|
import { observeQueryFactory } from '../../operations/observeQuery';
|
|
11
|
-
import {
|
|
12
|
-
ModelIntrospectionSchema,
|
|
13
|
-
GraphQLProviderConfig,
|
|
14
|
-
} from '@aws-amplify/core/internals/utils';
|
|
15
16
|
import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';
|
|
16
17
|
|
|
17
18
|
export function generateModelsProperty<T extends Record<any, any> = never>(
|
package/src/internals/v6.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
4
|
+
|
|
3
5
|
import { GraphQLAPI } from '../GraphQLAPI';
|
|
4
6
|
import {
|
|
7
|
+
GraphQLOptionsV6,
|
|
8
|
+
GraphQLResponseV6,
|
|
9
|
+
V6Client,
|
|
5
10
|
__amplify,
|
|
6
11
|
__authMode,
|
|
7
12
|
__authToken,
|
|
8
|
-
V6Client,
|
|
9
|
-
GraphQLOptionsV6,
|
|
10
|
-
GraphQLResponseV6,
|
|
11
13
|
} from '../types';
|
|
12
|
-
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Invokes graphql operations against a graphql service, providing correct input and
|
|
@@ -117,6 +118,7 @@ export function graphql<
|
|
|
117
118
|
options,
|
|
118
119
|
additionalHeaders,
|
|
119
120
|
);
|
|
121
|
+
|
|
120
122
|
return result as any;
|
|
121
123
|
}
|
|
122
124
|
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
AmplifyServer,
|
|
6
6
|
getAmplifyServerContext,
|
|
7
7
|
} from '@aws-amplify/core/internals/adapter-core';
|
|
8
|
+
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
9
|
+
|
|
8
10
|
import { generateClientWithAmplifyInstance } from '../internals/server';
|
|
9
11
|
import {
|
|
10
12
|
GenerateServerClientParams,
|
|
@@ -14,7 +16,6 @@ import {
|
|
|
14
16
|
V6ClientSSRRequest,
|
|
15
17
|
__amplify,
|
|
16
18
|
} from '../types';
|
|
17
|
-
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Generates an GraphQL API client that works with Amplify server context.
|
|
@@ -55,6 +56,7 @@ export function generateClient<T extends Record<any, any> = never>({
|
|
|
55
56
|
additionalHeaders?: CustomHeaders,
|
|
56
57
|
) => {
|
|
57
58
|
const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;
|
|
59
|
+
|
|
58
60
|
return prevGraphql.call(
|
|
59
61
|
{ [__amplify]: amplifyInstance },
|
|
60
62
|
options,
|
|
@@ -63,5 +65,6 @@ export function generateClient<T extends Record<any, any> = never>({
|
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
client.graphql = wrappedGraphql as unknown as GraphQLMethodSSR;
|
|
68
|
+
|
|
66
69
|
return client;
|
|
67
70
|
}
|
package/src/types/PubSub.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
|
|
4
4
|
import {
|
|
5
|
-
EnumTypes,
|
|
6
|
-
ModelTypes,
|
|
7
5
|
CustomHeaders,
|
|
8
|
-
CustomQueries,
|
|
9
6
|
CustomMutations,
|
|
7
|
+
CustomQueries,
|
|
8
|
+
EnumTypes,
|
|
9
|
+
ModelTypes,
|
|
10
10
|
} from '@aws-amplify/data-schema-types';
|
|
11
|
-
import {
|
|
12
|
-
export { OperationTypeNode } from 'graphql';
|
|
11
|
+
import { DocumentNode, GraphQLError, Source } from 'graphql';
|
|
13
12
|
import { Observable } from 'rxjs';
|
|
14
|
-
|
|
15
13
|
import {
|
|
16
|
-
GraphQLAuthMode,
|
|
17
14
|
DocumentType,
|
|
15
|
+
GraphQLAuthMode,
|
|
18
16
|
} from '@aws-amplify/core/internals/utils';
|
|
19
17
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
20
18
|
|
|
19
|
+
export { OperationTypeNode } from 'graphql';
|
|
20
|
+
|
|
21
21
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
22
22
|
|
|
23
23
|
export { SelectionSet } from '@aws-amplify/data-schema-types';
|
|
@@ -41,9 +41,7 @@ export interface GraphQLOptions {
|
|
|
41
41
|
export interface GraphQLResult<T = object> {
|
|
42
42
|
data: T;
|
|
43
43
|
errors?: GraphQLError[];
|
|
44
|
-
extensions?:
|
|
45
|
-
[key: string]: any;
|
|
46
|
-
};
|
|
44
|
+
extensions?: Record<string, any>;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
// Opaque type used for determining the graphql query type
|
|
@@ -75,21 +73,22 @@ export type GraphQLSubscription<T> = T & {
|
|
|
75
73
|
*
|
|
76
74
|
* This util simply makes related model properties optional recursively.
|
|
77
75
|
*/
|
|
78
|
-
export type GraphQLReturnType<T> =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
export type GraphQLReturnType<T> =
|
|
77
|
+
T extends Record<string, unknown>
|
|
78
|
+
? {
|
|
79
|
+
[K in keyof T]?: GraphQLReturnType<T[K]>;
|
|
80
|
+
}
|
|
81
|
+
: T;
|
|
83
82
|
|
|
84
83
|
/**
|
|
85
84
|
* Describes a paged list result from AppSync, which can either
|
|
86
85
|
* live at the top query or property (e.g., related model) level.
|
|
87
86
|
*/
|
|
88
|
-
|
|
87
|
+
interface PagedList<T, TYPENAME> {
|
|
89
88
|
__typename: TYPENAME;
|
|
90
89
|
nextToken?: string | null | undefined;
|
|
91
|
-
items:
|
|
92
|
-
}
|
|
90
|
+
items: T[];
|
|
91
|
+
}
|
|
93
92
|
|
|
94
93
|
/**
|
|
95
94
|
* Recursively looks through a result type and removes nulls and
|
|
@@ -102,7 +101,7 @@ type PagedList<T, TYPENAME> = {
|
|
|
102
101
|
type WithListsFixed<T> =
|
|
103
102
|
T extends PagedList<infer IT, infer NAME>
|
|
104
103
|
? PagedList<Exclude<IT, null | undefined>, NAME>
|
|
105
|
-
: T extends
|
|
104
|
+
: T extends Record<string, unknown>
|
|
106
105
|
? {
|
|
107
106
|
[K in keyof T]: WithListsFixed<T[K]>;
|
|
108
107
|
}
|
|
@@ -169,9 +168,9 @@ export type GraphqlSubscriptionResult<T> = Observable<
|
|
|
169
168
|
* })
|
|
170
169
|
* ```
|
|
171
170
|
*/
|
|
172
|
-
export
|
|
171
|
+
export interface GraphqlSubscriptionMessage<T> {
|
|
173
172
|
data: T;
|
|
174
|
-
}
|
|
173
|
+
}
|
|
175
174
|
|
|
176
175
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
177
176
|
appSyncGraphqlEndpoint?: string;
|
|
@@ -180,15 +179,15 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
180
179
|
variables?: Record<string, unknown>;
|
|
181
180
|
apiKey?: string;
|
|
182
181
|
region?: string;
|
|
183
|
-
libraryConfigHeaders
|
|
182
|
+
libraryConfigHeaders?(): () => Promise<Record<string, unknown> | Headers>;
|
|
184
183
|
additionalHeaders?: CustomHeaders;
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
export
|
|
186
|
+
export interface AWSAppSyncRealTimeProvider {
|
|
188
187
|
subscribe(
|
|
189
188
|
options?: AWSAppSyncRealTimeProviderOptions,
|
|
190
189
|
): Observable<Record<string, unknown>>;
|
|
191
|
-
}
|
|
190
|
+
}
|
|
192
191
|
|
|
193
192
|
export enum GraphQLAuthError {
|
|
194
193
|
NO_API_KEY = 'No api-key configured',
|
|
@@ -259,18 +258,18 @@ export type GraphQLResponseV6<
|
|
|
259
258
|
FALLBACK_TYPE = unknown,
|
|
260
259
|
TYPED_GQL_STRING extends string = string,
|
|
261
260
|
> =
|
|
262
|
-
TYPED_GQL_STRING extends GeneratedQuery<infer
|
|
261
|
+
TYPED_GQL_STRING extends GeneratedQuery<infer _, infer QUERY_OUT>
|
|
263
262
|
? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>>
|
|
264
|
-
: TYPED_GQL_STRING extends GeneratedMutation<infer
|
|
263
|
+
: TYPED_GQL_STRING extends GeneratedMutation<infer _, infer MUTATION_OUT>
|
|
265
264
|
? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>>
|
|
266
|
-
: TYPED_GQL_STRING extends GeneratedSubscription<infer
|
|
265
|
+
: TYPED_GQL_STRING extends GeneratedSubscription<infer _, infer SUB_OUT>
|
|
267
266
|
? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>>
|
|
268
|
-
: FALLBACK_TYPE extends GraphQLQuery<infer
|
|
267
|
+
: FALLBACK_TYPE extends GraphQLQuery<infer _>
|
|
269
268
|
? Promise<GraphQLResult<FALLBACK_TYPE>>
|
|
270
|
-
: FALLBACK_TYPE extends GraphQLSubscription<infer
|
|
269
|
+
: FALLBACK_TYPE extends GraphQLSubscription<infer _>
|
|
271
270
|
? GraphqlSubscriptionResult<FALLBACK_TYPE>
|
|
272
271
|
: FALLBACK_TYPE extends GraphQLOperationType<
|
|
273
|
-
infer
|
|
272
|
+
infer _,
|
|
274
273
|
infer CUSTOM_OUT
|
|
275
274
|
>
|
|
276
275
|
? CUSTOM_OUT
|
|
@@ -294,10 +293,13 @@ export type GraphQLResponseV6<
|
|
|
294
293
|
* })
|
|
295
294
|
* ```
|
|
296
295
|
*/
|
|
297
|
-
export
|
|
296
|
+
export interface GraphQLOperationType<
|
|
297
|
+
IN extends Record<string, DocumentType>,
|
|
298
|
+
OUT extends Record<string, DocumentType>,
|
|
299
|
+
> {
|
|
298
300
|
variables: IN;
|
|
299
301
|
result: OUT;
|
|
300
|
-
}
|
|
302
|
+
}
|
|
301
303
|
|
|
302
304
|
/**
|
|
303
305
|
* Nominal type for branding generated graphql query operation strings with
|
|
@@ -386,8 +388,8 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
|
386
388
|
[__authToken]?: string;
|
|
387
389
|
[__headers]?: CustomHeaders;
|
|
388
390
|
graphql: GraphQLMethod;
|
|
389
|
-
cancel
|
|
390
|
-
isCancelError
|
|
391
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
392
|
+
isCancelError(error: any): boolean;
|
|
391
393
|
models: ModelTypes<T>;
|
|
392
394
|
enums: EnumTypes<T>;
|
|
393
395
|
queries: CustomQueries<T>;
|
|
@@ -401,8 +403,8 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> =
|
|
|
401
403
|
[__authToken]?: string;
|
|
402
404
|
[__headers]?: CustomHeaders;
|
|
403
405
|
graphql: GraphQLMethodSSR;
|
|
404
|
-
cancel
|
|
405
|
-
isCancelError
|
|
406
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
407
|
+
isCancelError(error: any): boolean;
|
|
406
408
|
models: ModelTypes<T, 'REQUEST'>;
|
|
407
409
|
enums: EnumTypes<T>;
|
|
408
410
|
queries: CustomQueries<T, 'REQUEST'>;
|
|
@@ -416,8 +418,8 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> =
|
|
|
416
418
|
[__authToken]?: string;
|
|
417
419
|
[__headers]?: CustomHeaders;
|
|
418
420
|
graphql: GraphQLMethod;
|
|
419
|
-
cancel
|
|
420
|
-
isCancelError
|
|
421
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
422
|
+
isCancelError(error: any): boolean;
|
|
421
423
|
models: ModelTypes<T, 'COOKIES'>;
|
|
422
424
|
enums: EnumTypes<T>;
|
|
423
425
|
queries: CustomQueries<T, 'COOKIES'>;
|
|
@@ -446,30 +448,30 @@ export type GraphQLMethodSSR = <
|
|
|
446
448
|
*
|
|
447
449
|
* The knobs available for configuring `server/generateClient` internally.
|
|
448
450
|
*/
|
|
449
|
-
export
|
|
451
|
+
export interface ServerClientGenerationParams {
|
|
450
452
|
amplify:
|
|
451
453
|
| null // null expected when used with `generateServerClient`
|
|
452
454
|
// closure expected with `generateServerClientUsingCookies`
|
|
453
455
|
| ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
|
|
454
456
|
// global env-sourced config use for retrieving modelIntro
|
|
455
457
|
config: ResourcesConfig;
|
|
456
|
-
}
|
|
458
|
+
}
|
|
457
459
|
|
|
458
460
|
export type QueryArgs = Record<string, unknown>;
|
|
459
461
|
|
|
460
|
-
export
|
|
462
|
+
export interface ListArgs extends Record<string, unknown> {
|
|
461
463
|
selectionSet?: string[];
|
|
462
|
-
filter?:
|
|
464
|
+
filter?: Record<string, unknown>;
|
|
463
465
|
headers?: CustomHeaders;
|
|
464
|
-
}
|
|
466
|
+
}
|
|
465
467
|
|
|
466
|
-
export
|
|
468
|
+
export interface AuthModeParams extends Record<string, unknown> {
|
|
467
469
|
authMode?: GraphQLAuthMode;
|
|
468
470
|
authToken?: string;
|
|
469
|
-
}
|
|
471
|
+
}
|
|
470
472
|
|
|
471
|
-
export
|
|
473
|
+
export interface GenerateServerClientParams {
|
|
472
474
|
config: ResourcesConfig;
|
|
473
475
|
authMode?: GraphQLAuthMode;
|
|
474
476
|
authToken?: string;
|
|
475
|
-
}
|
|
477
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { Observable, Observer, SubscriptionLike,
|
|
4
|
+
import { Observable, Observer, SubscriptionLike, filter, map } from 'rxjs';
|
|
5
|
+
|
|
5
6
|
import { ConnectionState } from '../types/PubSub';
|
|
7
|
+
|
|
6
8
|
import { ReachabilityMonitor } from './ReachabilityMonitor';
|
|
7
9
|
|
|
8
10
|
// Internal types for tracking different connection states
|
|
9
11
|
type LinkedConnectionState = 'connected' | 'disconnected';
|
|
10
12
|
type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
11
|
-
|
|
13
|
+
interface LinkedConnectionStates {
|
|
12
14
|
networkState: LinkedConnectionState;
|
|
13
15
|
connectionState: LinkedConnectionState | 'connecting';
|
|
14
16
|
intendedConnectionState: LinkedConnectionState;
|
|
15
17
|
keepAliveState: LinkedHealthState;
|
|
16
|
-
}
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
export const CONNECTION_CHANGE: {
|
|
19
21
|
[key in
|
|
@@ -53,6 +55,7 @@ export class ConnectionStateMonitor {
|
|
|
53
55
|
private _linkedConnectionStateObserver:
|
|
54
56
|
| Observer<LinkedConnectionStates>
|
|
55
57
|
| undefined;
|
|
58
|
+
|
|
56
59
|
private _networkMonitoringSubscription?: SubscriptionLike;
|
|
57
60
|
private _initialNetworkStateSubscription?: SubscriptionLike;
|
|
58
61
|
|
|
@@ -132,6 +135,7 @@ export class ConnectionStateMonitor {
|
|
|
132
135
|
filter(current => {
|
|
133
136
|
const toInclude = current !== previous;
|
|
134
137
|
previous = current;
|
|
138
|
+
|
|
135
139
|
return toInclude;
|
|
136
140
|
}),
|
|
137
141
|
);
|
|
@@ -196,6 +200,7 @@ export class ConnectionStateMonitor {
|
|
|
196
200
|
// All remaining states directly correspond to the connection state
|
|
197
201
|
if (connectionState === 'connecting') return ConnectionState.Connecting;
|
|
198
202
|
if (connectionState === 'disconnected') return ConnectionState.Disconnected;
|
|
203
|
+
|
|
199
204
|
return ConnectionState.Connected;
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { Reachability } from '@aws-amplify/core/internals/utils';
|
|
4
|
-
import
|
|
4
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
5
5
|
|
|
6
6
|
export const ReachabilityMonitor = () =>
|
|
7
7
|
new Reachability().networkMonitor(NetInfo);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
AmplifyErrorParams,
|
|
6
|
-
GraphQLAuthMode,
|
|
7
|
-
} from '@aws-amplify/core/internals/utils';
|
|
4
|
+
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
interface ErrorObject {
|
|
10
7
|
errors: AmplifyErrorParams[];
|
|
11
|
-
}
|
|
8
|
+
}
|
|
12
9
|
|
|
13
10
|
/**
|
|
14
11
|
* Checks to see if the given response or subscription message contains an
|
|
@@ -27,12 +24,13 @@ export function repackageUnauthError<T extends ErrorObject>(content: T): T {
|
|
|
27
24
|
}
|
|
28
25
|
});
|
|
29
26
|
}
|
|
27
|
+
|
|
30
28
|
return content;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
function isUnauthError(error: any): boolean {
|
|
34
32
|
// Error pattern corresponding to appsync calls
|
|
35
|
-
if (error?.
|
|
33
|
+
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
36
34
|
return true;
|
|
37
35
|
}
|
|
38
36
|
// Error pattern corresponding to appsync subscriptions
|
|
@@ -42,5 +40,6 @@ function isUnauthError(error: any): boolean {
|
|
|
42
40
|
) {
|
|
43
41
|
return true;
|
|
44
42
|
}
|
|
43
|
+
|
|
45
44
|
return false;
|
|
46
45
|
}
|