1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00

Merge pull request #5090 from appwrite/sync-1.2.x

Sync 1.2.x
This commit is contained in:
Torsten Dittmann 2023-02-07 19:27:50 +01:00 committed by GitHub
commit 799c527661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 7 deletions

View file

@ -1,3 +1,7 @@
## 7.2.0
* Support for GraphQL
## 7.1.0
* Role helper update

View file

@ -1,3 +1,7 @@
## 8.2.0
* Support for GraphQL
## 8.1.0
* Role helper update

View file

@ -291,13 +291,7 @@ class Resolvers
return;
}
foreach ($payload as $key => $value) {
if (\str_starts_with($key, '$')) {
$escapedKey = \str_replace('$', '_', $key);
$payload[$escapedKey] = $value;
unset($payload[$key]);
}
}
$payload = self::escapePayload($payload, 1);
if ($beforeResolve) {
$payload = $beforeResolve($payload);
@ -305,4 +299,25 @@ class Resolvers
$resolve($payload);
}
private static function escapePayload(array $payload, int $depth)
{
if ($depth > App::getEnv('_APP_GRAPHQL_MAX_DEPTH', 3)) {
return;
}
foreach ($payload as $key => $value) {
if (\str_starts_with($key, '$')) {
$escapedKey = \str_replace('$', '_', $key);
$payload[$escapedKey] = $value;
unset($payload[$key]);
}
if (\is_array($value)) {
$payload[$key] = self::escapePayload($value, $depth + 1);
}
}
return $payload;
}
}