|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of DivineNii opensource projects. |
|
7
|
|
|
* |
|
8
|
|
|
* PHP version 7.4 and above required |
|
9
|
|
|
* |
|
10
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
|
11
|
|
|
* @copyright 2019 DivineNii (https://divinenii.com/) |
|
12
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause License |
|
13
|
|
|
* |
|
14
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
15
|
|
|
* file that was distributed with this source code. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Rade\GraphQL; |
|
19
|
|
|
|
|
20
|
|
|
use Biurad\Http\Response\JsonResponse; |
|
21
|
|
|
use GraphQL\Language\AST\DocumentNode; |
|
|
|
|
|
|
22
|
|
|
use GraphQL\Server\Helper; |
|
|
|
|
|
|
23
|
|
|
use GraphQL\Server\ServerConfig; |
|
|
|
|
|
|
24
|
|
|
use GraphQL\Type\Schema; |
|
|
|
|
|
|
25
|
|
|
use GraphQL\Utils\BuildSchema; |
|
|
|
|
|
|
26
|
|
|
use Psr\Http\Message\RequestInterface; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Represents a GraphQL schema. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class GraphQL |
|
34
|
|
|
{ |
|
35
|
|
|
private Schema $schema; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct(DocumentNode|Schema $schema, callable $typeConfigDecorator = null, array $options = []) |
|
38
|
|
|
{ |
|
39
|
|
|
if ($schema instanceof DocumentNode) { |
|
40
|
|
|
$schema = (new BuildSchema($schema, $typeConfigDecorator, $options))->buildSchema(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$this->schema = $schema; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getScheme(): Schema |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->schema; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param mixed|callable $context |
|
53
|
|
|
*/ |
|
54
|
|
|
public function run(RequestInterface $request, $context): JsonResponse |
|
55
|
|
|
{ |
|
56
|
|
|
$config = new ServerConfig(); |
|
57
|
|
|
$config->setSchema($this->schema); |
|
58
|
|
|
$config->setContext($context); |
|
59
|
|
|
|
|
60
|
|
|
$helper = new Helper(); |
|
61
|
|
|
$parsedBody = $helper->parsePsrRequest($request); |
|
62
|
|
|
|
|
63
|
|
|
if (\is_array($parsedBody)) { |
|
64
|
|
|
$result = $helper->executeBatch($config, $parsedBody); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return new JsonResponse($result ?? $helper->executeOperation($config, $parsedBody)); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
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