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
|
|
|
private $queryMatch; |
23
|
|
|
|
24
|
|
|
public function __construct(Profiler $profiler = null, Environment $twig = null, RouterInterface $router, RequestExecutor $requestExecutor, string $queryMatch = null) |
25
|
|
|
{ |
26
|
|
|
$this->profiler = $profiler; |
27
|
|
|
$this->twig = $twig; |
28
|
|
|
$this->endpointUrl = $router->generate('overblog_graphql_endpoint'); |
29
|
|
|
$this->requestExecutor = $requestExecutor; |
30
|
|
|
$this->queryMatch = $queryMatch; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function __invoke(Request $request, $token) |
34
|
|
|
{ |
35
|
|
|
if (null === $this->profiler) { |
36
|
|
|
throw new NotFoundHttpException('The profiler must be enabled.'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$this->profiler->disable(); |
40
|
|
|
|
41
|
|
|
$profile = $this->profiler->loadProfile($token); |
42
|
|
|
|
43
|
|
|
$tokens = \array_map(function ($tokenData) { |
44
|
|
|
$profile = $this->profiler->loadProfile($tokenData['token']); |
|
|
|
|
45
|
|
|
$graphql = $profile ? $profile->getCollector('graphql') : null; |
46
|
|
|
$tokenData['graphql'] = $graphql; |
47
|
|
|
|
48
|
|
|
return $tokenData; |
49
|
|
|
}, $this->profiler->find(null, $this->queryMatch ?: $this->endpointUrl, '100', 'POST', null, null, null)); |
50
|
|
|
|
51
|
|
|
$schemas = []; |
52
|
|
|
foreach ($this->requestExecutor->getSchemasNames() as $schemaName) { |
53
|
|
|
$schemas[$schemaName] = SchemaPrinter::doPrint($this->requestExecutor->getSchema($schemaName)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return new Response($this->twig->render('@OverblogGraphQL/profiler/graphql.html.twig', [ |
|
|
|
|
57
|
|
|
'request' => $request, |
58
|
|
|
'profile' => $profile, |
59
|
|
|
'tokens' => $tokens, |
60
|
|
|
'token' => $token, |
61
|
|
|
'panel' => null, |
62
|
|
|
'schemas' => $schemas, |
63
|
|
|
]), 200, ['Content-Type' => 'text/html']); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.