Address Comments

This commit is contained in:
Bradley Schofield 2025-01-16 14:34:53 +09:00
parent 4c22088146
commit 469732f482
5 changed files with 83 additions and 81 deletions

View file

@ -1128,3 +1128,8 @@ App::wildcard()
foreach (Config::getParam('services', []) as $service) {
include_once $service['controller'];
}
// Check for any errors found while we were initialising the SDK Methods.
if (!empty(Method::getErrors())) {
throw new \Exception('Errors found during SDK initialization:' . PHP_EOL . implode(PHP_EOL, Method::getErrors()));
}

View file

@ -2,7 +2,6 @@
require_once __DIR__ . '/../vendor/autoload.php';
use Appwrite\SDK\Method;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Swoole\Constant;
@ -336,9 +335,4 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
}
});
// Check for any errors found while we were initialising the SDK Methods.
if (!empty(Method::getErrors())) {
throw new \Exception('Errors found during SDK initialization:' . PHP_EOL . implode(PHP_EOL, Method::getErrors()));
}
$http->start();

122
composer.lock generated
View file

@ -709,16 +709,16 @@
},
{
"name": "google/protobuf",
"version": "v4.29.2",
"version": "v4.29.3",
"source": {
"type": "git",
"url": "https://github.com/protocolbuffers/protobuf-php.git",
"reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945"
"reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/79aa5014efeeec3d137df5cdb0ae2fc163953945",
"reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945",
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7",
"reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7",
"shasum": ""
},
"require": {
@ -747,9 +747,9 @@
"proto"
],
"support": {
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.2"
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.3"
},
"time": "2024-12-18T14:11:12+00:00"
"time": "2025-01-08T21:00:13+00:00"
},
{
"name": "jean85/pretty-package-versions",
@ -1237,16 +1237,16 @@
},
{
"name": "open-telemetry/api",
"version": "1.1.2",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/api.git",
"reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed"
"reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/api/zipball/04c85a1e41a3d59fa9bdc801a5de1df6624b95ed",
"reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed",
"url": "https://api.github.com/repos/opentelemetry-php/api/zipball/351a30baa79699de3de3a814c8ccc7b52ccdfb1d",
"reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d",
"shasum": ""
},
"require": {
@ -1303,7 +1303,7 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2024-11-16T04:32:30+00:00"
"time": "2025-01-08T23:50:34+00:00"
},
{
"name": "open-telemetry/context",
@ -1366,16 +1366,16 @@
},
{
"name": "open-telemetry/exporter-otlp",
"version": "1.1.0",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/exporter-otlp.git",
"reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18"
"reference": "243d9657c44a06f740cf384f486afe954c2b725f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/9b6de12204f25f8ab9540b46d6e7b5151897ce18",
"reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18",
"url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/243d9657c44a06f740cf384f486afe954c2b725f",
"reference": "243d9657c44a06f740cf384f486afe954c2b725f",
"shasum": ""
},
"require": {
@ -1426,20 +1426,20 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2024-04-30T18:28:30+00:00"
"time": "2025-01-08T23:50:03+00:00"
},
{
"name": "open-telemetry/gen-otlp-protobuf",
"version": "1.2.1",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git",
"reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d"
"reference": "585bafddd4ae6565de154610b10a787a455c9ba0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d",
"reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d",
"url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0",
"reference": "585bafddd4ae6565de154610b10a787a455c9ba0",
"shasum": ""
},
"require": {
@ -1489,20 +1489,20 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2024-10-30T11:49:49+00:00"
"time": "2025-01-15T23:07:07+00:00"
},
{
"name": "open-telemetry/sdk",
"version": "1.1.2",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/sdk.git",
"reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b"
"reference": "9a1c3b866239dbff291e5cc555bb7793eab08127"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/fb0ff8d8279a3776bd604791e2531dd0cc147e8b",
"reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b",
"url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/9a1c3b866239dbff291e5cc555bb7793eab08127",
"reference": "9a1c3b866239dbff291e5cc555bb7793eab08127",
"shasum": ""
},
"require": {
@ -1579,7 +1579,7 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2024-10-18T21:01:35+00:00"
"time": "2025-01-08T23:50:34+00:00"
},
{
"name": "open-telemetry/sem-conv",
@ -2453,16 +2453,16 @@
},
{
"name": "symfony/http-client",
"version": "v7.2.1",
"version": "v7.2.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
"reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e"
"reference": "339ba21476eb184290361542f732ad12c97591ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/ff4df2b68d1c67abb9fef146e6540ea16b58d99e",
"reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e",
"url": "https://api.github.com/repos/symfony/http-client/zipball/339ba21476eb184290361542f732ad12c97591ec",
"reference": "339ba21476eb184290361542f732ad12c97591ec",
"shasum": ""
},
"require": {
@ -2528,7 +2528,7 @@
"http"
],
"support": {
"source": "https://github.com/symfony/http-client/tree/v7.2.1"
"source": "https://github.com/symfony/http-client/tree/v7.2.2"
},
"funding": [
{
@ -2544,7 +2544,7 @@
"type": "tidelift"
}
],
"time": "2024-12-07T08:50:44+00:00"
"time": "2024-12-30T18:35:15+00:00"
},
{
"name": "symfony/http-client-contracts",
@ -3929,16 +3929,16 @@
},
{
"name": "utopia-php/migration",
"version": "0.6.13",
"version": "0.6.14",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "68d9b0a9477755afcda607e7e8109785cae17a13"
"reference": "59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/68d9b0a9477755afcda607e7e8109785cae17a13",
"reference": "68d9b0a9477755afcda607e7e8109785cae17a13",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2",
"reference": "59a19f09ded0ccab4c8cca35b1242c01e2b9cfd2",
"shasum": ""
},
"require": {
@ -3979,9 +3979,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/0.6.13"
"source": "https://github.com/utopia-php/migration/tree/0.6.14"
},
"time": "2024-11-26T13:57:53+00:00"
"time": "2025-01-08T01:07:25+00:00"
},
{
"name": "utopia-php/mongo",
@ -4095,16 +4095,16 @@
},
{
"name": "utopia-php/platform",
"version": "0.7.1",
"version": "0.7.2",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/platform.git",
"reference": "3433a0f1a54988f2a59c735f507745cb2c24638a"
"reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a",
"reference": "3433a0f1a54988f2a59c735f507745cb2c24638a",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf",
"reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf",
"shasum": ""
},
"require": {
@ -4139,9 +4139,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/platform/issues",
"source": "https://github.com/utopia-php/platform/tree/0.7.1"
"source": "https://github.com/utopia-php/platform/tree/0.7.2"
},
"time": "2024-10-22T10:27:49+00:00"
"time": "2025-01-15T05:56:26+00:00"
},
{
"name": "utopia-php/pools",
@ -4807,16 +4807,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.39.28",
"version": "0.39.29",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "6ff467858fe418e364460da905139216570a5d5e"
"reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6ff467858fe418e364460da905139216570a5d5e",
"reference": "6ff467858fe418e364460da905139216570a5d5e",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7",
"reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7",
"shasum": ""
},
"require": {
@ -4852,9 +4852,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.39.28"
"source": "https://github.com/appwrite/sdk-generator/tree/0.39.29"
},
"time": "2024-12-30T11:17:25+00:00"
"time": "2025-01-07T05:28:35+00:00"
},
{
"name": "doctrine/annotations",
@ -5126,16 +5126,16 @@
},
{
"name": "laravel/pint",
"version": "v1.19.0",
"version": "v1.20.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "8169513746e1bac70c85d6ea1524d9225d4886f0"
"reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0",
"reference": "8169513746e1bac70c85d6ea1524d9225d4886f0",
"url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b",
"reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b",
"shasum": ""
},
"require": {
@ -5188,7 +5188,7 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2024-12-30T16:20:10+00:00"
"time": "2025-01-14T16:20:53+00:00"
},
{
"name": "matthiasmullie/minify",
@ -7735,16 +7735,16 @@
},
{
"name": "symfony/finder",
"version": "v7.2.0",
"version": "v7.2.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49"
"reference": "87a71856f2f56e4100373e92529eed3171695cfb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49",
"reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49",
"url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb",
"reference": "87a71856f2f56e4100373e92529eed3171695cfb",
"shasum": ""
},
"require": {
@ -7779,7 +7779,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v7.2.0"
"source": "https://github.com/symfony/finder/tree/v7.2.2"
},
"funding": [
{
@ -7795,7 +7795,7 @@
"type": "tidelift"
}
],
"time": "2024-10-23T06:56:12+00:00"
"time": "2024-12-30T19:00:17+00:00"
},
{
"name": "symfony/options-resolver",

View file

@ -114,7 +114,7 @@ class Schema
$methodName = $method->getMethodName();
$name = $namespace . \ucfirst($methodName);
foreach (Mapper::route($utopia, $route, $complexity) as $field) {
foreach (Mapper::route($utopia, $route, $method, $complexity) as $field) {
switch ($route->getMethod()) {
case 'GET':
$queries[$name] = $field;

View file

@ -4,6 +4,7 @@ namespace Appwrite\GraphQL\Types;
use Appwrite\GraphQL\Resolvers;
use Appwrite\GraphQL\Types;
use Appwrite\SDK\Method;
use Exception;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
@ -78,6 +79,7 @@ class Mapper
public static function route(
App $utopia,
Route $route,
Method $method,
callable $complexity
): iterable {
foreach (self::$blacklist as $blacklist) {
@ -86,18 +88,7 @@ class Mapper
}
}
$sdk = $route->getLabel('sdk', false);
if (!$sdk) {
return;
}
if (is_array($sdk)) {
$sdk = $sdk[0];
}
/** @var \Appwrite\SDK\Method $sdk */
$responses = $sdk->getResponses() ?? [];
$responses = $method->getResponses() ?? [];
// If responses is an array, map each response to its model
if (\is_array($responses)) {
@ -126,13 +117,25 @@ class Mapper
$list = false;
foreach ($route->getParams() as $name => $parameter) {
$methodParameters = $method->getParameters();
if (!empty($methodParameters)) {
if (!array_key_exists($name, $methodParameters)) {
continue;
}
$optional = $methodParameters[$name]['optional'];
} else {
$optional = $parameter['optional'];
}
if ($name === 'queries') {
$list = true;
}
$parameterType = Mapper::param(
$utopia,
$parameter['validator'],
!$parameter['optional'],
!$optional,
$parameter['injections']
);
$params[$name] = [