api-client/components/graphql/Field.vue

65 lines
1.8 KiB
Vue
Raw Normal View History

2019-11-18 19:34:00 +00:00
<template>
2020-09-22 17:06:37 +00:00
<div class="p-2 m-2 border-b border-dashed border-brdColor">
2020-10-04 09:46:16 +00:00
<div class="field-title" :class="{ 'field-highlighted': isHighlighted }">
{{ fieldName }}
<span v-if="fieldArgs.length > 0">
(
2020-01-10 00:00:38 +00:00
<span v-for="(field, index) in fieldArgs" :key="index">
{{ field.name }}:
<GraphqlTypeLink :gqlType="field.type" :jumpTypeCallback="jumpTypeCallback" />
2020-09-22 17:06:37 +00:00
<span v-if="index !== fieldArgs.length - 1"> , </span>
2020-01-10 00:00:38 +00:00
</span>
) </span
>:
<GraphqlTypeLink :gqlType="gqlField.type" :jumpTypeCallback="jumpTypeCallback" />
</div>
2020-09-22 17:06:37 +00:00
<div class="mt-2 text-fgLightColor field-desc" v-if="gqlField.description">
2019-11-18 19:34:00 +00:00
{{ gqlField.description }}
</div>
2020-09-22 17:06:37 +00:00
<div
class="inline-block px-4 py-2 my-2 text-sm font-bold text-black bg-yellow-200 rounded-lg field-deprecated"
v-if="gqlField.isDeprecated"
>
{{ $t("deprecated") }}
</div>
<div v-if="fieldArgs.length > 0">
<h5 class="my-2 text-xs">ARGUMENTS:</h5>
<div class="px-4 border-l-2 border-acColor">
<div v-for="(field, index) in fieldArgs" :key="index">
{{ field.name }}:
<GraphqlTypeLink :gqlType="field.type" :jumpTypeCallback="jumpTypeCallback" />
<div class="mt-2 text-fgLightColor field-desc" v-if="field.description">
{{ field.description }}
</div>
</div>
</div>
</div>
2019-11-18 19:34:00 +00:00
</div>
</template>
2020-10-04 09:46:16 +00:00
<style scoped lang="scss">
.field-highlighted {
2020-10-04 10:31:19 +00:00
@apply border-b-2;
@apply border-acColor;
2020-10-04 09:46:16 +00:00
}
</style>
2019-11-18 19:34:00 +00:00
<script>
export default {
props: {
gqlField: Object,
2020-02-24 18:44:50 +00:00
jumpTypeCallback: Function,
2020-10-04 09:46:16 +00:00
isHighlighted: { type: Boolean, default: false },
2019-11-18 19:34:00 +00:00
},
computed: {
fieldName() {
2020-02-24 18:44:50 +00:00
return this.gqlField.name
},
fieldArgs() {
2020-02-24 18:44:50 +00:00
return this.gqlField.args || []
},
},
}
2019-11-18 19:34:00 +00:00
</script>