Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Added copy schema button to copy schema string to clipboard

Andrew Bastin6a938cdcca45
diff --git a/pages/graphql.vue b/pages/graphql.vue
index bd1f6ce0a..ad6736036 100644
--- a/pages/graphql.vue
+++ b/pages/graphql.vue
@@ -37,6 +37,13 @@
useWorker: false
}"
/>
+ <button
+ class="icon"
+ @click="copySchema"
+ v-tooltip="'Copy Schema'"
+ >
+ <i class="material-icons">file_copy</i>
+ </button>
</pw-section>
</div>
<aside class="sticky-inner inner-right">
@@ -140,6 +147,19 @@ export default {
};
},
methods: {
+
+ copySchema() {
+ const aux = document.createElement("textarea");
+ aux.innerText = this.schemaString;
+ document.body.appendChild(aux);
+ aux.select();
+ document.execCommand("copy");
+ document.body.removeChild(aux);
+ this.$toast.success("Copied to clipboard", {
+ icon: "done"
+ });
+ },
+
async getSchema() {
const startTime = Date.now();
this.schemaString = "Loading...";