From 0471bf1c905734c04273d6e267118f1ff6b63b2f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 29 Sep 2022 17:54:48 +1300 Subject: [PATCH] Only allow default values for optional params --- src/Appwrite/GraphQL/SchemaBuilder.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/GraphQL/SchemaBuilder.php b/src/Appwrite/GraphQL/SchemaBuilder.php index 28cd610c60..baaeb75418 100644 --- a/src/Appwrite/GraphQL/SchemaBuilder.php +++ b/src/Appwrite/GraphQL/SchemaBuilder.php @@ -133,21 +133,23 @@ class SchemaBuilder $params = []; $list = false; - foreach ($route->getParams() as $key => $value) { - if ($key === 'queries') { + foreach ($route->getParams() as $name => $parameter) { + if ($name === 'queries') { $list = true; } $argType = TypeMapper::fromRouteParameter( $utopia, - $value['validator'], - !$value['optional'], - $value['injections'] + $parameter['validator'], + !$parameter['optional'], + $parameter['injections'] ); - $params[$key] = [ + $params[$name] = [ 'type' => $argType, - 'description' => $value['description'], - 'defaultValue' => $value['default'] + 'description' => $parameter['description'], ]; + if ($parameter['optional']) { + $params[$name]['defaultValue'] = $parameter['default']; + } } $field = [