fix: graphql tests.

This commit is contained in:
Darshan
2025-05-06 10:51:11 +05:30
parent 565e6b2ad8
commit 56077d59f7
5 changed files with 39 additions and 38 deletions
+4 -4
View File
@@ -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,
];
+13 -13
View File
@@ -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
@@ -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
@@ -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
+19 -19
View File
@@ -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