Add invalid query exception
This commit is contained in:
parent
4ee7f80433
commit
4f5c7ddada
3 changed files with 11 additions and 0 deletions
|
@ -517,6 +517,11 @@ return [
|
|||
'description' => 'Query is required.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::GRAPHQL_INVALID_QUERY => [
|
||||
'name' => Exception::GRAPHQL_NO_QUERY,
|
||||
'description' => 'Invalid query supplied.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::GRAPHQL_TOO_MANY_QUERIES => [
|
||||
'name' => Exception::GRAPHQL_TOO_MANY_QUERIES,
|
||||
'description' => 'Too many queries have been sent in the same request.',
|
||||
|
|
|
@ -88,6 +88,10 @@ function graphqlRequest(
|
|||
if (\count($query) > $maxBatchSize) {
|
||||
throw new Exception('Too many queries.', 400, Exception::GRAPHQL_TOO_MANY_QUERIES);
|
||||
}
|
||||
foreach ($query as $item) {
|
||||
if (!isset($item['query'])) {
|
||||
throw new Exception('Invalid query.', 400, Exception::GRAPHQL_INVALID_QUERY);
|
||||
}
|
||||
}
|
||||
|
||||
$debugFlags = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE;
|
||||
|
|
|
@ -173,6 +173,8 @@ class Exception extends \Exception
|
|||
|
||||
/** GraphqQL */
|
||||
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
|
||||
public const GRAPHQL_INVALID_QUERY = 'graphql_invalid_query';
|
||||
public const GRAPHQL_TOO_MANY_QUERIES = 'graphql_too_many_queries';
|
||||
|
||||
private $type = '';
|
||||
|
||||
|
|
Loading…
Reference in a new issue