From a085a07479e8c4093e2a97c7593aefd13a4a037a Mon Sep 17 00:00:00 2001 From: David McAfee Date: Wed, 13 Sep 2023 12:50:08 -0700 Subject: [PATCH] update parseAWSExports to map auth type; update subscription response type --- packages/api-graphql/src/types/index.ts | 4 +--- packages/core/src/parseAWSExports.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/api-graphql/src/types/index.ts b/packages/api-graphql/src/types/index.ts index b93ab87245c..29b71e009ed 100644 --- a/packages/api-graphql/src/types/index.ts +++ b/packages/api-graphql/src/types/index.ts @@ -82,9 +82,7 @@ export type GraphqlSubscriptionResult = Observable< * ``` */ export type GraphqlSubscriptionMessage = { - // provider: AWSAppSyncRealTimeProvider; - provider: {}; - value: { data?: T }; + data?: T; }; export interface AWSAppSyncRealTimeProviderOptions { diff --git a/packages/core/src/parseAWSExports.ts b/packages/core/src/parseAWSExports.ts index f7244596f35..87967c88624 100644 --- a/packages/core/src/parseAWSExports.ts +++ b/packages/core/src/parseAWSExports.ts @@ -3,6 +3,12 @@ import { OAuthConfig } from './singleton/Auth/types'; import { ResourcesConfig } from './singleton/types'; +const authTypeMapping: Record = { + API_KEY: 'apiKey', + AWS_IAM: 'iam', + COGNITO_USERPOOLS: 'jwt', +}; + /** * This utility converts the `aws-exports.js` file generated by the Amplify CLI into a {@link ResourcesConfig} object * consumable by Amplify. @@ -53,7 +59,8 @@ export const parseAWSExports = ( apiKey: aws_appsync_apiKey, // defaultAuthMode: aws_appsync_authenticationType, defaultAuthMode: { - type: aws_appsync_authenticationType, + // type: GRAPHQL_AUTH_MODE[aws_appsync_authenticationType], + type: authTypeMapping[aws_appsync_authenticationType], apiKey: aws_appsync_apiKey, }, endpoint: aws_appsync_graphqlEndpoint,