From 6c81069b27e88d22c1e867d4f32260e2a0fc6f0c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 29 Sep 2022 17:51:53 +1300 Subject: [PATCH] Custom type serialization fixes --- src/Appwrite/GraphQL/Types/InputFile.php | 2 +- src/Appwrite/GraphQL/Types/Json.php | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/GraphQL/Types/InputFile.php b/src/Appwrite/GraphQL/Types/InputFile.php index 17ee6a0061..c10591ef57 100644 --- a/src/Appwrite/GraphQL/Types/InputFile.php +++ b/src/Appwrite/GraphQL/Types/InputFile.php @@ -16,7 +16,7 @@ class InputFile extends ScalarType public function serialize($value) { - throw new InvariantViolation('`InputFile` cannot be serialized'); + return ''; } public function parseValue($value) diff --git a/src/Appwrite/GraphQL/Types/Json.php b/src/Appwrite/GraphQL/Types/Json.php index c430543c9b..2ebf2d39b0 100644 --- a/src/Appwrite/GraphQL/Types/Json.php +++ b/src/Appwrite/GraphQL/Types/Json.php @@ -21,12 +21,12 @@ class Json extends ScalarType public function serialize($value) { - return $this->identity($value); + return \json_encode($value); } public function parseValue($value) { - return $this->identity($value); + return \json_decode($value, associative: true); } public function parseLiteral(Node $valueNode, ?array $variables = null) @@ -51,9 +51,4 @@ class Json extends ScalarType return null; } } - - private function identity($value) - { - return $value; - } }