@@ -70,28 +70,7 @@ public function convertType(Type $type, bool $input, Operation $rootOperation, s
70
70
return GraphQLType::string ();
71
71
}
72
72
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 );
95
74
default :
96
75
return null ;
97
76
}
@@ -149,6 +128,25 @@ private function getResourceType(Type $type, bool $input, Operation $rootOperati
149
128
}
150
129
151
130
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
+
152
150
return null ;
153
151
}
154
152
0 commit comments