Skip to content

Commit

Permalink
move creation of header object into try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
MUlfers committed Feb 14, 2022
1 parent 92b50c4 commit 7d15cbd
Showing 1 changed file with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,37 +259,39 @@ export class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
// Preparing payload for subscription message

const dataString = JSON.stringify(data);
const headerObj = {
...(await this._awsRealTimeHeaderBasedAuth({
apiKey,
appSyncGraphqlEndpoint,
authenticationType,
payload: dataString,
canonicalUri: "",
region,
credentials,
token,
graphql_headers
})),
[USER_AGENT_HEADER]: USER_AGENT
};
let stringToAWSRealTime: string;

const subscriptionMessage = {
id: subscriptionId,
payload: {
data: dataString,
extensions: {
authorization: {
...headerObj
try {
const headerObj = {
...(await this._awsRealTimeHeaderBasedAuth({
apiKey,
appSyncGraphqlEndpoint,
authenticationType,
payload: dataString,
canonicalUri: "",
region,
credentials,
token,
graphql_headers
})),
[USER_AGENT_HEADER]: USER_AGENT
};

const subscriptionMessage = {
id: subscriptionId,
payload: {
data: dataString,
extensions: {
authorization: {
...headerObj
}
}
}
},
type: MESSAGE_TYPES.GQL_START
};
},
type: MESSAGE_TYPES.GQL_START
};

const stringToAWSRealTime = JSON.stringify(subscriptionMessage);
stringToAWSRealTime = JSON.stringify(subscriptionMessage);

try {
await this._initializeWebSocketConnection({
apiKey,
appSyncGraphqlEndpoint,
Expand Down

0 comments on commit 7d15cbd

Please sign in to comment.