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 ability to copy GQL response

Andrew Bastind2115ab004fb
diff --git a/pages/graphql.vue b/pages/graphql.vue
index 7ad3e813c..efa6437fb 100644
--- a/pages/graphql.vue
+++ b/pages/graphql.vue
@@ -178,7 +178,19 @@
></textarea>
</pw-section>
<pw-section class="purple" label="Response" ref="response">
- <label for="responseField"></label>
+ <div class="flex-wrap">
+ <label for="responseField">Response</label>
+ <div>
+ <button
+ class="icon"
+ @click="copyResponse"
+ ref="copyResponseButton"
+ v-tooltip="'Copy Response'"
+ >
+ <i class="material-icons">file_copy</i>
+ </button>
+ </div>
+ </div>
<Editor
:value="responseString"
:lang="'json'"
@@ -369,6 +381,22 @@ export default {
1000
);
},
+ copyResponse() {
+ this.$refs.copyResponseButton.innerHTML = this.doneButton;
+ const aux = document.createElement("textarea");
+ aux.innerText = this.responseString;
+ document.body.appendChild(aux);
+ aux.select();
+ document.execCommand("copy");
+ document.body.removeChild(aux);
+ this.$toast.success("Copied to clipboard", {
+ icon: "done"
+ });
+ setTimeout(
+ () => (this.$refs.copyResponseButton.innerHTML = this.copyButton),
+ 1000
+ );
+ },
async runQuery() {
const startTime = Date.now();