diff --git a/packages/insomnia-app/app/common/misc.js b/packages/insomnia-app/app/common/misc.js index c912ddaad..6584bdd19 100644 --- a/packages/insomnia-app/app/common/misc.js +++ b/packages/insomnia-app/app/common/misc.js @@ -118,7 +118,7 @@ export function removeVowels(str: string): string { } export function formatMethodName(method: string): string { - let methodName = method; + let methodName = method || ''; if (method === METHOD_DELETE || method === METHOD_OPTIONS) { methodName = method.slice(0, 3); } else if (method.length > 4) { diff --git a/packages/insomnia-app/app/ui/components/sidebar/sidebar-request-row.js b/packages/insomnia-app/app/ui/components/sidebar/sidebar-request-row.js index 0fdcdc6c4..0e1174991 100644 --- a/packages/insomnia-app/app/ui/components/sidebar/sidebar-request-row.js +++ b/packages/insomnia-app/app/ui/components/sidebar/sidebar-request-row.js @@ -11,6 +11,7 @@ import MethodTag from '../tags/method-tag'; import * as models from '../../../models'; import { showModal } from '../modals/index'; import RequestSettingsModal from '../modals/request-settings-modal'; +import { CONTENT_TYPE_GRAPHQL } from '../../../common/constants'; @autobind class SidebarRequestRow extends PureComponent { @@ -60,12 +61,20 @@ class SidebarRequestRow extends PureComponent { } _getMethodOverrideHeaderValue() { - let header = this.props.request.headers.find( - h => h.name.toLowerCase() === 'x-http-method-override', - ); - if (!header || header.disabled) header = null; - else header = header.value; - return header; + const { request } = this.props; + + const header = request.headers.find(h => h.name.toLowerCase() === 'x-http-method-override'); + + if (header) { + return header.value; + } + + // If no override, use GraphQL as override if it's a gql request + if (request.body && request.body.mimeType === CONTENT_TYPE_GRAPHQL) { + return 'GQL'; + } + + return null; } setDragDirection(dragDirection) { diff --git a/packages/insomnia-app/app/ui/components/tags/method-tag.js b/packages/insomnia-app/app/ui/components/tags/method-tag.js index 6d97b3e3d..c8a3aa06e 100644 --- a/packages/insomnia-app/app/ui/components/tags/method-tag.js +++ b/packages/insomnia-app/app/ui/components/tags/method-tag.js @@ -1,18 +1,17 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; -import { HTTP_METHODS } from '../../../common/constants'; import * as util from '../../../common/misc'; class MethodTag extends PureComponent { render() { const { method, override, fullNames } = this.props; + let methodName = method; let overrideName = override; - if (!HTTP_METHODS.includes(override)) overrideName = null; if (!fullNames) { methodName = util.formatMethodName(method); - if (overrideName) overrideName = util.formatMethodName(override); + overrideName = override ? util.formatMethodName(override) : override; } return ( diff --git a/packages/insomnia-app/app/ui/css/constants/colors.less b/packages/insomnia-app/app/ui/css/constants/colors.less index a371c59f3..5dbb5546b 100644 --- a/packages/insomnia-app/app/ui/css/constants/colors.less +++ b/packages/insomnia-app/app/ui/css/constants/colors.less @@ -75,6 +75,7 @@ } .surprise, +.http-method-GQL, .http-method-GET { color: var(--color-surprise) !important; }