diff --git a/src/Appwrite/GraphQL/Resolvers.php b/src/Appwrite/GraphQL/Resolvers.php index b4c6986020..0f8c663a52 100644 --- a/src/Appwrite/GraphQL/Resolvers.php +++ b/src/Appwrite/GraphQL/Resolvers.php @@ -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); } diff --git a/src/Appwrite/GraphQL/SchemaBuilder.php b/src/Appwrite/GraphQL/SchemaBuilder.php index fd278c8d28..e03ae5720b 100644 --- a/src/Appwrite/GraphQL/SchemaBuilder.php +++ b/src/Appwrite/GraphQL/SchemaBuilder.php @@ -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, diff --git a/tests/e2e/Services/GraphQL/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/DatabaseServerTest.php index 5e805df065..d42309d05b 100644 --- a/tests/e2e/Services/GraphQL/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/DatabaseServerTest.php @@ -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']); -// } }