From 7dd4db13a10784c2b2b6106b7f57e1531193dc8e Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Thu, 5 Mar 2020 14:20:15 -0500 Subject: [PATCH] Added prettifying to GQL Query Editor --- components/graphql/queryeditor.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/graphql/queryeditor.vue b/components/graphql/queryeditor.vue index 6378f5f09..52cfcae21 100644 --- a/components/graphql/queryeditor.vue +++ b/components/graphql/queryeditor.vue @@ -147,6 +147,15 @@ export default { }, }) + editor.commands.addCommand({ + name: "prettifyGQLQuery", + exec: () => this.prettifyQuery(), + bindKey: { + mac: "cmd-g", + win: "ctrl-g", + }, + }) + editor.on("change", () => { const content = editor.getValue() this.$emit("input", content) @@ -158,6 +167,10 @@ export default { }, methods: { + prettifyQuery() { + this.value = gql.print(gql.parse(this.editor.getValue())) + }, + defineTheme() { if (this.theme) { return this.theme