-
Notifications
You must be signed in to change notification settings - Fork 164
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
Use buffer streams to solve the problem with synchronous reads. #733
base: master
Are you sure you want to change the base?
Use buffer streams to solve the problem with synchronous reads. #733
Conversation
I think that it would be better to rebase to |
I mean we dropped too much code from |
Here's what I'm gathering/thinking: Newtonsoft is synchronous instead of asynchronous, and For writing from Newtonsoft, we already have a As such, it seems to me that the immediate issue is really more of reading than writing for the current version of GraphQL server. If we do a fix for the current version, I might simply limit it to using For the next version of GraphQL, the serializers are in the main project. We should consider if we should use There is one final option for the next version -- remove both options above, and instead move the buffering code into the middleware. However, it should only be used for Newtonsoft, as System.Text.Json does not need any buffering. I'm not sure there is a clear answer here. The answer that works for the most situations is probably to implement |
System.Text.JSON is also synchronous. They just solved it in the API directly by using a in-memory buffer.
In ASP.NET Core they actually do both together. HttpResponseStreamReader + FileBufferingReadStream. I guess they just measured it and the original StreamReader was too slow. It is strange because StreamReader also has a buffer. My guess is that they wanted to use a bigger buffer, but the StreamReader does not use an ArrayPool and therefore they introduced a wrapper to reduce allocations.
Tried that, but does not build locally, because it is looking for preview packages in develop: Unable to find package GraphQL.DataLoader with version (>= 5.0.0-preview-476) |
You may download each preview version from here https://github.com/orgs/graphql-dotnet/packages?repo_name=graphql-dotnet |
@sungam3r I suggest we add a readonly property to |
It looks a bit weird to add properties like |
Let's decide if adding some type of property like // IGraphQLSerializer
bool IsNativelyAsync { get; }
// GraphQL.NewtonsoftJson
public IsNativelyAsync => false;
// GraphQL.SystemTextJson
public IsNativelyAsync => true; |
OK. Perhaps this is better than nothing. |
Hi, I copied the approach from ASP.NET Core Input and Output Formatter to solve the problem for synchronous reads with Newtonsoft.JSON.
I also updated the server project to test both implementations.