pragma icon indicating copy to clipboard operation
pragma copied to clipboard

Subscription topics

Open anasbarg opened this issue 3 years ago • 0 comments

Subscription topics

You can define the subscription topic for each model to be either a field, or a function that generates the topic.

A topic is a runtime value indicating to which websockets a subscription "publish" event should be routed to.

Proposed Examples

Binding the value of the topic of a subscription on A using @topic directive:

Binding it to the value of a field

@1 model A {
  @1 id: String @uuid @primary
  @2 a: String
  @3 b: Integer @topic
}

Binding it to an arbitrary value using a function on a specific field

import "./some/script.js" as fns { runtime = "node" }

@1 model A {
  @1 id: String @uuid @primary
  @2 a: String
  @3 b: Integer @topic(function: fns.topicA)
}

Binding it to an arbitrary value using a function on the entire model

@topic(function: fns.topicA)
@1 model A {
  @1 id: String @uuid @primary
  @2 a: String
  @3 b: Integer
}

Notes

We need to think more about the first example.

anasbarg avatar Apr 15 '21 08:04 anasbarg