1
0
Fork 0
mirror of synced 2024-07-07 23:46:11 +12:00

Custom type serialization fixes

This commit is contained in:
Jake Barnby 2022-09-29 17:51:53 +13:00
parent 471f12b8ba
commit 6c81069b27
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 3 additions and 8 deletions

View file

@ -16,7 +16,7 @@ class InputFile extends ScalarType
public function serialize($value)
{
throw new InvariantViolation('`InputFile` cannot be serialized');
return '';
}
public function parseValue($value)

View file

@ -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;
}
}