Skip to content

Commit 78ba78c

Browse files
committed
Fix extendability of schema
1 parent ae58a6e commit 78ba78c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/FederatedSchemaTrait.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,24 @@ protected function resolve($root, $args, $context, $info): array
166166
}, $args[FederatedSchema::RESERVED_FIELD_REPRESENTATIONS]);
167167
}
168168

169+
/**
170+
* @param array<string,mixed> $config
171+
*
172+
* @return array<Type>
173+
*/
174+
protected function extractExtraTypes(array $config): array
175+
{
176+
$typeMap = [];
177+
$configTypes = $config['types'] ?? [];
178+
if (\is_array($configTypes)) {
179+
$typeMap = $configTypes;
180+
} elseif (\is_callable($configTypes)) {
181+
$typeMap = $configTypes();
182+
}
183+
184+
return $typeMap;
185+
}
186+
169187
/**
170188
* @param array<string,mixed> $config
171189
*
@@ -192,17 +210,8 @@ protected function extractEntityTypes(array $config): array
192210
*/
193211
protected function extractSchemaExtensionTypes(array $config): array
194212
{
195-
$typeMap = [];
196-
$configTypes = $config['types'] ?? [];
197-
if (\is_array($configTypes)) {
198-
$typeMap = $configTypes;
199-
} elseif (\is_callable($configTypes)) {
200-
$typeMap = $configTypes();
201-
}
202-
203213
$types = [];
204-
205-
foreach ($typeMap as $type) {
214+
foreach ($this->extractExtraTypes($config) as $type) {
206215
if ($type instanceof SchemaExtensionType) {
207216
$types[$type->name] = $type;
208217
}

0 commit comments

Comments
 (0)