refactor: move from network strategies to generic interceptor service (#3242)

This commit is contained in:
Andrew Bastin
2023-08-21 07:50:35 +05:30
committed by GitHub
parent d4d1e27ba9
commit 10bb68a538
33 changed files with 1470 additions and 1314 deletions

View File

@@ -29,7 +29,6 @@
<script setup lang="ts">
import { platform } from "~/platform"
import { GQLConnection } from "~/helpers/GQLConnection"
import { getCurrentStrategyID } from "~/helpers/network"
import { useReadonlyStream, useStream } from "@composables/stream"
import { useI18n } from "@composables/i18n"
import {
@@ -38,9 +37,13 @@ import {
gqlURL$,
setGQLURL,
} from "~/newstore/GQLSession"
import { useService } from "dioc/vue"
import { InterceptorService } from "~/services/interceptor.service"
const t = useI18n()
const interceptorService = useService(InterceptorService)
const props = defineProps<{
conn: GQLConnection
}>()
@@ -62,7 +65,7 @@ const onConnectClick = () => {
platform.analytics?.logEvent({
type: "HOPP_REQUEST_RUN",
platform: "graphql-schema",
strategy: getCurrentStrategyID(),
strategy: interceptorService.currentInterceptorID.value!,
})
} else {
props.conn.disconnect()

View File

@@ -373,7 +373,6 @@ import { commonHeaders } from "~/helpers/headers"
import { GQLConnection } from "~/helpers/GQLConnection"
import { makeGQLHistoryEntry, addGraphqlHistoryEntry } from "~/newstore/history"
import { platform } from "~/platform"
import { getCurrentStrategyID } from "~/helpers/network"
import { useCodemirror } from "@composables/codemirror"
import jsonLinter from "~/helpers/editor/linting/json"
import { createGQLQueryLinter } from "~/helpers/editor/linting/gqlQuery"
@@ -381,6 +380,8 @@ import queryCompleter from "~/helpers/editor/completion/gqlQuery"
import { defineActionHandler } from "~/helpers/actions"
import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"
import { objRemoveKey } from "~/helpers/functional/object"
import { useService } from "dioc/vue"
import { InterceptorService } from "~/services/interceptor.service"
type OptionTabs = "query" | "headers" | "variables" | "authorization"
@@ -390,6 +391,8 @@ const selectedOptionTab = ref<OptionTabs>("query")
const t = useI18n()
const interceptorService = useService(InterceptorService)
const props = defineProps<{
conn: GQLConnection
}>()
@@ -744,7 +747,7 @@ const runQuery = async () => {
platform.analytics?.logEvent({
type: "HOPP_REQUEST_RUN",
platform: "graphql-query",
strategy: getCurrentStrategyID(),
strategy: interceptorService.currentInterceptorID.value!,
})
}