From 56077d59f72398369dda3771f23a3f8fb0cd3d31 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 6 May 2025 10:51:11 +0530 Subject: [PATCH] fix: graphql tests. --- app/init/resources.php | 8 ++-- src/Appwrite/GraphQL/Types/Mapper.php | 26 ++++++------- .../Modules/Databases/Http/Tables/XList.php | 2 +- .../Request/Filters/DatabaseAliases.php | 3 +- tests/e2e/Services/GraphQL/Base.php | 38 +++++++++---------- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/app/init/resources.php b/app/init/resources.php index 3a1539e59b..7657b9ea69 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -721,8 +721,8 @@ App::setResource('schema', function ($utopia, $dbForProject) { // Order must be the same as the route params return [ 'databaseId' => $databaseId, - 'documentId' => $id, - 'collectionId' => $collectionId, + 'rowId' => $id, + 'tableId' => $collectionId, 'data' => $args, 'permissions' => $permissions, ]; @@ -737,8 +737,8 @@ App::setResource('schema', function ($utopia, $dbForProject) { // Order must be the same as the route params return [ 'databaseId' => $databaseId, - 'collectionId' => $collectionId, - 'documentId' => $documentId, + 'tableId' => $collectionId, + 'rowId' => $documentId, 'data' => $args, 'permissions' => $permissions, ]; diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index e5056d0abc..8cfad823af 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -418,8 +418,8 @@ class Mapper // TODO: Find a better way to do this switch ($name) { - case 'Attributes': - return static::getAttributeImplementation($object); + case 'Columns': + return static::getColumnImplementation($object); case 'HashOptions': return static::getHashOptionsImplementation($object); } @@ -427,29 +427,29 @@ class Mapper throw new Exception('Unknown union type: ' . $name); } - private static function getAttributeImplementation(array $object): Type + private static function getColumnImplementation(array $object): Type { switch ($object['type']) { case 'string': return match ($object['format'] ?? '') { - 'email' => static::model('AttributeEmail'), - 'url' => static::model('AttributeUrl'), - 'ip' => static::model('AttributeIp'), - default => static::model('AttributeString'), + 'email' => static::model('ColumnEmail'), + 'url' => static::model('ColumnUrl'), + 'ip' => static::model('ColumnIp'), + default => static::model('ColumnString'), }; case 'integer': - return static::model('AttributeInteger'); + return static::model('ColumnInteger'); case 'double': - return static::model('AttributeFloat'); + return static::model('ColumnFloat'); case 'boolean': - return static::model('AttributeBoolean'); + return static::model('ColumnBoolean'); case 'datetime': - return static::model('AttributeDatetime'); + return static::model('ColumnDatetime'); case 'relationship': - return static::model('AttributeRelationship'); + return static::model('ColumnRelationship'); } - throw new Exception('Unknown attribute implementation'); + throw new Exception('Unknown column implementation'); } private static function getHashOptionsImplementation(array $object): Type diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Tables/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Tables/XList.php index 86107cc533..055102415d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Tables/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Tables/XList.php @@ -49,7 +49,7 @@ class XList extends Action responses: [ new SDKResponse( code: SwooleResponse::STATUS_CODE_OK, - model: UtopiaResponse::MODEL_TABLE, + model: UtopiaResponse::MODEL_TABLE_LIST, ) ], contentType: ContentType::JSON diff --git a/src/Appwrite/Utopia/Request/Filters/DatabaseAliases.php b/src/Appwrite/Utopia/Request/Filters/DatabaseAliases.php index b2b772be11..0ee2754475 100644 --- a/src/Appwrite/Utopia/Request/Filters/DatabaseAliases.php +++ b/src/Appwrite/Utopia/Request/Filters/DatabaseAliases.php @@ -12,7 +12,8 @@ class DatabaseAliases extends Filter 'attributes' => 'columns', 'collectionId' => 'tableId', 'attributeId' => 'columnId', - 'relatedCollectionId' => 'relatedTableId' + 'relatedCollection' => 'relatedTable', + 'relatedCollectionId' => 'relatedTableId', ]; public function parse(array $content, string $model): array diff --git a/tests/e2e/Services/GraphQL/Base.php b/tests/e2e/Services/GraphQL/Base.php index 95f446cf6f..7c91cf67f7 100644 --- a/tests/e2e/Services/GraphQL/Base.php +++ b/tests/e2e/Services/GraphQL/Base.php @@ -259,8 +259,8 @@ trait Base // Fragments public static string $FRAGMENT_COLUMNS = ' - fragment attributeProperties on Attributes { - ... on AttributeString { + fragment columnProperties on Columns { + ... on ColumnString { key required array @@ -268,7 +268,7 @@ trait Base default size } - ... on AttributeInteger { + ... on ColumnInteger { key required array @@ -277,7 +277,7 @@ trait Base intMin: min intMax: max } - ... on AttributeFloat { + ... on ColumnFloat { key required array @@ -286,35 +286,35 @@ trait Base floatMin: min floatMax: max } - ... on AttributeBoolean { + ... on ColumnBoolean { key required array status boolDefault:default } - ... on AttributeUrl { + ... on ColumnUrl { key required array status default } - ... on AttributeEmail { + ... on ColumnEmail { key required array status default } - ... on AttributeIp { + ... on ColumnIp { key required array status default } - ... on AttributeEnum { + ... on ColumnEnum { key required array @@ -322,7 +322,7 @@ trait Base default elements } - ... on AttributeDatetime { + ... on ColumnDatetime { key required array @@ -406,7 +406,7 @@ trait Base return 'query listTables($databaseId: String!) { databasesListTables(databaseId: $databaseId) { total - collections { + tables { _id _permissions documentSecurity @@ -527,7 +527,7 @@ trait Base case self::$CREATE_RELATIONSHIP_COLUMN: return 'mutation createRelationshipColumn($databaseId: String!, $tableId: String!, $relatedTableId: String!, $type: String!, $twoWay: Boolean, $key: String, $twoWayKey: String, $onDelete: String){ databasesCreateRelationshipColumn(databaseId: $databaseId, tableId: $tableId, relatedTableId: $relatedTableId, type: $type, twoWay: $twoWay, key: $key, twoWayKey: $twoWayKey, onDelete: $onDelete) { - relatedCollection + relatedTable relationType twoWay key @@ -606,7 +606,7 @@ trait Base case self::$UPDATE_RELATIONSHIP_COLUMN: return 'mutation updateRelationshipColumn($databaseId: String!, $tableId: String!, $key: String!, $onDelete: String){ databasesUpdateRelationshipColumn(databaseId: $databaseId, tableId: $tableId, key: $key, onDelete: $onDelete) { - relatedCollection + relatedTable relationType twoWay key @@ -651,15 +651,15 @@ trait Base return 'query listColumns($databaseId: String!, $tableId: String!) { databasesListColumns(databaseId: $databaseId, tableId: $tableId) { total - attributes { - ...attributeProperties + columns { + ...columnProperties } } }' . PHP_EOL . self::$FRAGMENT_COLUMNS; case self::$GET_COLUMN: return 'query getColumn($databaseId: String!, $tableId: String!, $key: String!) { databasesGetColumn(databaseId: $databaseId, tableId: $tableId, key: $key) { - ...attributeProperties + ...columnProperties } }' . PHP_EOL . self::$FRAGMENT_COLUMNS; case self::$DELETE_COLUMN: @@ -681,7 +681,7 @@ trait Base return 'query listRows($databaseId: String!, $tableId: String!){ databasesListRows(databaseId: $databaseId, tableId: $tableId) { total - documents { + rows { _id _collectionId _permissions @@ -2259,8 +2259,8 @@ trait Base _databaseId name documentSecurity - attributes { - ...attributeProperties + columns { + ...columnProperties } indexes { key