Skip to content

Commit

Permalink
test(core): better auth logic in test subscriber (#3724)
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts authored Dec 18, 2023
1 parent 964a02a commit 2562c62
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bats/helpers/subscriber/src/gql-subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ const url = process.argv[3]
const filePath = process.argv[4]
const authToken = process.argv[5]
const variablesString = process.argv[6] || "{}"
let authParam = undefined
if (authToken) {
if (authToken.startsWith("dev_")) {
authParam = { "X-API-KEY": authToken }
} else {
authParam = { Authorization: `Bearer ${authToken}` }
}
}
const client = createClient({
url,
connectionParams: authToken ? authToken.startsWith("dev_") ? {
"X-API-KEY": authToken,
} : { Authorization: `Bearer ${authToken}` } : undefined,
webSocketImpl: WebSocket,
connectionParams: authParam
})

const startSubscription = async () => {
Expand Down

0 comments on commit 2562c62

Please sign in to comment.