Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: prevent GQL request failure caused by collection property computation (#5350)

Nivedined8b85bb67a4
diff --git a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue
index 111a2f2ad..219fe39a2 100644
--- a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue
+++ b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue
@@ -141,21 +141,16 @@ const runQuery = async (
const inheritedHeaders =
tabs.currentActiveTab.value.document.inheritedProperties?.headers.map(
- (header) => {
- if (header.inheritedHeader) {
- return header.inheritedHeader
- }
- return []
- }
- ) as HoppGQLRequest["headers"]
+ (header) => header.inheritedHeader
+ ) ?? []
await runGQLOperation({
name: request.value.name,
url: runURL,
request: request.value,
- inheritedHeaders: inheritedHeaders,
+ inheritedHeaders,
inheritedAuth: tabs.currentActiveTab.value.document.inheritedProperties
- ?.auth.inheritedAuth as HoppGQLAuth,
+ ?.auth.inheritedAuth as HoppGQLAuth | undefined,
query: runQuery,
variables: runVariables,
operationName: definition?.name?.value,
diff --git a/packages/hoppscotch-common/src/helpers/graphql/connection.ts b/packages/hoppscotch-common/src/helpers/graphql/connection.ts
index bab1b9b20..66b05120d 100644
--- a/packages/hoppscotch-common/src/helpers/graphql/connection.ts
+++ b/packages/hoppscotch-common/src/helpers/graphql/connection.ts
@@ -38,7 +38,7 @@ type ConnectionRequestOptions = {
url: string
request: HoppGQLRequest
inheritedHeaders: HoppGQLRequest["headers"]
- inheritedAuth: HoppGQLAuth
+ inheritedAuth?: HoppGQLAuth
}
type RunQueryOptions = {
@@ -46,7 +46,7 @@ type RunQueryOptions = {
url: string
request: HoppGQLRequest
inheritedHeaders: HoppGQLRequest["headers"]
- inheritedAuth: HoppGQLAuth
+ inheritedAuth?: HoppGQLAuth
query: string
variables: string
operationName: string | undefined
@@ -400,14 +400,23 @@ export const runGQLOperation = async (options: RunQueryOptions) => {
.filter((item) => item.active && item.key !== "")
.forEach(({ key, value }) => (finalHeaders[key] = value))
+ const finalHoppHeaders: HoppRESTHeaders = Object.entries(finalHeaders).map(
+ ([key, value]) => ({
+ active: true,
+ key,
+ value,
+ description: "",
+ })
+ )
+
const gqlRequest: HoppGQLRequest = {
v: 9,
name: options.name || "Untitled Request",
url: finalUrl,
- headers: runHeaders,
+ headers: finalHoppHeaders,
query,
variables,
- auth,
+ auth: auth ?? request.auth,
}
if (operationType === "subscription") {