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: documentation is not being generated on GQL (#3730)

Anwarul Islamc0dbcc901fd5
diff --git a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
index 4019154a6..8d3def5f4 100644
--- a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
+++ b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue
@@ -187,7 +187,7 @@ import IconClock from "~icons/lucide/clock"
import IconCopy from "~icons/lucide/copy"
import IconBox from "~icons/lucide/box"
import { computed, nextTick, reactive, ref } from "vue"
-import { GraphQLField, GraphQLType } from "graphql"
+import { GraphQLField, GraphQLType, getNamedType } from "graphql"
import { refAutoReset } from "@vueuse/core"
import { useCodemirror } from "@composables/codemirror"
import { copyToClipboard } from "@helpers/utils/clipboard"
@@ -260,12 +260,6 @@ function getFilteredGraphqlTypes(filterText: string, types: GraphQLType[]) {
})
}
-function resolveRootType(type: GraphQLType) {
- let t: any = type
- while (t.ofType) t = t.ofType
- return t
-}
-
const toast = useToast()
const downloadSchemaIcon = refAutoReset<typeof IconDownload | typeof IconCheck>(
@@ -331,7 +325,7 @@ const handleJumpToType = async (type: GraphQLType) => {
selectedGqlTab.value = "types"
await nextTick()
- const rootTypeName = resolveRootType(type).name
+ const rootTypeName = getNamedType(type).name
const target = document.getElementById(`type_${rootTypeName}`)
if (target) {
target.scrollIntoView({ block: "center", behavior: "smooth" })
diff --git a/packages/hoppscotch-common/src/components/graphql/TypeLink.vue b/packages/hoppscotch-common/src/components/graphql/TypeLink.vue
index 6b4e1c885..8404dd045 100644
--- a/packages/hoppscotch-common/src/components/graphql/TypeLink.vue
+++ b/packages/hoppscotch-common/src/components/graphql/TypeLink.vue
@@ -8,7 +8,7 @@
</template>
<script setup lang="ts">
-import { GraphQLScalarType, GraphQLType } from "graphql"
+import { GraphQLScalarType, GraphQLType, getNamedType } from "graphql"
import { computed } from "vue"
const props = defineProps<{
@@ -21,15 +21,9 @@ const emit = defineEmits<{
const typeString = computed(() => `${props.gqlType}`)
const isScalar = computed(() => {
- return resolveRootType(props.gqlType) instanceof GraphQLScalarType
+ return getNamedType(props.gqlType) instanceof GraphQLScalarType
})
-function resolveRootType(type: GraphQLType) {
- let t = type as any
- while (t.ofType !== null) t = t.ofType
- return t
-}
-
function jumpToType() {
if (isScalar.value) return
emit("jump-to-type", props.gqlType)