From 903448186bf37722a46ce5012b9dd2128ff8b844 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Mon, 24 Feb 2025 17:58:45 +0600 Subject: [PATCH] fix: ensure GraphQL connection sends authentication headers (#4746) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com> --- .../src/components/graphql/Request.vue | 19 +- .../src/components/graphql/RequestOptions.vue | 47 +--- .../src/helpers/graphql/connection.ts | 257 ++++++++++++------ 3 files changed, 210 insertions(+), 113 deletions(-) diff --git a/packages/hoppscotch-common/src/components/graphql/Request.vue b/packages/hoppscotch-common/src/components/graphql/Request.vue index 6d674d4a..e9632b74 100644 --- a/packages/hoppscotch-common/src/components/graphql/Request.vue +++ b/packages/hoppscotch-common/src/components/graphql/Request.vue @@ -72,6 +72,7 @@ import { InterceptorService } from "~/services/interceptor.service" import { useService } from "dioc/vue" import { defineActionHandler } from "~/helpers/actions" import { GQLTabService } from "~/services/tab/graphql" +import { HoppGQLAuth, HoppGQLRequest } from "@hoppscotch/data" const t = useI18n() const tabs = useService(GQLTabService) @@ -98,7 +99,23 @@ const onConnectClick = () => { } const gqlConnect = () => { - connect(url.value, tabs.currentActiveTab.value?.document.request.headers) + const inheritedHeaders = + tabs.currentActiveTab.value.document.inheritedProperties?.headers.map( + (header) => { + if (header.inheritedHeader) { + return header.inheritedHeader + } + return [] + } + ) as HoppGQLRequest["headers"] + + connect({ + url: url.value, + request: tabs.currentActiveTab.value.document.request, + inheritedHeaders, + inheritedAuth: tabs.currentActiveTab.value.document.inheritedProperties + ?.auth.inheritedAuth as HoppGQLAuth, + }) platform.analytics?.logEvent({ type: "HOPP_REQUEST_RUN", diff --git a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue index cf5c5190..1f0ab9c4 100644 --- a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue +++ b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue @@ -57,26 +57,25 @@