serializeSafe method

Object? serializeSafe(
  1. Object? value, {
  2. bool nested = true,
})
inherited

Implementation

Serialized serializeSafe(Object? value, {bool nested = true}) {
  if (value is Serialized &&
      (!nested || value is! Map && value is! List || value is! Value)) {
    return value;
  } else if (value is! Value) {
    throw GraphQLException([
      GraphQLError(
        'Cannot convert value $value (${value.runtimeType}) of $Value'
        ' to type $Serialized. In $name ($runtimeType)',
      ),
    ]);
  } else {
    return serialize(value);
  }
}