Skip to content

Commit

Permalink
fix type for AWSAppSyncRealTimeProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
david-mcafee committed Nov 15, 2023
1 parent 08a5d44 commit 2556bd9
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ export interface AWSAppSyncRealTimeProviderOptions {
apiKey?: string;
region?: string;
graphql_headers?: () => {} | (() => Promise<{}>);
// additionalHeaders?:
// | Record<string, string>
// | (() => Promise<Record<string, string>>);
additionalHeaders?:
| Record<string, string>
| (() => Promise<Record<string, string>>);
Expand All @@ -111,6 +108,7 @@ type AWSAppSyncRealTimeAuthInput =
canonicalUri: string;
payload: string;
host?: string | undefined;
additionalHeaders?: Record<string, string>;
};

export class AWSAppSyncRealTimeProvider {
Expand Down Expand Up @@ -1002,19 +1000,14 @@ export class AWSAppSyncRealTimeProvider {
host,
additionalHeaders,
}: AWSAppSyncRealTimeAuthInput) {
if (
typeof additionalHeaders === 'object' &&
!additionalHeaders?.['Authorization']
) {
if (!additionalHeaders?.['Authorization']) {
throw new Error('No auth token specified');
}

// This check also isn't necessary, the function will already have been called.
// Type needs to be updated:
return {
Authorization:
typeof additionalHeaders === 'object' &&
additionalHeaders.Authorization,
Authorization: additionalHeaders.Authorization,
host,
};
}
Expand Down

0 comments on commit 2556bd9

Please sign in to comment.