graphql: show enums and interfaces
make scalars not clickable
This commit is contained in:
@@ -2,11 +2,25 @@
|
|||||||
<div :id="`type_${gqlType.name}`" 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>
|
<span v-if="isInput" class="text-acColor font-normal">input </span>
|
||||||
|
<span v-else-if="isInterface" class="text-acColor font-normal">interface </span>
|
||||||
|
<span v-else-if="isEnum" class="text-acColor font-normal">enum </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">
|
||||||
{{ gqlType.description }}
|
{{ gqlType.description }}
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="interfaces.length > 0" class="mb-2">
|
||||||
|
<h5>{{ $t("interfaces") }}</h5>
|
||||||
|
<div v-for="gqlInterface in interfaces" :key="gqlInterface.name" class="m-2 ml-4">
|
||||||
|
<typelink :gqlType="gqlInterface" :jumpTypeCallback="jumpTypeCallback" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="children.length > 0" class="mb-2">
|
||||||
|
<h5>{{ $t("children") }}</h5>
|
||||||
|
<div v-for="child in children" :key="child.name" class="m-2 ml-4">
|
||||||
|
<typelink :gqlType="child" :jumpTypeCallback="jumpTypeCallback" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="gqlType.getFields">
|
<div v-if="gqlType.getFields">
|
||||||
<h5>{{ $t("fields") }}</h5>
|
<h5>{{ $t("fields") }}</h5>
|
||||||
<div v-for="field in gqlType.getFields()" :key="field.name">
|
<div v-for="field in gqlType.getFields()" :key="field.name">
|
||||||
@@ -17,6 +31,10 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="isEnum">
|
||||||
|
<h5>{{ $t("values") }}</h5>
|
||||||
|
<div v-for="value in gqlType.getValues()" class="m-4" v-text="value.name" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -27,11 +45,12 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { GraphQLInputObjectType } from "graphql"
|
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType } from "graphql"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
gqlType: {},
|
gqlType: {},
|
||||||
|
gqlTypes: Array,
|
||||||
jumpTypeCallback: Function,
|
jumpTypeCallback: Function,
|
||||||
isHighlighted: { type: Boolean, default: false },
|
isHighlighted: { type: Boolean, default: false },
|
||||||
highlightedFields: { type: Array, default: () => [] },
|
highlightedFields: { type: Array, default: () => [] },
|
||||||
@@ -45,6 +64,21 @@ export default {
|
|||||||
isInput() {
|
isInput() {
|
||||||
return this.gqlType instanceof GraphQLInputObjectType
|
return this.gqlType instanceof GraphQLInputObjectType
|
||||||
},
|
},
|
||||||
|
isInterface() {
|
||||||
|
return this.gqlType instanceof GraphQLInterfaceType
|
||||||
|
},
|
||||||
|
isEnum() {
|
||||||
|
return this.gqlType instanceof GraphQLEnumType
|
||||||
|
},
|
||||||
|
interfaces() {
|
||||||
|
let type = this.gqlType
|
||||||
|
return (type.getInterfaces && type.getInterfaces()) || []
|
||||||
|
},
|
||||||
|
children() {
|
||||||
|
return this.gqlTypes.filter(
|
||||||
|
(type) => type.getInterfaces && type.getInterfaces().includes(this.gqlType)
|
||||||
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
<template>
|
<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 }}
|
{{ typeString }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { GraphQLScalarType } from "graphql"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
gqlType: null,
|
gqlType: null,
|
||||||
@@ -16,12 +22,21 @@ export default {
|
|||||||
typeString() {
|
typeString() {
|
||||||
return this.gqlType.toString()
|
return this.gqlType.toString()
|
||||||
},
|
},
|
||||||
|
isScalar() {
|
||||||
|
return this.resolveRootType(this.gqlType) instanceof GraphQLScalarType
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
jumpToType() {
|
jumpToType() {
|
||||||
|
if (this.isScalar) return
|
||||||
this.jumpTypeCallback(this.gqlType)
|
this.jumpTypeCallback(this.gqlType)
|
||||||
},
|
},
|
||||||
|
resolveRootType(type) {
|
||||||
|
let t = type
|
||||||
|
while (t.ofType != null) t = t.ofType
|
||||||
|
return t
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -199,7 +199,10 @@
|
|||||||
"docs": "Docs",
|
"docs": "Docs",
|
||||||
"reset_default": "Reset to default",
|
"reset_default": "Reset to default",
|
||||||
"fields": "FIELDS",
|
"fields": "FIELDS",
|
||||||
|
"interfaces": "INTERFACES",
|
||||||
|
"children": "CHILDREN",
|
||||||
"deprecated": "DEPRECATED",
|
"deprecated": "DEPRECATED",
|
||||||
|
"values": "VALUES",
|
||||||
"add_one_header": "(add at least one header)",
|
"add_one_header": "(add at least one header)",
|
||||||
"add_one_parameter": "(add at least one parameter)",
|
"add_one_parameter": "(add at least one parameter)",
|
||||||
"header_count": "header {count}",
|
"header_count": "header {count}",
|
||||||
|
|||||||
@@ -364,6 +364,7 @@
|
|||||||
<div v-for="type in filteredGraphqlTypes" :key="type.name">
|
<div v-for="type in filteredGraphqlTypes" :key="type.name">
|
||||||
<type
|
<type
|
||||||
:gqlType="type"
|
:gqlType="type"
|
||||||
|
:gqlTypes="graphqlTypes"
|
||||||
:isHighlighted="isGqlTypeHighlighted({ gqlType: type })"
|
:isHighlighted="isGqlTypeHighlighted({ gqlType: type })"
|
||||||
:highlightedFields="getGqlTypeHighlightedFields({ gqlType: type })"
|
:highlightedFields="getGqlTypeHighlightedFields({ gqlType: type })"
|
||||||
:jumpTypeCallback="handleJumpToType"
|
:jumpTypeCallback="handleJumpToType"
|
||||||
@@ -740,14 +741,17 @@ export default {
|
|||||||
? schema.getSubscriptionType().name
|
? schema.getSubscriptionType().name
|
||||||
: ""
|
: ""
|
||||||
|
|
||||||
for (const type in typeMap) {
|
for (const typeName in typeMap) {
|
||||||
|
let type = typeMap[typeName]
|
||||||
if (
|
if (
|
||||||
!typeMap[type].name.startsWith("__") &&
|
!type.name.startsWith("__") &&
|
||||||
![queryTypeName, mutationTypeName, subscriptionTypeName].includes(typeMap[type].name) &&
|
![queryTypeName, mutationTypeName, subscriptionTypeName].includes(type.name) &&
|
||||||
(typeMap[type] instanceof gql.GraphQLObjectType ||
|
(type instanceof gql.GraphQLObjectType ||
|
||||||
typeMap[type] instanceof gql.GraphQLInputObjectType)
|
type instanceof gql.GraphQLInputObjectType ||
|
||||||
|
type instanceof gql.GraphQLEnumType ||
|
||||||
|
type instanceof gql.GraphQLInterfaceType)
|
||||||
) {
|
) {
|
||||||
types.push(typeMap[type])
|
types.push(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.graphqlTypes = types
|
this.graphqlTypes = types
|
||||||
@@ -828,7 +832,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$nuxt.$loading.finish()
|
this.$nuxt.$loading.finish()
|
||||||
|
|
||||||
},
|
},
|
||||||
async getSchema() {
|
async getSchema() {
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|||||||
Reference in New Issue
Block a user