-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Newtonsoft Support Within Consideration/Scope? #56
Comments
I was thinking about it initially but decided there was no point in it. System.Json is faster and already "installed" in net6.0+ projects. To make it work, it is not enough to replace the attribute. You have to rewrite the custom serializes for scalar and supported built-in types. Incorporate new options into the source generator. Figured out how to cover all scenarios in the integration tests. I would say a big chunk of work. What raises the question of what benefits it would bring? Performance? No. Ease of use? They are pretty much the same in most scenarios. Compatibility? System.Text.Json works on netstandard. The only thing I can see is eliminating the dependency on System.Text.Json, which can be useful for projects already using Newtosoft. At the same time, the best path forward is to use a built-in serializer. So, from my perspective, there is no point to invest time in it. |
I don't get it. Why would you need to configure anything to work with the ZeroQL client? Everything happens under the hood and doesn't require any intervention from the developer side. |
Oh totally agree with you; getting the data from the ZeroQL client works like a charm. This is for when I am trying to return a ZeroQL model out of the controller. For example: public async Task<IActionResult> Get()
{
var response = await GQLClient.Query(...)
return Ok(response.Data)
} Which works just fine when I remove the Hence my attempts to configure which controllers used which serializers. Thankfully I found another approach that works for my situation.
Got yeah! I appreciate you taking the time to read and share your thoughts. |
Is your feature request related to a problem? Please describe.
I am working with an ASP.NET project that is using newtonsoft for serialization for controllers. However the code generated by ZeroQL is built for System.Text.Json (e.g. the JsonPropertyName attributes). Apologies if this is already possible; my check of the documentation and thumbing through of GenerateCommand.cs did not yield results.
Like all projects, this one has to decide what is within scope and out of scope; and so I wanted to see if Newtonsoft support was within scope of ZeroQL
Describe the solution you'd like
For usage, the simplest approach I could think of is some option on generate command to configure using Newtonsoft vs System.Text.Json. Maybe some sort of flag like --serializer="Newtonsoft" vs --seralizer="System.Text.Json", with it defaulting to System.Text.Json if the flag is not specified. (and a similar approach for the
zeroql.json
file)Describe alternatives you've considered
I am trying to configure the ASP.NET project to use one serializer or another depending on the controller; this appears to be possible but also appears to be very difficult - I've yet to get it to work. Other alternatives are being considered but they all feel quite clunky and undesirable.
Additional context
This is very much asked in the spirit of "if you never ask, the answer is always no". If this support is not within consideration at this time, no worries!
The text was updated successfully, but these errors were encountered: