Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
Updated field, type and graphql page to use the new argument and typelink components
Andrew Bastincc396aecd3fe
diff --git a/components/graphql/field.vue b/components/graphql/field.vueindex b5acb1b54..e717cca2c 100644--- a/components/graphql/field.vue+++ b/components/graphql/field.vue@@ -1,6 +1,18 @@<template><div class="field-box">- <div class="field-title">{{ fieldString }}</div>+ <div class="field-title">+ {{ fieldName }}+ <span v-if="fieldArgs.length > 0">+ (+ <span v-for="(field, index) in fieldArgs" :key="index">+ {{ field.name }}: <typelink :gqlType="field.type" :jumpTypeCallback="jumpTypeCallback" />+ <span v-if="index !== fieldArgs.length - 1">+ ,+ </span>+ </span>+ )+ </span>: <typelink :gqlType="gqlField.type" :jumpTypeCallback="jumpTypeCallback" />+ </div><div class="field-desc" v-if="gqlField.description">{{ gqlField.description }}</div>@@ -8,6 +20,7 @@<div class="field-deprecated" v-if="gqlField.isDeprecated">DEPRECATED</div>+</div></template>@@ -36,9 +49,17 @@</style><script>+import typelink from './typelink';+export default {+ components: {+ typelink: typelink+ },+props: {- gqlField: Object+ gqlField: Object,++ jumpTypeCallback: Function},computed: {@@ -56,6 +77,14 @@ export default {return `${this.gqlField.name}${argsString}: ${this.gqlField.type.toString()}`;+ },++ fieldName() {+ return this.gqlField.name;+ },++ fieldArgs() {+ return this.gqlField.args || [];}}};diff --git a/components/graphql/type.vue b/components/graphql/type.vueindex b33bdb209..4bf00b511 100644--- a/components/graphql/type.vue+++ b/components/graphql/type.vue@@ -8,7 +8,7 @@<div v-if="gqlType.getFields"><h5>FIELDS</h5><div v-for="field in gqlType.getFields()" :key="field.name">- <gql-field :gqlField="field" />+ <gql-field :gqlField="field" :jumpTypeCallback="jumpTypeCallback" /></div></div></div>@@ -36,7 +36,9 @@ export default {"gql-field": () => import("./field")},props: {- gqlType: {}+ gqlType: {},++ jumpTypeCallback: Function}};</script>diff --git a/pages/graphql.vue b/pages/graphql.vueindex f6c201d94..2ebd97f0c 100644--- a/pages/graphql.vue+++ b/pages/graphql.vue@@ -288,7 +288,7 @@</label><div v-if="queryFields.length > 0" class="tab"><div v-for="field in queryFields" :key="field.name">- <gql-field :gqlField="field" />+ <gql-field :gqlField="field" :jumpTypeCallback="handleJumpToType" /></div></div>@@ -304,7 +304,7 @@</label><div v-if="mutationFields.length > 0" class="tab"><div v-for="field in mutationFields" :key="field.name">- <gql-field :gqlField="field" />+ <gql-field :gqlField="field" :jumpTypeCallback="handleJumpToType" /></div></div>@@ -320,7 +320,7 @@</label><div v-if="subscriptionFields.length > 0" class="tab"><div v-for="field in subscriptionFields" :key="field.name">- <gql-field :gqlField="field" />+ <gql-field :gqlField="field" :jumpTypeCallback="handleJumpToType" /></div></div>@@ -335,8 +335,8 @@{{ $t("types") }}</label><div v-if="gqlTypes.length > 0" class="tab">- <div v-for="type in gqlTypes" :key="type.name">- <gql-type :gqlType="type" />+ <div v-for="type in gqlTypes" :key="type.name" :id="`type_${type.name}`">+ <gql-type :gqlType="type" :jumpTypeCallback="handleJumpToType" /></div></div></section>@@ -563,6 +563,24 @@ export default {}},methods: {+ handleJumpToType(type) {+ const typesTab = document.getElementById("gqltypes-tab");+ typesTab.checked = true;++ const rootTypeName = this.resolveRootType(type).name;++ const target = document.getElementById(`type_${rootTypeName}`);+ if (target) {+ target.scrollIntoView({+ behavior: 'smooth'+ });+ }+ },+ resolveRootType(type) {+ let t = type;+ while (t.ofType != null) t = t.ofType;+ return t;+ },copySchema() {this.$refs.copySchemaCode.innerHTML = this.doneButton;const aux = document.createElement("textarea");