1
0
Fork 0
mirror of synced 2024-10-05 12:43:13 +13:00

Fix custom entity delete

This commit is contained in:
Jake Barnby 2022-09-23 13:46:39 +12:00
parent 8cd36b2721
commit 6e4bad5969
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 30 additions and 33 deletions

View file

@ -254,14 +254,12 @@ class Resolvers
$request = $utopia->getResource('request', true);
$response = $utopia->getResource('response', true);
$swoole = $request->getSwoole();
$swoole->post = [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'documentId' => $args['id'],
];
$documentId = $args['id'];
$swoole->server['request_method'] = 'DELETE';
$swoole->server['request_uri'] = "/v1/databases/$databaseId/collections/$collectionId/documents/{$args['id']}";
$swoole->server['path_info'] = "/v1/databases/$databaseId/collections/$collectionId/documents/{$args['id']}";
$swoole->server['request_uri'] = "/v1/databases/$databaseId/collections/$collectionId/documents/$documentId";
$swoole->server['path_info'] = "/v1/databases/$databaseId/collections/$collectionId/documents/$documentId";
self::resolve($utopia, $request, $response, $resolve, $reject);
}

View file

@ -288,7 +288,7 @@ class SchemaBuilder
)
];
$mutationFields[$collectionId . 'Delete'] = [
'type' => $objectType,
'type' => TypeRegistry::get(Response::MODEL_NONE),
'args' => TypeRegistry::argumentsFor('id'),
'resolve' => Resolvers::resolveDocumentDelete(
$utopia,

View file

@ -942,15 +942,36 @@ class DatabaseServerTest extends Scope
$this->assertEquals(204, $document['headers']['status-code']);
}
/**
* @depends testCreateCustomEntity
* @throws Exception
*/
public function testDeleteCustomEntity(array $data)
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$DELETE_CUSTOM_ENTITY);
$gqlPayload = [
'query' => $query,
'variables' => [
'id' => $data['_id'],
]
];
$entity = $this->client->call(Client::METHOD_POST, '/graphql', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertIsNotArray($entity['body']);
$this->assertEquals(204, $entity['headers']['status-code']);
}
/**
* @depends testCreateStringAttribute
* @throws Exception
*/
public function testDeleteAttribute($data): void
{
// Wait for attributes to be available
sleep(3);
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$DELETE_ATTRIBUTE);
$gqlPayload = [
@ -1020,26 +1041,4 @@ class DatabaseServerTest extends Scope
$this->assertEquals(204, $database['headers']['status-code']);
}
// /**
// * @depends testCreateCustomEntity
// * @throws Exception
// */
// public function testDeleteCustomEntity(array $data) {
// $projectId = $this->getProject()['$id'];
// $query = $this->getQuery(self::$DELETE_CUSTOM_ENTITY);
// $gqlPayload = [
// 'query' => $query,
// 'variables' => [
// 'id' => $data['_id'],
// ]
// ];
//
// $entity = $this->client->call(Client::METHOD_POST, '/graphql', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $projectId,
// ], $this->getHeaders()), $gqlPayload);
//
// $this->assertIsNotArray($entity['body']);
// $this->assertEquals(204, $entity['headers']['status-code']);
// }
}