@@ -217,11 +217,11 @@ protected function buildTypeReferenceMap(array $types) {
217217 */
218218 protected function buildFieldAssociationMap (FieldPluginManager $ manager , $ types ) {
219219 $ definitions = $ manager ->getDefinitions ();
220- $ fields = array_reduce (array_keys ($ definitions ), function ($ carry , $ id ) use ($ definitions ) {
220+ $ fields = array_reduce (array_keys ($ definitions ), function ($ carry , $ id ) use ($ definitions, $ types ) {
221221 $ current = $ definitions [$ id ];
222222 $ parents = $ current ['parents ' ] ?: ['Root ' ];
223223
224- return array_reduce ($ parents , function ($ carry , $ parent ) use ($ current , $ id ) {
224+ return array_reduce ($ parents , function ($ carry , $ parent ) use ($ current , $ id, $ types ) {
225225 // Allow plugins to define a different name for each parent.
226226 if (strpos ($ parent , ': ' ) !== FALSE ) {
227227 list ($ parent , $ name ) = explode (': ' , $ parent );
@@ -239,6 +239,28 @@ protected function buildFieldAssociationMap(FieldPluginManager $manager, $types)
239239 }, $ carry );
240240 }, []);
241241
242+ $ rename = [];
243+
244+ foreach ($ fields as $ parent => $ fieldList ) {
245+ foreach ($ fieldList as $ field => $ info ) {
246+ if (!array_key_exists ($ parent , $ types )) {
247+ continue ;
248+ }
249+ foreach ($ types [$ parent ]['definition ' ]['interfaces ' ] as $ interface ) {
250+ if (isset ($ fields [$ interface ][$ field ]) && $ definitions [$ fields [$ interface ][$ field ]['id ' ]]['type ' ] != $ definitions [$ info ['id ' ]]['type ' ]) {
251+ $ rename [$ parent ][$ field ] = TRUE ;
252+ }
253+ }
254+ }
255+ }
256+
257+ foreach ($ rename as $ parent => $ names ) {
258+ foreach (array_keys ($ names ) as $ name ) {
259+ $ fields [$ parent ][$ name . 'Of ' . $ parent ] = $ fields [$ parent ][$ name ];
260+ unset($ fields [$ parent ][$ name ]);
261+ }
262+ }
263+
242264 // Only return fields for types that are actually fieldable.
243265 $ fieldable = [GRAPHQL_TYPE_PLUGIN , GRAPHQL_INTERFACE_PLUGIN ];
244266 $ fields = array_intersect_key ($ fields , array_filter ($ types , function ($ type ) use ($ fieldable ) {
0 commit comments