Custom filtering on subscription in AWS AppSync
Asked Answered
R

2

16

Is it possible to have custom filtering logic on subscription in AWS AppSync?

As I know, current behavior is: e.g. my schema is like the following

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

type Subscription {
  onEvent(userId: ID!): Event!
  @aws_subscribe(mutations: ["createEvent"])
}

Current behavior of AppSync is, when I trigger createEvent, AppSync promise that the subscriber of Subscription receive the Event if the userId are equal. i.e. the filtering logic of AppSync is sth like

if (Muatation.userId == Subscription.userId) {
  // forward to subscriber
}

But what if I want different filtering logic? For example, I want to subscribe all other events except those triggered by me? i.e.

if (Muatation.userId != Subscription.userId) {
  // forward to subscriber
}

So, is it possible to have custom filtering logic in AppSync?

Reaper answered 26/4, 2018 at 7:53 Comment(0)
D
6

Currently, this use case is not supported by AppSync.

Adding custom filtering may be considered in the future.

Delila answered 21/5, 2018 at 19:13 Comment(1)
Has anything changed in this matter in recent years?Germangermana
M
0

After having a look at possible filtering method here - appsync-doc

It doesn't seem possible

only thing you can do is, add a small logic in your client to detect if the Subscription is yours by comparing userid's.

Mendez answered 16/2, 2021 at 10:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.