• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 7930644932

16 Feb 2024 12:36PM UTC coverage: 66.683% (+0.005%) from 66.678%
7930644932

push

github

web-flow
fix: return null instead of exception for GraphQL Query operation (#6118)

0 of 2 new or added lines in 1 file covered. (0.0%)

53 existing lines in 19 files now uncovered.

16304 of 24450 relevant lines covered (66.68%)

37.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/src/Symfony/Validator/State/QueryParameterValidateProvider.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\Validator\State;
15

16
use ApiPlatform\Api\QueryParameterValidator\QueryParameterValidator;
17
use ApiPlatform\Doctrine\Orm\State\Options;
18
use ApiPlatform\Metadata\CollectionOperationInterface;
19
use ApiPlatform\Metadata\HttpOperation;
20
use ApiPlatform\Metadata\Operation;
21
use ApiPlatform\State\ProviderInterface;
22
use ApiPlatform\State\Util\RequestParser;
23

24
final class QueryParameterValidateProvider implements ProviderInterface
25
{
26
    public function __construct(private readonly ProviderInterface $decorated, private readonly QueryParameterValidator $queryParameterValidator)
27
    {
28
    }
99✔
29

30
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
31
    {
32
        if (
33
            !$operation instanceof HttpOperation
99✔
34
            || !($request = $context['request'] ?? null)
99✔
35
            || !$request->isMethodSafe()
99✔
36
            || 'GET' !== $request->getMethod()
99✔
37
        ) {
UNCOV
38
            return $this->decorated->provide($operation, $uriVariables, $context);
9✔
39
        }
40

41
        if (!($operation->getQueryParameterValidationEnabled() ?? true) || !$operation instanceof CollectionOperationInterface) {
90✔
42
            return $this->decorated->provide($operation, $uriVariables, $context);
65✔
43
        }
44

45
        $queryString = RequestParser::getQueryString($request);
34✔
46
        $queryParameters = $queryString ? RequestParser::parseRequestParams($queryString) : [];
34✔
47
        $class = $operation->getClass();
34✔
48
        if (($options = $operation->getStateOptions()) && $options instanceof Options && $options->getEntityClass()) {
34✔
49
            $class = $options->getEntityClass();
×
50
        }
51

52
        $this->queryParameterValidator->validateFilters($class, $operation->getFilters() ?? [], $queryParameters);
34✔
53

54
        return $this->decorated->provide($operation, $uriVariables, $context);
34✔
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc