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

[Feature] Support for subscription #27

@alexstrat

Description

@alexstrat

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!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions