From 44e4f1e05bcced2400f9301b6c4bc91694f0edc9 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 14 Oct 2022 13:18:08 +1300 Subject: [PATCH] Make param errors consistent --- app/config/errors.php | 2 +- app/controllers/api/graphql.php | 2 +- tests/e2e/Services/GraphQL/ContentTypeTest.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index da69798906..6e14716cb9 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -551,7 +551,7 @@ return [ ], Exception::GRAPHQL_NO_QUERY => [ 'name' => Exception::GRAPHQL_NO_QUERY, - 'description' => 'No query passed in the request.', + 'description' => 'Param "query" is not optional.', 'code' => 400, ], Exception::GRAPHQL_INVALID_QUERY => [ diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 16f39c83c0..d370a4e988 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -104,7 +104,7 @@ function executeRequest( } foreach ($query as $item) { if (empty($item['query'])) { - throw new Exception(Exception::GRAPHQL_INVALID_QUERY); + throw new Exception(Exception::GRAPHQL_NO_QUERY); } } diff --git a/tests/e2e/Services/GraphQL/ContentTypeTest.php b/tests/e2e/Services/GraphQL/ContentTypeTest.php index bd9b097746..d6675374e7 100644 --- a/tests/e2e/Services/GraphQL/ContentTypeTest.php +++ b/tests/e2e/Services/GraphQL/ContentTypeTest.php @@ -162,7 +162,7 @@ class ContentTypeTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders())); - $this->assertEquals('No query passed in the request.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } public function testPostEmptyBody() @@ -173,7 +173,7 @@ class ContentTypeTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), []); - $this->assertEquals('No query passed in the request.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } public function testPostRandomBody() @@ -184,7 +184,7 @@ class ContentTypeTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), ['foo' => 'bar']); - $this->assertEquals('Invalid query.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } public function testGetNoQuery() @@ -195,7 +195,7 @@ class ContentTypeTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders())); - $this->assertEquals('No query passed in the request.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } public function testGetEmptyQuery() @@ -206,17 +206,17 @@ class ContentTypeTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders())); - $this->assertEquals('Invalid query.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } public function testGetRandomParameters() { $projectId = $this->getProject()['$id']; - $response = $this->client->call(Client::METHOD_POST, '/graphql?random=random', \array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/graphql?random=random', \array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, ], $this->getHeaders())); - $this->assertEquals('No query passed in the request.', $response['body']['message']); + $this->assertEquals('Param "query" is not optional.', $response['body']['message']); } }