2019-11-18 20:17:07 +00:00
|
|
|
<template>
|
2021-02-01 14:13:12 +00:00
|
|
|
<div :id="`type_${gqlType.name}`" class="p-2 m-2">
|
2021-05-19 04:54:57 +00:00
|
|
|
<div
|
|
|
|
|
class="font-bold type-title"
|
|
|
|
|
:class="{ 'type-highlighted': isHighlighted }"
|
|
|
|
|
>
|
2021-02-20 15:39:37 +00:00
|
|
|
<span v-if="isInput" class="font-normal text-acColor">input </span>
|
2021-05-19 04:54:57 +00:00
|
|
|
<span v-else-if="isInterface" class="font-normal text-acColor"
|
|
|
|
|
>interface
|
|
|
|
|
</span>
|
2021-02-20 15:39:37 +00:00
|
|
|
<span v-else-if="isEnum" class="font-normal text-acColor">enum </span>
|
2020-10-04 09:46:16 +00:00
|
|
|
{{ gqlType.name }}
|
|
|
|
|
</div>
|
2021-05-19 04:54:57 +00:00
|
|
|
<div v-if="gqlType.description" class="mt-2 text-fgLightColor type-desc">
|
2019-11-19 03:25:57 +00:00
|
|
|
{{ gqlType.description }}
|
2019-11-18 20:17:07 +00:00
|
|
|
</div>
|
2021-02-07 17:07:09 +00:00
|
|
|
<div v-if="interfaces.length > 0" class="mb-2">
|
|
|
|
|
<h5>{{ $t("interfaces") }}</h5>
|
2021-05-19 04:54:57 +00:00
|
|
|
<div
|
|
|
|
|
v-for="gqlInterface in interfaces"
|
|
|
|
|
:key="gqlInterface.name"
|
|
|
|
|
class="m-2 ml-4"
|
|
|
|
|
>
|
|
|
|
|
<GraphqlTypeLink
|
|
|
|
|
:gql-type="gqlInterface"
|
|
|
|
|
:jump-type-callback="jumpTypeCallback"
|
|
|
|
|
/>
|
2021-02-07 17:07:09 +00:00
|
|
|
</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">
|
2021-05-19 04:54:57 +00:00
|
|
|
<GraphqlTypeLink
|
|
|
|
|
:gql-type="child"
|
|
|
|
|
:jump-type-callback="jumpTypeCallback"
|
|
|
|
|
/>
|
2021-02-07 17:07:09 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-11-18 20:17:07 +00:00
|
|
|
<div v-if="gqlType.getFields">
|
2020-02-25 02:06:23 +00:00
|
|
|
<h5>{{ $t("fields") }}</h5>
|
2019-11-18 20:17:07 +00:00
|
|
|
<div v-for="field in gqlType.getFields()" :key="field.name">
|
2021-03-01 03:58:14 +00:00
|
|
|
<GraphqlField
|
2021-05-19 04:54:57 +00:00
|
|
|
:gql-field="field"
|
|
|
|
|
:is-highlighted="isFieldHighlighted({ field })"
|
|
|
|
|
:jump-type-callback="jumpTypeCallback"
|
2020-10-04 09:46:16 +00:00
|
|
|
/>
|
2019-11-18 20:17:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-02-07 17:07:09 +00:00
|
|
|
<div v-if="isEnum">
|
|
|
|
|
<h5>{{ $t("values") }}</h5>
|
2021-05-19 04:54:57 +00:00
|
|
|
<div
|
|
|
|
|
v-for="value in gqlType.getValues()"
|
|
|
|
|
:key="value.name"
|
|
|
|
|
class="m-4"
|
|
|
|
|
v-text="value.name"
|
|
|
|
|
></div>
|
2021-02-07 17:07:09 +00:00
|
|
|
</div>
|
2019-11-18 20:17:07 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-05-19 04:54:57 +00:00
|
|
|
import {
|
|
|
|
|
GraphQLEnumType,
|
|
|
|
|
GraphQLInputObjectType,
|
|
|
|
|
GraphQLInterfaceType,
|
|
|
|
|
} from "graphql"
|
2021-02-01 14:13:12 +00:00
|
|
|
|
2019-11-18 20:17:07 +00:00
|
|
|
export default {
|
|
|
|
|
props: {
|
2021-05-19 04:54:57 +00:00
|
|
|
// eslint-disable-next-line vue/require-default-prop, vue/require-prop-types
|
2020-01-09 18:32:38 +00:00
|
|
|
gqlType: {},
|
2021-05-19 04:54:57 +00:00
|
|
|
gqlTypes: { type: Array, default: () => [] },
|
|
|
|
|
jumpTypeCallback: { type: Function, default: () => {} },
|
2020-10-04 09:46:16 +00:00
|
|
|
isHighlighted: { type: Boolean, default: false },
|
2020-10-08 14:30:20 +00:00
|
|
|
highlightedFields: { type: Array, default: () => [] },
|
2020-10-04 09:46:16 +00:00
|
|
|
},
|
2021-02-01 14:13:12 +00:00
|
|
|
computed: {
|
|
|
|
|
isInput() {
|
|
|
|
|
return this.gqlType instanceof GraphQLInputObjectType
|
|
|
|
|
},
|
2021-02-07 17:07:09 +00:00
|
|
|
isInterface() {
|
|
|
|
|
return this.gqlType instanceof GraphQLInterfaceType
|
|
|
|
|
},
|
|
|
|
|
isEnum() {
|
|
|
|
|
return this.gqlType instanceof GraphQLEnumType
|
|
|
|
|
},
|
|
|
|
|
interfaces() {
|
2021-02-09 02:11:18 +00:00
|
|
|
return (this.gqlType.getInterfaces && this.gqlType.getInterfaces()) || []
|
2021-02-07 17:07:09 +00:00
|
|
|
},
|
|
|
|
|
children() {
|
|
|
|
|
return this.gqlTypes.filter(
|
2021-05-19 04:54:57 +00:00
|
|
|
(type) =>
|
|
|
|
|
type.getInterfaces && type.getInterfaces().includes(this.gqlType)
|
2021-02-07 17:07:09 +00:00
|
|
|
)
|
|
|
|
|
},
|
2021-02-01 14:13:12 +00:00
|
|
|
},
|
2021-05-19 04:54:57 +00:00
|
|
|
methods: {
|
|
|
|
|
isFieldHighlighted({ field }) {
|
|
|
|
|
return !!this.highlightedFields.find(({ name }) => name === field.name)
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-02-24 18:44:50 +00:00
|
|
|
}
|
2019-11-18 20:17:07 +00:00
|
|
|
</script>
|
2021-05-19 04:54:57 +00:00
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.type-highlighted {
|
|
|
|
|
@apply text-acColor;
|
|
|
|
|
}
|
|
|
|
|
</style>
|