From 4006c25532e2d5b5442dc9de494c02364e3d7ee1 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 10 Aug 2017 12:50:37 -0700 Subject: [PATCH] Automatically switch to POST for GraphQL --- app/models/request.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/request.js b/app/models/request.js index 513297117..e4e81973b 100644 --- a/app/models/request.js +++ b/app/models/request.js @@ -1,6 +1,6 @@ // @flow 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 {getContentTypeHeader} from '../common/misc'; import {buildFromParams, deconstructToParams} from '../common/querystring'; @@ -214,6 +214,11 @@ export function updateMimeType ( ? CONTENT_TYPE_JSON : 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 let leaveContentTypeAlone = false; if (contentTypeHeader && mimeType) {