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 error handling to query prettify to prevent event propagation

Andrew Bastina9ba2b50f916
diff --git a/components/graphql/queryeditor.vue b/components/graphql/queryeditor.vue
index 52cfcae21..e351bf5b3 100644
--- a/components/graphql/queryeditor.vue
+++ b/components/graphql/queryeditor.vue
@@ -151,8 +151,8 @@ export default {
name: "prettifyGQLQuery",
exec: () => this.prettifyQuery(),
bindKey: {
- mac: "cmd-g",
- win: "ctrl-g",
+ mac: "cmd-p",
+ win: "ctrl-p",
},
})
@@ -168,7 +168,12 @@ export default {
methods: {
prettifyQuery() {
- this.value = gql.print(gql.parse(this.editor.getValue()))
+ try {
+ this.value = gql.print(gql.parse(this.editor.getValue()))
+ } catch (e) {
+ // Catching the exception to avoid the event to be passed to the browser
+ // Prevents the print dialog from appearing
+ }
},
defineTheme() {