Skip to content

Commit

Permalink
exception is thrown when invalid json is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasLudvik committed Nov 29, 2024
1 parent 30552c7 commit 2deeb93
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use GraphQL\Language\Parser;
use Override;
use Shopsys\FrameworkBundle\Component\HttpFoundation\TransactionalMasterRequestConditionProviderInterface;
use Shopsys\FrontendApiBundle\Model\Error\InvalidArgumentUserError;
use Symfony\Component\HttpKernel\Event\RequestEvent;

class TransactionalMasterRequestConditionProvider implements TransactionalMasterRequestConditionProviderInterface
Expand Down Expand Up @@ -44,6 +45,10 @@ protected function isRequestGraphQlQuery(RequestEvent $requestEvent): bool

$source = json_decode($requestContent, true);

if (!is_array($source)) {
throw new InvalidArgumentUserError('Request content is not a valid JSON.');
}

if (!array_key_exists(static::QUERY_TYPE, $source)) {
return false;
}
Expand Down

0 comments on commit 2deeb93

Please sign in to comment.