Skip to content

Commit 06dc826

Browse files
authored
Merge pull request #305 from moufmouf/conditional_myclabs_enum
Loading MyCLabsEnumTypeMapper conditionally
2 parents c056ef7 + c7022af commit 06dc826

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/SchemaFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\Common\Cache\PhpFileCache;
1313
use GraphQL\Type\SchemaConfig;
1414
use Mouf\Composer\ClassNameMapper;
15+
use MyCLabs\Enum\Enum;
1516
use PackageVersions\Versions;
1617
use Psr\Container\ContainerInterface;
1718
use Psr\SimpleCache\CacheInterface;
@@ -52,6 +53,7 @@
5253
use TheCodingMachine\GraphQLite\Utils\Namespaces\NamespaceFactory;
5354
use function array_map;
5455
use function array_reverse;
56+
use function class_exists;
5557
use function crc32;
5658
use function function_exists;
5759
use function md5;
@@ -346,7 +348,9 @@ public function createSchema(): Schema
346348

347349
$errorRootTypeMapper = new FinalRootTypeMapper($recursiveTypeMapper);
348350
$rootTypeMapper = new BaseTypeMapper($errorRootTypeMapper, $recursiveTypeMapper, $topRootTypeMapper);
349-
$rootTypeMapper = new MyCLabsEnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);
351+
if (class_exists(Enum::class)) {
352+
$rootTypeMapper = new MyCLabsEnumTypeMapper($rootTypeMapper, $annotationReader, $symfonyCache, $nsList);
353+
}
350354

351355
if (! empty($this->rootTypeMapperFactories)) {
352356
$rootSchemaFactoryContext = new RootTypeMapperFactoryContext(

0 commit comments

Comments
 (0)