@@ -70,28 +70,7 @@ public function convertType(Type $type, bool $input, Operation $rootOperation, s
7070 return GraphQLType::string ();
7171 }
7272
73- $ resourceType = $ this ->getResourceType ($ type , $ input , $ rootOperation , $ rootResource , $ property , $ depth );
74-
75- if (!$ resourceType && is_a ($ type ->getClassName (), \BackedEnum::class, true )) {
76- // Remove the condition in API Platform 4.
77- if ($ this ->typeBuilder instanceof TypeBuilderEnumInterface) {
78- $ operation = null ;
79- try {
80- $ resourceMetadataCollection = $ this ->resourceMetadataCollectionFactory ->create ($ type ->getClassName ());
81- $ operation = $ resourceMetadataCollection ->getOperation ();
82- } catch (ResourceClassNotFoundException |OperationNotFoundException ) {
83- }
84- /** @var Query $enumOperation */
85- $ enumOperation = (new Query ())
86- ->withClass ($ type ->getClassName ())
87- ->withShortName ($ operation ?->getShortName() ?? (new \ReflectionClass ($ type ->getClassName ()))->getShortName ())
88- ->withDescription ($ operation ?->getDescription());
89-
90- return $ this ->typeBuilder ->getEnumType ($ enumOperation );
91- }
92- }
93-
94- return $ resourceType ;
73+ return $ this ->getResourceType ($ type , $ input , $ rootOperation , $ rootResource , $ property , $ depth );
9574 default :
9675 return null ;
9776 }
@@ -149,6 +128,25 @@ private function getResourceType(Type $type, bool $input, Operation $rootOperati
149128 }
150129
151130 if (!$ hasGraphQl ) {
131+ if (is_a ($ resourceClass , \BackedEnum::class, true )) {
132+ // Remove the condition in API Platform 4.
133+ if ($ this ->typeBuilder instanceof TypeBuilderEnumInterface) {
134+ $ operation = null ;
135+ try {
136+ $ resourceMetadataCollection = $ this ->resourceMetadataCollectionFactory ->create ($ resourceClass );
137+ $ operation = $ resourceMetadataCollection ->getOperation ();
138+ } catch (ResourceClassNotFoundException |OperationNotFoundException ) {
139+ }
140+ /** @var Query $enumOperation */
141+ $ enumOperation = (new Query ())
142+ ->withClass ($ resourceClass )
143+ ->withShortName ($ operation ?->getShortName() ?? (new \ReflectionClass ($ resourceClass ))->getShortName ())
144+ ->withDescription ($ operation ?->getDescription());
145+
146+ return $ this ->typeBuilder ->getEnumType ($ enumOperation );
147+ }
148+ }
149+
152150 return null ;
153151 }
154152
0 commit comments