Skip to content

Commit f20bec9

Browse files
tguilpainfubhy
authored andcommitted
#868: Improve error handling in case of query with wrong querymap id. (#869)
1 parent 17e33a9 commit f20bec9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/GraphQL/Execution/QueryProcessor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function executeOperationWithReporting(PromiseAdapter $adapter, Server
172172
protected function executeOperation(PromiseAdapter $adapter, ServerConfig $config, OperationParams $params, $batching = FALSE) {
173173
try {
174174
if (!$config->getSchema()) {
175-
throw new \LogicException('Missing schema for query execution.');
175+
throw new Error('Missing schema for query execution.');
176176
}
177177

178178
if ($batching && !$config->getQueryBatching()) {
@@ -403,14 +403,15 @@ protected function resolveContextValue(ServerConfig $config, OperationParams $pa
403403
* @param $operation
404404
*
405405
* @return array
406+
* @throws \GraphQL\Server\RequestError
406407
*/
407408
protected function resolveValidationRules(ServerConfig $config, OperationParams $params, DocumentNode $document, $operation) {
408409
// Allow customizing validation rules per operation:
409410
$rules = $config->getValidationRules();
410411
if (is_callable($rules)) {
411412
$rules = $rules($params, $document, $operation);
412413
if (!is_array($rules)) {
413-
throw new \LogicException(sprintf("Expecting validation rules to be array or callable returning array, but got: %s", Utils::printSafe($rules)));
414+
throw new RequestError(sprintf("Expecting validation rules to be array or callable returning array, but got: %s", Utils::printSafe($rules)));
414415
}
415416
}
416417

@@ -431,7 +432,7 @@ protected function loadPersistedQuery(ServerConfig $config, OperationParams $par
431432

432433
$source = $loader($params->queryId, $params);
433434
if (!is_string($source) && !$source instanceof DocumentNode) {
434-
throw new \LogicException(sprintf('The persisted query loader must return query string or instance of %s but got: %s.', DocumentNode::class, Utils::printSafe($source)));
435+
throw new RequestError(sprintf('The persisted query loader must return query string or instance of %s but got: %s.', DocumentNode::class, Utils::printSafe($source)));
435436
}
436437

437438
return $source;

0 commit comments

Comments
 (0)