Don't render GraphQL comments (Fixes #895)

This commit is contained in:
Gregory Schier 2018-06-27 23:43:38 -04:00
parent 07b4e02693
commit 4b64c81222
2 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import type { BaseModel } from '../models/index';
import { setDefaultProtocol } from 'insomnia-url'; import { setDefaultProtocol } from 'insomnia-url';
import clone from 'clone'; import clone from 'clone';
import * as models from '../models'; import * as models from '../models';
import { CONTENT_TYPE_GRAPHQL } from '../common/constants';
import * as db from './database'; import * as db from './database';
import * as templating from '../templating'; import * as templating from '../templating';
import type { CookieJar } from '../models/cookie-jar'; import type { CookieJar } from '../models/cookie-jar';
@ -246,6 +247,16 @@ export async function getRenderedRequestAndContext(
purpose 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 // Render all request properties
const renderResult = await render( const renderResult = await render(
{ _request: request, _cookieJar: cookieJar }, { _request: request, _cookieJar: cookieJar },

View File

@ -247,7 +247,6 @@ export function createWindow() {
}, },
{ {
label: 'Insomnia Help', label: 'Insomnia Help',
accelerator: 'CmdOrCtrl+/',
click: () => { click: () => {
shell.openExternal('https://support.insomnia.rest'); shell.openExternal('https://support.insomnia.rest');
} }