⚡️ Pro Feature ⚡️ This feature is bundled with GraphQL-Pro.

Stream

@stream works very much like @defer, except it only applies to list fields. When a field has @stream and it returns a list, then each item in the list is returned to the client as a patch. @stream is described in a proposal to the GraphQL specification.

Note: @stream was added in GraphQL-Pro 1.21.0 and requires GraphQL-Ruby 1.13.6+.

Installation

To support @stream in your schema, add it with use GraphQL::Pro::Stream:

class MySchema < GraphQL::Schema
  # ...
  use GraphQL::Pro::Stream
end

Additionally, you should update your controller to handle deferred parts of the response. See the @defer setup guide for details. (@stream uses the same deferral pipeline as @defer, so the same setup instructions apply.)

Usage

After that, you can include @stream in your queries, for example:

{
  # Send each movie in its own patch:
  nowPlaying @stream {
    title
    director { name }
  }
}

If @stream is applied to non-list fields, it’s ignored.

@stream supports several arguments: