1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Overblog\GraphQLBundle\Controller; |
6
|
|
|
|
7
|
|
|
use GraphQL\Utils\SchemaPrinter; |
8
|
|
|
use Overblog\GraphQLBundle\Request\Executor as RequestExecutor; |
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
10
|
|
|
use Symfony\Component\HttpFoundation\Response; |
11
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
12
|
|
|
use Symfony\Component\HttpKernel\Profiler\Profiler; |
13
|
|
|
use Symfony\Component\Routing\RouterInterface; |
14
|
|
|
use Twig\Environment; |
|
|
|
|
15
|
|
|
|
16
|
|
|
class ProfilerController |
17
|
|
|
{ |
18
|
|
|
private $profiler; |
19
|
|
|
private $twig; |
20
|
|
|
private $endpointUrl; |
21
|
|
|
private $requestExecutor; |
22
|
|
|
|
23
|
|
|
public function __construct(Profiler $profiler = null, Environment $twig = null, RouterInterface $router, RequestExecutor $requestExecutor) |
24
|
|
|
{ |
25
|
|
|
$this->profiler = $profiler; |
26
|
|
|
$this->twig = $twig; |
27
|
|
|
$this->endpointUrl = $router->generate('overblog_graphql_endpoint'); |
28
|
|
|
$this->requestExecutor = $requestExecutor; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function __invoke(Request $request, $token) |
32
|
|
|
{ |
33
|
|
|
if (null === $this->profiler) { |
34
|
|
|
throw new NotFoundHttpException('The profiler must be enabled.'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
$this->profiler->disable(); |
38
|
|
|
|
39
|
|
|
$profile = $this->profiler->loadProfile($token); |
40
|
|
|
|
41
|
|
|
$tokens = \array_map(function ($tokenData) { |
42
|
|
|
$profile = $this->profiler->loadProfile($tokenData['token']); |
|
|
|
|
43
|
|
|
$graphql = $profile ? $profile->getCollector('graphql') : null; |
44
|
|
|
$tokenData['graphql'] = $graphql; |
45
|
|
|
|
46
|
|
|
return $tokenData; |
47
|
|
|
}, $this->profiler->find(null, $this->endpointUrl, '100', null, null, null, null)); |
48
|
|
|
|
49
|
|
|
$schemas = []; |
50
|
|
|
foreach ($this->requestExecutor->getSchemasNames() as $schemaName) { |
51
|
|
|
$schemas[$schemaName] = SchemaPrinter::doPrint($this->requestExecutor->getSchema($schemaName)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return new Response($this->twig->render('@OverblogGraphQL/profiler/graphql.html.twig', [ |
|
|
|
|
55
|
|
|
'request' => $request, |
56
|
|
|
'profile' => $profile, |
57
|
|
|
'tokens' => $tokens, |
58
|
|
|
'token' => $token, |
59
|
|
|
'panel' => null, |
60
|
|
|
'schemas' => $schemas, |
61
|
|
|
]), 200, ['Content-Type' => 'text/html']); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths