Skip to content

Commit 0d6d954

Browse files
committed
Working on fields order in inheritance
When using some UIs like GraphiQL, field order can be relevant for the end user. This PR changes field order so that fields from the most parent class are displayed before fields from child classes.
1 parent 5e182bf commit 0d6d954

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Types/TypeAnnotatedObjectType.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public static function createFromAnnotatedClass(string $typeName, string $classN
4343
$fields = $fieldProvider->getSelfFields($className);
4444
}
4545
if ($parentType !== null) {
46-
// Note: with +=, the keys already present are not overloaded
47-
$fields += $parentType->getFields();
46+
$finalFields = $parentType->getFields();
47+
foreach ($fields as $name => $field) {
48+
$finalFields[$name] = $field;
49+
}
50+
return $finalFields;
4851
}
4952
return $fields;
5053
},

0 commit comments

Comments
 (0)