Skip to content

Commit

Permalink
update parseAWSExports to map auth type; update subscription response…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
david-mcafee committed Sep 13, 2023
1 parent e25e2f9 commit a085a07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/api-graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ export type GraphqlSubscriptionResult<T> = Observable<
* ```
*/
export type GraphqlSubscriptionMessage<T> = {
// provider: AWSAppSyncRealTimeProvider;
provider: {};
value: { data?: T };
data?: T;
};

export interface AWSAppSyncRealTimeProviderOptions {
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/parseAWSExports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import { OAuthConfig } from './singleton/Auth/types';
import { ResourcesConfig } from './singleton/types';

const authTypeMapping: Record<any, any> = {
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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a085a07

Please sign in to comment.