graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Feature request: Subscriptions

Open itsezc opened this issue 5 years ago • 5 comments

Are there any plans to support Subscriptions?

and how about other features such as @batch, @relay, @defer, @stream and @live (Apollo GraphQL Blog)

I understand that said features would take considerable effort to implement, but I'm sure that if there was to be a roadmap the community will start submitting PR for these features.

itsezc avatar Jan 07 '21 17:01 itsezc

The goal is to support the latest GraphQL spec, so that's a yes regarding subscriptions. Not a fan of supporting out of spec extensions at least for now, but it looks like some of them might become part of the next GraphQL version anyhow.

jgillich avatar Jan 12 '21 12:01 jgillich

+1 I need subscriptions

vrishtrix avatar Jan 18 '21 03:01 vrishtrix

I'd love for @live and @stream to be supported, I have been waiting on Apollo 3.0 far too long

thomasDelaporte avatar Jan 18 '21 19:01 thomasDelaporte

I've looked into subscriptions and I feel like the best way to implement them is via channels:

class Subscription
  @[GraphQL::Field]
  def example : Channel(String)
    channel = Channel(String).new
    spawn do
      channel.send "foo"
      channel.send "bar"
    end
    channel
  end
end

For triggering updates from mutations one could use a channel on Context, so I don't think we need to add anything for that.

The spec doesn't define any transport protocol or format, but the most sensible thing seems to be to do what Apollo/graphql-ws do, with the ability to override it.

Does that sound good?

jgillich avatar Mar 29 '22 23:03 jgillich

Please make example for redis ( https://github.com/davidyaha/graphql-redis-subscriptions ) , so it will be easy to put crystal app along with nodejs implementation syncing states, thanks,

atik7 avatar Mar 30 '22 09:03 atik7