Handling slow SQL queries in GraphQL in general and Hot Chocolate specifically #8412
tomer-w
started this conversation in
Guidelines
Replies: 1 comment
-
Maybe look into something akin to Shopifys' bulkOperations. Would take a fair bit of doing, but it works pretty well for them. TLDR: Doc: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Hot Chocolate experts, I have a question about how we should handle inherently slow queries which can lead to client timeouts.
In my situation our Hot Chocolate is connected to SQL Azure backend and the queries we run are complex and slow. I'm talking about multi-minutes slow. We observed that for some of our customers, this can lead to the client side disconnecting the connection as there is no traffic on the connection.
As this is SQL, we really don't have any data to send till we really have all the data to send so using defer / stream is not really solving anything.
As an ugly workaround, I implemented my own "custom middletier" (I dont know a better / right term for that) hooked via
app.MapPost("/graphql", ...
which will do something very similar to what Hot Chocolate is doing internally but also start a task that will send new-line charachter every 30 seconds till the SQL query is ready. This, with theTransfer-Encoding: chunked
doing pretty good jon in keeping the client happy, while not interfering with the json parsing done by the client when the actual result is sent.I have few questions:
Beta Was this translation helpful? Give feedback.
All reactions