mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Use X-HTTP-Method-Override UI to show GraphQL as well (Closes #1780)
This commit is contained in:
parent
1e3da598cd
commit
d330bb5c70
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 (
|
||||
|
@ -75,6 +75,7 @@
|
||||
}
|
||||
|
||||
.surprise,
|
||||
.http-method-GQL,
|
||||
.http-method-GET {
|
||||
color: var(--color-surprise) !important;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user