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 {
|
export function formatMethodName(method: string): string {
|
||||||
let methodName = method;
|
let methodName = method || '';
|
||||||
if (method === METHOD_DELETE || method === METHOD_OPTIONS) {
|
if (method === METHOD_DELETE || method === METHOD_OPTIONS) {
|
||||||
methodName = method.slice(0, 3);
|
methodName = method.slice(0, 3);
|
||||||
} else if (method.length > 4) {
|
} else if (method.length > 4) {
|
||||||
|
@ -11,6 +11,7 @@ import MethodTag from '../tags/method-tag';
|
|||||||
import * as models from '../../../models';
|
import * as models from '../../../models';
|
||||||
import { showModal } from '../modals/index';
|
import { showModal } from '../modals/index';
|
||||||
import RequestSettingsModal from '../modals/request-settings-modal';
|
import RequestSettingsModal from '../modals/request-settings-modal';
|
||||||
|
import { CONTENT_TYPE_GRAPHQL } from '../../../common/constants';
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
class SidebarRequestRow extends PureComponent {
|
class SidebarRequestRow extends PureComponent {
|
||||||
@ -60,12 +61,20 @@ class SidebarRequestRow extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getMethodOverrideHeaderValue() {
|
_getMethodOverrideHeaderValue() {
|
||||||
let header = this.props.request.headers.find(
|
const { request } = this.props;
|
||||||
h => h.name.toLowerCase() === 'x-http-method-override',
|
|
||||||
);
|
const header = request.headers.find(h => h.name.toLowerCase() === 'x-http-method-override');
|
||||||
if (!header || header.disabled) header = null;
|
|
||||||
else header = header.value;
|
if (header) {
|
||||||
return 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) {
|
setDragDirection(dragDirection) {
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { HTTP_METHODS } from '../../../common/constants';
|
|
||||||
import * as util from '../../../common/misc';
|
import * as util from '../../../common/misc';
|
||||||
|
|
||||||
class MethodTag extends PureComponent {
|
class MethodTag extends PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { method, override, fullNames } = this.props;
|
const { method, override, fullNames } = this.props;
|
||||||
|
|
||||||
let methodName = method;
|
let methodName = method;
|
||||||
let overrideName = override;
|
let overrideName = override;
|
||||||
|
|
||||||
if (!HTTP_METHODS.includes(override)) overrideName = null;
|
|
||||||
if (!fullNames) {
|
if (!fullNames) {
|
||||||
methodName = util.formatMethodName(method);
|
methodName = util.formatMethodName(method);
|
||||||
if (overrideName) overrideName = util.formatMethodName(override);
|
overrideName = override ? util.formatMethodName(override) : override;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.surprise,
|
.surprise,
|
||||||
|
.http-method-GQL,
|
||||||
.http-method-GET {
|
.http-method-GET {
|
||||||
color: var(--color-surprise) !important;
|
color: var(--color-surprise) !important;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user