From f19dd9446f5722d243e82b1e7bc34ebdab95719d Mon Sep 17 00:00:00 2001 From: Amer Chaudhary Date: Fri, 22 Nov 2024 13:05:33 +0500 Subject: [PATCH] fix(laravel): graphQl type locator indexes (#6815) --- src/Laravel/ApiPlatformProvider.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Laravel/ApiPlatformProvider.php b/src/Laravel/ApiPlatformProvider.php index 1eda99340b..5d9e6906f5 100644 --- a/src/Laravel/ApiPlatformProvider.php +++ b/src/Laravel/ApiPlatformProvider.php @@ -1135,14 +1135,18 @@ private function registerGraphQl(Application $app): void $app->singleton('api_platform.graphql.type_locator', function (Application $app) { $tagged = iterator_to_array($app->tagged('api_platform.graphql.type')); + $services = []; + foreach ($tagged as $service) { + $services[$service->name] = $service; + } - return new ServiceLocator($tagged); + return new ServiceLocator($services); }); $app->singleton(TypesFactoryInterface::class, function (Application $app) { $tagged = iterator_to_array($app->tagged('api_platform.graphql.type')); - return new TypesFactory($app->make('api_platform.graphql.type_locator'), array_keys($tagged)); + return new TypesFactory($app->make('api_platform.graphql.type_locator'), array_column($tagged, 'name')); }); $app->singleton(TypesContainerInterface::class, function () { return new TypesContainer();