This commit is contained in:
Liyas Thomas
2021-02-05 06:07:55 +05:30
2 changed files with 17 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
<template> <template>
<div class="p-2 m-2"> <div :id="`type_${gqlType.name}`" class="p-2 m-2">
<div class="font-bold type-title" :class="{ 'type-highlighted': isHighlighted }"> <div class="font-bold type-title" :class="{ 'type-highlighted': isHighlighted }">
<span v-if="isInput" class="text-acColor font-normal">input </span>
{{ gqlType.name }} {{ gqlType.name }}
</div> </div>
<div class="mt-2 text-fgLightColor type-desc" v-if="gqlType.description"> <div class="mt-2 text-fgLightColor type-desc" v-if="gqlType.description">
@@ -26,6 +27,8 @@
</style> </style>
<script> <script>
import { GraphQLInputObjectType } from "graphql"
export default { export default {
props: { props: {
gqlType: {}, gqlType: {},
@@ -38,5 +41,10 @@ export default {
return !!this.highlightedFields.find(({ name }) => name === field.name) return !!this.highlightedFields.find(({ name }) => name === field.name)
}, },
}, },
computed: {
isInput() {
return this.gqlType instanceof GraphQLInputObjectType
},
},
} }
</script> </script>

View File

@@ -394,6 +394,7 @@
<style scoped lang="scss"> <style scoped lang="scss">
.gqlTabs { .gqlTabs {
max-height: calc(100vh - 192px); max-height: calc(100vh - 192px);
position: relative;
@apply overflow-auto; @apply overflow-auto;
} }
.gqlRunQuery { .gqlRunQuery {
@@ -589,16 +590,17 @@ export default {
doPrettifyQuery() { doPrettifyQuery() {
this.$refs.queryEditor.prettifyQuery() this.$refs.queryEditor.prettifyQuery()
}, },
handleJumpToType(type) { async handleJumpToType(type) {
this.$refs.gqlTabs.selectTab(this.$refs.typesTab) this.$refs.gqlTabs.selectTab(this.$refs.typesTab)
await this.$nextTick()
const rootTypeName = this.resolveRootType(type).name const rootTypeName = this.resolveRootType(type).name
const target = document.getElementById(`type_${rootTypeName}`) const target = document.getElementById(`type_${rootTypeName}`)
if (target && this.settings.SCROLL_INTO_ENABLED) { if (target && this.settings.SCROLL_INTO_ENABLED) {
target.scrollIntoView({ this.$refs.gqlTabs.$el
behavior: "smooth", .querySelector(".gqlTabs")
}) .scrollTo({ top: target.offsetTop, behavior: "smooth" })
} }
}, },
resolveRootType(type) { resolveRootType(type) {
@@ -742,7 +744,8 @@ export default {
if ( if (
!typeMap[type].name.startsWith("__") && !typeMap[type].name.startsWith("__") &&
![queryTypeName, mutationTypeName, subscriptionTypeName].includes(typeMap[type].name) && ![queryTypeName, mutationTypeName, subscriptionTypeName].includes(typeMap[type].name) &&
typeMap[type] instanceof gql.GraphQLObjectType (typeMap[type] instanceof gql.GraphQLObjectType ||
typeMap[type] instanceof gql.GraphQLInputObjectType)
) { ) {
types.push(typeMap[type]) types.push(typeMap[type])
} }