graphql: show enums and interfaces

make scalars not clickable
This commit is contained in:
Igor Stuzhuk (KoHcoJlb)
2021-02-07 19:07:09 +02:00
parent a32ce56295
commit c9e542d6d5
4 changed files with 64 additions and 9 deletions

View File

@@ -1,10 +1,16 @@
<template>
<span class="font-mono font-normal cursor-pointer text-acColor" @click="jumpToType">
<span
:class="{ 'cursor-pointer': !isScalar }"
class="font-mono font-normal text-acColor"
@click="jumpToType"
>
{{ typeString }}
</span>
</template>
<script>
import { GraphQLScalarType } from "graphql"
export default {
props: {
gqlType: null,
@@ -16,12 +22,21 @@ export default {
typeString() {
return this.gqlType.toString()
},
isScalar() {
return this.resolveRootType(this.gqlType) instanceof GraphQLScalarType
},
},
methods: {
jumpToType() {
if (this.isScalar) return
this.jumpTypeCallback(this.gqlType)
},
resolveRootType(type) {
let t = type
while (t.ofType != null) t = t.ofType
return t
},
},
}
</script>