fix graphql endpoint

This commit is contained in:
Blaise de Carné 2018-07-26 16:22:57 +02:00
parent d38f28bd07
commit 376f3542d2

View File

@ -5,16 +5,24 @@ header('Access-Control-Allow-Credentials: true', true);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type');
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
return;
}
$payload = null;
if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] === 'application/json') {
switch($_SERVER['REQUEST_METHOD']) {
case "POST":
if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] === 'application/json') {
$rawBody = file_get_contents('php://input');
$requestData = json_decode($rawBody ?: '', true);
} else {
} else {
$requestData = $_POST;
}
break;
case "GET":
$requestData = $_GET;
break;
default:
exit;
}
$payload = isset($requestData['query']) ? $requestData['query'] : null;
require_once __DIR__.'/../vendor/autoload.php';