Add too many queries exception
This commit is contained in:
parent
ded46774bc
commit
4ee7f80433
2 changed files with 11 additions and 5 deletions
|
@ -514,7 +514,12 @@ return [
|
||||||
],
|
],
|
||||||
Exception::GRAPHQL_NO_QUERY => [
|
Exception::GRAPHQL_NO_QUERY => [
|
||||||
'name' => Exception::GRAPHQL_NO_QUERY,
|
'name' => Exception::GRAPHQL_NO_QUERY,
|
||||||
'description' => 'Query is required and can be provided via parameter or as the raw body if the content-type header is application/graphql.',
|
'description' => 'Query is required.',
|
||||||
|
'code' => 400,
|
||||||
|
],
|
||||||
|
Exception::GRAPHQL_TOO_MANY_QUERIES => [
|
||||||
|
'name' => Exception::GRAPHQL_TOO_MANY_QUERIES,
|
||||||
|
'description' => 'Too many queries have been sent in the same request.',
|
||||||
'code' => 400,
|
'code' => 400,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -79,14 +79,15 @@ function graphqlRequest(
|
||||||
if (\str_starts_with($contentType, 'multipart/form-data')) {
|
if (\str_starts_with($contentType, 'multipart/form-data')) {
|
||||||
$query = parseMultipartRequest($query, $request);
|
$query = parseMultipartRequest($query, $request);
|
||||||
}
|
}
|
||||||
if (!\isset($query[0])) {
|
if (!empty($query) && !isset($query[0])) {
|
||||||
$query = [$query];
|
$query = [$query];
|
||||||
}
|
}
|
||||||
if (\empty($query)) {
|
if (empty($query)) {
|
||||||
throw new Exception('No query supplied.', 400, Exception::GRAPHQL_NO_QUERY);
|
throw new Exception('No query supplied.', 400, Exception::GRAPHQL_NO_QUERY);
|
||||||
}
|
}
|
||||||
if (\count($query) > $maxBatchSize) {
|
if (\count($query) > $maxBatchSize) {
|
||||||
throw new Exception('Too many queries in batch.', 400, Exception::GRAPHQL_TOO_MANY_QUERIES);
|
throw new Exception('Too many queries.', 400, Exception::GRAPHQL_TOO_MANY_QUERIES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$debugFlags = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE;
|
$debugFlags = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE;
|
||||||
|
|
Loading…
Reference in a new issue