Skip to content

GraphQL Subscriptions #2369

Description

@michakfromparis

As a headless platform, I believe vendure would greatly benefit from an idiomatic way to register new graphql subscriptions.
This would allow the admin UI to avoid polling and immediately react to data changes.

Some users have managed to get them working #1879 but my personal recent attempts were unfruitful.

What seems to be the approach that is most aligned with vendure's coding standards / architecture would be to use the nest resolver decorators so @Subscription can sit along @Mutation & @Query like in the example below

@Resolver('Entity')
export class EntityResolver {

  @Query('entity')
  @Transaction()
  async entity(@Args('id') id: number) {
    ...
  }

  @Mutation('deleteEntity')
  @Transaction()
  async deleteEntity(@Args('id') id: number) {
    ...
  }

  @Subscription('entityDeleted')
  async entityDeleted() {
    ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    @vendure/coreT3: SystemicInvolves a systemic decision. Decide before implementing.design 📐This issue deals with high-level design of a featuretype: feature ✨👋 contributions welcomeIssues where we appreciate contributions from our community

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions