Skip to content

Commit dd5e608

Browse files
committed
Adding ability to fetch types in a namespace non-recursively
1 parent 7b6b4e8 commit dd5e608

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"webonyx/graphql-php": "^0.13",
1515
"psr/container": "^1",
1616
"doctrine/annotations": "^1.2",
17-
"thecodingmachine/class-explorer": "^1",
17+
"thecodingmachine/class-explorer": "^1.1",
1818
"psr/simple-cache": "^1",
1919
"phpdocumentor/reflection-docblock": "^4.3",
2020
"phpdocumentor/type-resolver": "^0.4",

src/Mappers/GlobTypeMapper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,15 @@ final class GlobTypeMapper implements TypeMapperInterface
113113
* @var array<string,ReflectionClass>
114114
*/
115115
private $classes;
116+
/**
117+
* @var bool
118+
*/
119+
private $recursive;
116120

117121
/**
118122
* @param string $namespace The namespace that contains the GraphQL types (they must have a `@Type` annotation)
119123
*/
120-
public function __construct(string $namespace, TypeGenerator $typeGenerator, InputTypeGenerator $inputTypeGenerator, InputTypeUtils $inputTypeUtils, ContainerInterface $container, AnnotationReader $annotationReader, NamingStrategy $namingStrategy, CacheInterface $cache, ?int $globTtl = 2, ?int $mapTtl = null)
124+
public function __construct(string $namespace, TypeGenerator $typeGenerator, InputTypeGenerator $inputTypeGenerator, InputTypeUtils $inputTypeUtils, ContainerInterface $container, AnnotationReader $annotationReader, NamingStrategy $namingStrategy, CacheInterface $cache, ?int $globTtl = 2, ?int $mapTtl = null, bool $recursive = true)
121125
{
122126
$this->namespace = $namespace;
123127
$this->typeGenerator = $typeGenerator;
@@ -129,6 +133,7 @@ public function __construct(string $namespace, TypeGenerator $typeGenerator, Inp
129133
$this->mapTtl = $mapTtl;
130134
$this->inputTypeGenerator = $inputTypeGenerator;
131135
$this->inputTypeUtils = $inputTypeUtils;
136+
$this->recursive = $recursive;
132137
}
133138

134139
/**
@@ -241,7 +246,7 @@ private function getClassList(): array
241246
{
242247
if ($this->classes === null) {
243248
$this->classes = [];
244-
$explorer = new GlobClassExplorer($this->namespace, $this->cache, $this->globTtl, ClassNameMapper::createFromComposerFile(null, null, true));
249+
$explorer = new GlobClassExplorer($this->namespace, $this->cache, $this->globTtl, ClassNameMapper::createFromComposerFile(null, null, true), $this->recursive);
245250
$classes = $explorer->getClasses();
246251
foreach ($classes as $className) {
247252
if (!\class_exists($className)) {

0 commit comments

Comments
 (0)