diff --git a/src/Appwrite/GraphQL/SchemaBuilder.php b/src/Appwrite/GraphQL/SchemaBuilder.php index b349ebf2bb..fa3e5ba5cf 100644 --- a/src/Appwrite/GraphQL/SchemaBuilder.php +++ b/src/Appwrite/GraphQL/SchemaBuilder.php @@ -216,7 +216,8 @@ class SchemaBuilder $dbForProject, $databaseId, $collectionId - ) + ), + 'complexity' => fn (int $complexity, array $args) => $complexity * $args['limit'], ]; $mutationFields[$collectionId . 'Create'] = [ 'type' => $objectType, diff --git a/tests/e2e/Services/GraphQL/GraphQLAbuseTest.php b/tests/e2e/Services/GraphQL/GraphQLAbuseTest.php index ca66677e63..826cd7f33a 100644 --- a/tests/e2e/Services/GraphQL/GraphQLAbuseTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLAbuseTest.php @@ -43,9 +43,9 @@ class GraphQLAbuseTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - \var_dump($response); + $max = App::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', 50); - $this->assertEquals('Too many queries.', $response['body']['message']); + $this->assertEquals('Max query complexity should be ' . $max . ' but got 51.', $response['body']['errors'][0]['message']); } public function testTooManyQueriesBlocked() diff --git a/tests/e2e/Services/GraphQL/GraphQLBase.php b/tests/e2e/Services/GraphQL/GraphQLBase.php index fa5f5198d2..22fe55274b 100644 --- a/tests/e2e/Services/GraphQL/GraphQLBase.php +++ b/tests/e2e/Services/GraphQL/GraphQLBase.php @@ -1356,8 +1356,58 @@ trait GraphQLBase } databasesCreateCollection(databaseId: $databaseId, collectionId: $collectionId, name: $collectionName, permission: $collectionPermission, read: $collectionRead, write: $collectionWrite) { _id + _createdAt + _updatedAt + _read + _write + databaseId name permission + attributes { + key + type + status + } + indexes { + key + type + status + } + } + databasesCreateStringAttribute(databaseId: $databaseId, collectionId: $collectionId, key: "name", size: 255, required: true) { + key + type + status + size + required + default + array + } + databasesCreateIntegerAttribute(databaseId: $databaseId, collectionId: $collectionId, key: "age", min: 0, max: 150, required: true) { + key + type + status + required + min + max + default + array + } + usersCreate(userId: "unique()", email: "test1@appwrite.io", password: "password", name: "Tester 1") { + _id + _createdAt + _updatedAt + name + registration + status + passwordUpdate + email + emailVerification + phone + phoneVerification + prefs { + data + } } }'; }