Automatically switch to POST for GraphQL

This commit is contained in:
Gregory Schier 2017-08-10 12:50:37 -07:00
parent 7b494c2b95
commit 4006c25532

View File

@ -1,6 +1,6 @@
// @flow // @flow
import type {BaseModel} from './index'; import type {BaseModel} from './index';
import {AUTH_BASIC, AUTH_DIGEST, AUTH_NONE, AUTH_NTLM, AUTH_OAUTH_2, AUTH_AWS_IAM, AUTH_NETRC, CONTENT_TYPE_FILE, CONTENT_TYPE_FORM_DATA, CONTENT_TYPE_FORM_URLENCODED, CONTENT_TYPE_OTHER, getContentTypeFromHeaders, METHOD_GET, CONTENT_TYPE_GRAPHQL, CONTENT_TYPE_JSON} from '../common/constants'; import {AUTH_BASIC, AUTH_DIGEST, AUTH_NONE, AUTH_NTLM, AUTH_OAUTH_2, AUTH_AWS_IAM, AUTH_NETRC, CONTENT_TYPE_FILE, CONTENT_TYPE_FORM_DATA, CONTENT_TYPE_FORM_URLENCODED, CONTENT_TYPE_OTHER, getContentTypeFromHeaders, METHOD_GET, CONTENT_TYPE_GRAPHQL, CONTENT_TYPE_JSON, METHOD_POST} from '../common/constants';
import * as db from '../common/database'; import * as db from '../common/database';
import {getContentTypeHeader} from '../common/misc'; import {getContentTypeHeader} from '../common/misc';
import {buildFromParams, deconstructToParams} from '../common/querystring'; import {buildFromParams, deconstructToParams} from '../common/querystring';
@ -214,6 +214,11 @@ export function updateMimeType (
? CONTENT_TYPE_JSON ? CONTENT_TYPE_JSON
: mimeType; : mimeType;
// GraphQL must be POST
if (mimeType === CONTENT_TYPE_GRAPHQL) {
request.method = METHOD_POST;
}
// Check if we are converting to/from variants of XML or JSON // Check if we are converting to/from variants of XML or JSON
let leaveContentTypeAlone = false; let leaveContentTypeAlone = false;
if (contentTypeHeader && mimeType) { if (contentTypeHeader && mimeType) {