Skip to content

Commit

Permalink
use is_graphql_http_request
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed Apr 17, 2020
1 parent 18f69f4 commit ba16a1b
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,6 @@ function is_graphql_request()
return true;
}

// Copied from https://github.com/wp-graphql/wp-graphql/pull/1067
// For now as the existing version is buggy.
if (isset($_GET[\WPGraphQL\Router::$route])) {
return true;
}

// If before 'init' check $_SERVER.
if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) {
$haystack =
wp_unslash($_SERVER['HTTP_HOST']) .
wp_unslash($_SERVER['REQUEST_URI']);
$needle = site_url(\WPGraphQL\Router::$route);
// Strip protocol.
$haystack = preg_replace('#^(http(s)?://)#', '', $haystack);
$needle = preg_replace('#^(http(s)?://)#', '', $needle);
$len = strlen($needle);
return substr($haystack, 0, $len) === $needle;
}

return false;
return is_graphql_http_request();
}
}

0 comments on commit ba16a1b

Please sign in to comment.