api-client/components/graphql/Field.vue

91 lines
2.1 KiB
Vue
Raw Normal View History

2019-11-18 19:34:00 +00:00
<template>
2021-06-12 16:46:17 +00:00
<div class="p-2 m-2 border-b border-dashed border-divider">
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 }}:
2021-05-19 04:54:57 +00:00
<GraphqlTypeLink
:gql-type="field.type"
:jump-type-callback="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
>:
2021-05-19 04:54:57 +00:00
<GraphqlTypeLink
:gql-type="gqlField.type"
:jump-type-callback="jumpTypeCallback"
/>
</div>
2021-06-12 16:46:17 +00:00
<div
v-if="gqlField.description"
2021-06-21 11:01:40 +00:00
class="py-2 text-sm text-secondaryLight field-desc"
2021-06-12 16:46:17 +00:00
>
2019-11-18 19:34:00 +00:00
{{ gqlField.description }}
</div>
2020-09-22 17:06:37 +00:00
<div
2021-05-19 04:54:57 +00:00
v-if="gqlField.isDeprecated"
2021-05-15 12:43:31 +00:00
class="
inline-block
px-4
py-2
my-2
text-sm
font-bold
text-black
bg-yellow-200
rounded-lg
field-deprecated
"
2020-09-22 17:06:37 +00:00
>
{{ $t("deprecated") }}
</div>
<div v-if="fieldArgs.length > 0">
<h5 class="my-2 text-xs">ARGUMENTS:</h5>
2021-06-12 16:46:17 +00:00
<div class="px-4 border-l-2 border-accent">
<div v-for="(field, index) in fieldArgs" :key="index">
{{ field.name }}:
2021-05-19 04:54:57 +00:00
<GraphqlTypeLink
:gql-type="field.type"
:jump-type-callback="jumpTypeCallback"
/>
<div
v-if="field.description"
2021-06-21 11:01:40 +00:00
class="py-2 text-sm text-secondaryLight field-desc"
2021-05-19 04:54:57 +00:00
>
{{ field.description }}
</div>
</div>
</div>
</div>
2019-11-18 19:34:00 +00:00
</div>
</template>
<script>
export default {
props: {
2021-05-19 04:54:57 +00:00
gqlField: { type: Object, default: () => {} },
jumpTypeCallback: { type: Function, default: () => {} },
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>
2021-05-19 04:54:57 +00:00
<style scoped lang="scss">
.field-highlighted {
@apply border-b-2;
2021-06-12 16:46:17 +00:00
@apply border-accent;
2021-05-19 04:54:57 +00:00
}
</style>