From 4b64c81222b3a69bdec344dda460d41d0a37b740 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 27 Jun 2018 23:43:38 -0400 Subject: [PATCH] Don't render GraphQL comments (Fixes #895) --- packages/insomnia-app/app/common/render.js | 11 +++++++++++ packages/insomnia-app/app/main/window-utils.js | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/insomnia-app/app/common/render.js b/packages/insomnia-app/app/common/render.js index 3bf0616db..384c125f4 100644 --- a/packages/insomnia-app/app/common/render.js +++ b/packages/insomnia-app/app/common/render.js @@ -5,6 +5,7 @@ import type { BaseModel } from '../models/index'; import { setDefaultProtocol } from 'insomnia-url'; import clone from 'clone'; import * as models from '../models'; +import { CONTENT_TYPE_GRAPHQL } from '../common/constants'; import * as db from './database'; import * as templating from '../templating'; import type { CookieJar } from '../models/cookie-jar'; @@ -246,6 +247,16 @@ export async function getRenderedRequestAndContext( purpose ); + // HACK: Remove comments from GraphQL.query because comments (#}) + // can cause rendering to fail (https://github.com/getinsomnia/insomnia/issues/895) + try { + if (request.body.text && request.body.mimeType === CONTENT_TYPE_GRAPHQL) { + const o = JSON.parse(request.body.text); + o.query = o.query.replace(/#}/g, '# }'); + request.body.text = JSON.stringify(o); + } + } catch (err) {} + // Render all request properties const renderResult = await render( { _request: request, _cookieJar: cookieJar }, diff --git a/packages/insomnia-app/app/main/window-utils.js b/packages/insomnia-app/app/main/window-utils.js index e06bf3899..5cfa5990c 100644 --- a/packages/insomnia-app/app/main/window-utils.js +++ b/packages/insomnia-app/app/main/window-utils.js @@ -247,7 +247,6 @@ export function createWindow() { }, { label: 'Insomnia Help', - accelerator: 'CmdOrCtrl+/', click: () => { shell.openExternal('https://support.insomnia.rest'); }