Fix custom entity delete
This commit is contained in:
parent
8cd36b2721
commit
6e4bad5969
3 changed files with 30 additions and 33 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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']);
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue