@@ -68,21 +68,26 @@ private function resolve(ResolveInfo $info): Promise
68
68
{
69
69
$ type = $ info ->returnType ;
70
70
71
+ $ this ->prepareTypeResolver ($ type );
72
+
73
+ $ promise = $ this ->delegatedPromises [$ info ->operation ];
74
+
75
+ return $ promise ->then (fn (ExecutionResult $ result ) => $ this ->accessResultByPath ($ info ->path , $ result ));
76
+ }
77
+
78
+ private function prepareTypeResolver (Type $ type ): void
79
+ {
71
80
if ($ type instanceof WrappingType) {
72
81
$ type = $ type ->getInnermostType ();
73
82
}
74
83
75
84
if ($ type instanceof AbstractType) {
76
- $ type ->config ['resolveType ' ] ?? = $ this ->resolveAbstractType (...);
85
+ $ type ->config ['resolveType ' ] = $ this ->resolveAbstractType (...);
77
86
}
78
87
79
88
if ($ type instanceof ObjectType) {
80
- $ type ->resolveFieldFn ?? = $ this ->resolveObjectFields (...);
89
+ $ type ->resolveFieldFn = $ this ->resolveObjectFields (...);
81
90
}
82
-
83
- $ promise = $ this ->delegatedPromises [$ info ->operation ];
84
-
85
- return $ promise ->then (fn (ExecutionResult $ result ) => $ this ->accessResultByPath ($ info ->path , $ result ));
86
91
}
87
92
88
93
private function resolveAbstractType (array $ value , mixed $ context , ResolveInfo $ info ): Type
@@ -105,9 +110,7 @@ private function resolveAbstractType(array $value, mixed $context, ResolveInfo $
105
110
106
111
$ implType = $ info ->schema ->getType ($ typename );
107
112
108
- if ($ implType instanceof ObjectType) {
109
- $ implType ->resolveFieldFn = $ this ->resolveObjectFields (...);
110
- }
113
+ $ this ->prepareTypeResolver ($ implType );
111
114
112
115
/// If impl type is not object, executor should throw error.
113
116
return $ implType ;
0 commit comments