AWS AppSync中的订阅自定义筛选

Vin*_*ang 13 amazon-web-services aws-appsync appsync-apollo-client

是否可以在AWS AppSync中订阅自定义过滤逻辑?

据我所知,目前的行为是:例如,我的架构如下所示

type Mutation {
  createEvent(userId: ID!, event: Event!): Event!
}

type Subscription {
  onEvent(userId: ID!): Event!
  @aws_subscribe(mutations: ["createEvent"])
}
Run Code Online (Sandbox Code Playgroud)

AppSync的当前行为是,当我触发createEvent时,AppSync承诺如果userId相等,则Subscription的订阅者会收到Event.即AppSync的过滤逻辑就像

if (Muatation.userId == Subscription.userId) {
  // forward to subscriber
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我想要不同的过滤逻辑呢?例如,我想订阅除了由我触发的所有其他事件?即

if (Muatation.userId != Subscription.userId) {
  // forward to subscriber
}
Run Code Online (Sandbox Code Playgroud)

那么,是否可以在AppSync中使用自定义过滤逻辑?

小智 5

当前,AppSync不支持此用例。

将来可能会考虑添加自定义过滤。