graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Remove `IsValueType` check from `AnyType.TrySerialize` method

Open EvilVir opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Product

Hot Chocolate

Describe the bug

AnyType can be expanded by using custom ChangeTypeProviders but ONLY if type to be converted is ValueType. Which is artificial limitation. Expanding AnyType to handle types like Encoding, CultureInfo, TimeZoneInfo, Uri, which have standarized string representations, is currently impossible due to that IsValueType check.

Steps to reproduce

  1. Create output type that has object property marked as GraphQLType<AnyType>.
  2. Assign TimeZoneInfo or other non-value type instance to that property.
  3. Write and register custom ChangeTypeProvider that is able to serialize and deserialize TimeZoneInfo to and from string.
  4. Run the query - despite propert converter registered object will be returned as serialized dictionary rather than string.

Relevant log output

No response

Additional Context?

No response

Version

13.1.0

EvilVir avatar May 24 '23 17:05 EvilVir