Replies: 4 comments 20 replies
-
Hey, thanks for opening this discussion. For my part, I have considered (even attempted!) to build an implementation on the same code as |
Beta Was this translation helpful? Give feedback.
-
Whoa, that's great! Would be a pleasure to try this out, since I have a few apps with valid use cases (and a Pro subscription) 😄 I'm using Relay's support is still experimental, that's why is not mentioned in the docs (except I just wanted to add that I'm very impressed by your support. I'm using this gem for years and every issue I've opened was closed and resolved within days or even hours. I really appreciate this! |
Beta Was this translation helpful? Give feedback.
-
👋 I just released GraphQL-Pro 1.21.0 which includes |
Beta Was this translation helpful? Give feedback.
-
Ok... I spent today trying to get urql's streaming example working exactly the same with a Ruby server, and I pretty much got there: https://github.com/rmosolgo/graphql-ruby-urql-stream-example There are some caveats, but it works as it should, IMO. The biggest thing is that urql seems to expect the first flush to contain only As for timing, I think this is because of debouncing on the client somewhere. If you want to add a pause, I'd recommend doing it inside the controller. For example, for Rails ActionController::Live, you might do something like this: if (deferred = result.context[:defer])
# Stream an urql-friendly response over ActionController::Live
# like https://github.com/FormidableLabs/urql/blob/main/examples/with-defer-stream-directives/server/index.js
response.headers["Content-Type"] = "multipart/mixed; boundary=\"#{delimiter}\""
# urql expects a leading boundary marker:
response.stream.write("---")
deferred.deferrals.each do |deferral|
patch = [
"",
"Content-Type: application/json; charset=utf-8",
"",
deferral.to_h.to_json
]
if deferral.has_next?
patch << "---"
end
patch_str = patch.join("\r\n")
response.stream.write(patch_str)
# Sleep here to let the view render between flushes:
sleep 0.1
end
response.stream.write("-----")
end Want to give something like that a try? |
Beta Was this translation helpful? Give feedback.
-
Since we already have a
@defer
directive, a@stream
one would be great too. I have a lot of use cases where I query hundreds of rows, and this could be speeded up by using a@stream
, since infinite loading isn't always possible (for example: display a spreadsheet).Here's some more information about
@stream
:Libraries like
urql
andrelay
are already supporting@stream
. I think you had that in your docs a few years ago also 🤔 But maybe I'm mixing it up too.Beta Was this translation helpful? Give feedback.
All reactions