From 902a6f3076211d93f5a9b9373afeea2155f5f3f5 Mon Sep 17 00:00:00 2001 From: mauriau Date: Tue, 17 Dec 2024 17:23:46 +0100 Subject: [PATCH] feat(graphql): add configuration on laravel, for max query depth and max query complexity --- src/Laravel/ApiPlatformProvider.php | 2 +- src/Laravel/config/api-platform.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Laravel/ApiPlatformProvider.php b/src/Laravel/ApiPlatformProvider.php index a13fb63b0e..fe9123da09 100644 --- a/src/Laravel/ApiPlatformProvider.php +++ b/src/Laravel/ApiPlatformProvider.php @@ -1294,7 +1294,7 @@ private function registerGraphQl(Application $app): void /** @var ConfigRepository */ $config = $app['config']; - return new Executor($config->get('api-platform.graphql.introspection.enabled') ?? false); + return new Executor($config->get('api-platform.graphql.introspection.enabled') ?? false, $config->get('api-platform.graphql.max_query_complexity'), $config->get('api-platform.graphql.max_query_depth')); }); $app->singleton(GraphiQlController::class, function (Application $app) { diff --git a/src/Laravel/config/api-platform.php b/src/Laravel/config/api-platform.php index f24a85a9a1..6056db6303 100644 --- a/src/Laravel/config/api-platform.php +++ b/src/Laravel/config/api-platform.php @@ -62,7 +62,9 @@ 'graphql' => [ 'enabled' => false, 'nesting_separator' => '__', - 'introspection' => ['enabled' => true] + 'introspection' => ['enabled' => true], + 'max_query_complexity' => 500, + 'max_query_depth' => 200 ], 'exception_to_status' => [