fix: documentation is not being generated on GQL (#3730)

Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
Anwarul Islam
2024-01-23 22:00:41 +05:30
committed by GitHub
parent ba52c8cc37
commit c0dbcc901f
2 changed files with 4 additions and 16 deletions

View File

@@ -187,7 +187,7 @@ import IconClock from "~icons/lucide/clock"
import IconCopy from "~icons/lucide/copy" import IconCopy from "~icons/lucide/copy"
import IconBox from "~icons/lucide/box" import IconBox from "~icons/lucide/box"
import { computed, nextTick, reactive, ref } from "vue" import { computed, nextTick, reactive, ref } from "vue"
import { GraphQLField, GraphQLType } from "graphql" import { GraphQLField, GraphQLType, getNamedType } from "graphql"
import { refAutoReset } from "@vueuse/core" import { refAutoReset } from "@vueuse/core"
import { useCodemirror } from "@composables/codemirror" import { useCodemirror } from "@composables/codemirror"
import { copyToClipboard } from "@helpers/utils/clipboard" 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 toast = useToast()
const downloadSchemaIcon = refAutoReset<typeof IconDownload | typeof IconCheck>( const downloadSchemaIcon = refAutoReset<typeof IconDownload | typeof IconCheck>(
@@ -331,7 +325,7 @@ const handleJumpToType = async (type: GraphQLType) => {
selectedGqlTab.value = "types" selectedGqlTab.value = "types"
await nextTick() await nextTick()
const rootTypeName = resolveRootType(type).name const rootTypeName = getNamedType(type).name
const target = document.getElementById(`type_${rootTypeName}`) const target = document.getElementById(`type_${rootTypeName}`)
if (target) { if (target) {
target.scrollIntoView({ block: "center", behavior: "smooth" }) target.scrollIntoView({ block: "center", behavior: "smooth" })

View File

@@ -8,7 +8,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { GraphQLScalarType, GraphQLType } from "graphql" import { GraphQLScalarType, GraphQLType, getNamedType } from "graphql"
import { computed } from "vue" import { computed } from "vue"
const props = defineProps<{ const props = defineProps<{
@@ -21,15 +21,9 @@ const emit = defineEmits<{
const typeString = computed(() => `${props.gqlType}`) const typeString = computed(() => `${props.gqlType}`)
const isScalar = computed(() => { 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() { function jumpToType() {
if (isScalar.value) return if (isScalar.value) return
emit("jump-to-type", props.gqlType) emit("jump-to-type", props.gqlType)