Skip to content

Commit ed8b85b

Browse files
fix: prevent GQL request failure caused by collection property computation (hoppscotch#5350)
Co-authored-by: jamesgeorge007 <[email protected]>
1 parent eb8487f commit ed8b85b

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

packages/hoppscotch-common/src/components/graphql/RequestOptions.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,16 @@ const runQuery = async (
141141
142142
const inheritedHeaders =
143143
tabs.currentActiveTab.value.document.inheritedProperties?.headers.map(
144-
(header) => {
145-
if (header.inheritedHeader) {
146-
return header.inheritedHeader
147-
}
148-
return []
149-
}
150-
) as HoppGQLRequest["headers"]
144+
(header) => header.inheritedHeader
145+
) ?? []
151146
152147
await runGQLOperation({
153148
name: request.value.name,
154149
url: runURL,
155150
request: request.value,
156-
inheritedHeaders: inheritedHeaders,
151+
inheritedHeaders,
157152
inheritedAuth: tabs.currentActiveTab.value.document.inheritedProperties
158-
?.auth.inheritedAuth as HoppGQLAuth,
153+
?.auth.inheritedAuth as HoppGQLAuth | undefined,
159154
query: runQuery,
160155
variables: runVariables,
161156
operationName: definition?.name?.value,

packages/hoppscotch-common/src/helpers/graphql/connection.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ type ConnectionRequestOptions = {
3838
url: string
3939
request: HoppGQLRequest
4040
inheritedHeaders: HoppGQLRequest["headers"]
41-
inheritedAuth: HoppGQLAuth
41+
inheritedAuth?: HoppGQLAuth
4242
}
4343

4444
type RunQueryOptions = {
4545
name?: string
4646
url: string
4747
request: HoppGQLRequest
4848
inheritedHeaders: HoppGQLRequest["headers"]
49-
inheritedAuth: HoppGQLAuth
49+
inheritedAuth?: HoppGQLAuth
5050
query: string
5151
variables: string
5252
operationName: string | undefined
@@ -400,14 +400,23 @@ export const runGQLOperation = async (options: RunQueryOptions) => {
400400
.filter((item) => item.active && item.key !== "")
401401
.forEach(({ key, value }) => (finalHeaders[key] = value))
402402

403+
const finalHoppHeaders: HoppRESTHeaders = Object.entries(finalHeaders).map(
404+
([key, value]) => ({
405+
active: true,
406+
key,
407+
value,
408+
description: "",
409+
})
410+
)
411+
403412
const gqlRequest: HoppGQLRequest = {
404413
v: 9,
405414
name: options.name || "Untitled Request",
406415
url: finalUrl,
407-
headers: runHeaders,
416+
headers: finalHoppHeaders,
408417
query,
409418
variables,
410-
auth,
419+
auth: auth ?? request.auth,
411420
}
412421

413422
if (operationType === "subscription") {

0 commit comments

Comments
 (0)