You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an app which stores Json blob data in a database. I want essentially an "AnyType" field on my schema, where the actual json data is returned as a part of the result, rather than as an escaped string that then needs to be parsed in my Javascript client.
Currently I achieve this by reading the database field as a string, parsing into a JsonDocument, which I wrap with a custom IReadOnlyDictionary<string, object?> implementation allowing the HotChocolate serializer to walk the JsonDocument serializing as name value pairs, in a way that I think is somewhat more efficient than actually materializing the blob as a dictionary of scalars & child dictionaries.
In a world of REST controllers, I believe I could do something like
which would remove the need to deserialize and then re-serialize entirely.
The solution you'd like
It would be great if a similar concept was possible with HotChocolate, where you could have a JsonStringType type which is essentially a string wrapper, which then just writes using WriteRawValue on the Utf8JsonWriter, or something along those lines.
Product
Hot Chocolate
The text was updated successfully, but these errors were encountered:
We have this on the list for 13. We are thinking to base it on the JsonToken type of System.Text.Json. Implementation wise we have not decided really how we go about it but something in this direction will come.
Is your feature request related to a problem?
I have an app which stores Json blob data in a database. I want essentially an "AnyType" field on my schema, where the actual json data is returned as a part of the result, rather than as an escaped string that then needs to be parsed in my Javascript client.
Currently I achieve this by reading the database field as a string, parsing into a JsonDocument, which I wrap with a custom IReadOnlyDictionary<string, object?> implementation allowing the HotChocolate serializer to walk the JsonDocument serializing as name value pairs, in a way that I think is somewhat more efficient than actually materializing the blob as a dictionary of scalars & child dictionaries.
In a world of REST controllers, I believe I could do something like
return new ContentResult { Content = myJsonString, ContentType = "application/json" };
which would remove the need to deserialize and then re-serialize entirely.
The solution you'd like
It would be great if a similar concept was possible with HotChocolate, where you could have a JsonStringType type which is essentially a string wrapper, which then just writes using WriteRawValue on the Utf8JsonWriter, or something along those lines.
Product
Hot Chocolate
The text was updated successfully, but these errors were encountered: