api-client/components/graphql/field.vue

63 lines
1.2 KiB
Vue
Raw Normal View History

2019-11-18 19:34:00 +00:00
<template>
<div class="field-box">
<div class="field-title">{{ fieldString }}</div>
<div class="field-desc" v-if="gqlField.description">
{{ gqlField.description }}
</div>
<div class="field-deprecated" v-if="gqlField.isDeprecated">
DEPRECATED
</div>
2019-11-18 19:34:00 +00:00
</div>
</template>
<style>
.field-box {
2019-11-20 00:46:02 +00:00
padding: 16px;
margin: 4px;
2019-12-17 19:13:15 +00:00
border-bottom: 1px dashed var(--brd-color);
2019-11-18 19:34:00 +00:00
}
2019-11-20 00:46:02 +00:00
.field-deprecated {
background-color: yellow;
color: black;
display: inline-block;
2019-11-20 00:46:02 +00:00
padding: 4px 8px;
margin: 4px 0;
border-radius: 4px;
font-size: 14px;
2019-11-20 00:46:02 +00:00
font-weight: 700;
}
2019-11-18 19:34:00 +00:00
.field-desc {
2019-11-20 00:46:02 +00:00
color: var(--fg-light-color);
margin-top: 4px;
2019-11-18 19:34:00 +00:00
}
</style>
<script>
export default {
props: {
gqlField: Object
},
computed: {
fieldString() {
2019-11-18 20:14:26 +00:00
const args = (this.gqlField.args || []).reduce((acc, arg, index) => {
return (
acc +
`${arg.name}: ${arg.type.toString()}${
index !== this.gqlField.args.length - 1 ? ", " : ""
}`
);
}, "");
const argsString = args.length > 0 ? `(${args})` : "";
2019-11-18 19:34:00 +00:00
return `${
this.gqlField.name
}${argsString}: ${this.gqlField.type.toString()}`;
2019-11-18 19:34:00 +00:00
}
}
};
2019-11-18 19:34:00 +00:00
</script>