Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

[Feature] Support for subscription #27

Open
alexstrat opened this issue Aug 8, 2019 · 1 comment
Open

[Feature] Support for subscription #27

alexstrat opened this issue Aug 8, 2019 · 1 comment

Comments

@alexstrat
Copy link
Contributor

alexstrat commented Aug 8, 2019

As noted in Readme, today's implementation does not support subscriptions and it is, a priori, not a big deal because as noted in Readme:

in reactive-graphql everything is treated as subscriptions

Though, I figured out some benefits of having support for proper GraphQL Subscriptions:

Support conceptual difference between live queries and subscription

There is a conceptual difference between live queries and subscription that is well summarized with:

Live Queries observe data, subscriptions observe events

I stumbled upon cases where I specifically want to react to events. Example: to trigger some animations in the front-end when something happens.

Note that GQL eco-system (example: apollo-client, graphql-code-generator..) uses this distinction between the 2 concepts, and making the distinction helps to leverage the eco-system.

Use live queries as event subscription can lead to pitfalls

If one really wants to implement an event subscription with reactive-graphql, as a workaround one can use a regular reactive query:

type Query {
  postAdded: PostAddedEvent!
}

type PostAddedEvent {
  postId: Int!
}

But this can lead to emitting much more events than expected if the Post is changing live:

type Query {
  postAdded: PostAddedEvent!
}

type PostAddedEvent {
  post: Post!
}
@DanielMSchmidt
Copy link
Contributor

I think you are right and I would assume it's a doable change. We need to implement the Subscription interface, there should be tests in graphql-js that we can borrow to make sure we are spec compliant

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants