aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

Feature Request: Enhanced filtering subscription on mutation that returns list of objects.

Open matsus2 opened this issue 2 years ago • 6 comments

Looking at the documentation, it seems like enhanced filtering subscription only supports mutation that returns one object. https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-enhanced-filtering.html

Will there be support for this use case?

matsus2 avatar Apr 15 '22 17:04 matsus2

Indeed Enhance Filtering only supports top level objects/types for now however we are planning to support nested types in the future. Would you mind sharing your use case, if possible with specific types/fields required for filtering?

KoldBrewEd avatar Apr 18 '22 23:04 KoldBrewEd

Sure. We have a mutation called bulkCreateNotifications that returns a list of Notification object. We want to filter based on one of the fields of Notification object as you can do with a enhanced filtering for subscriptions for a single object output but since the mutation returns a list of them, it fails.

Enhanced subscription currently works for createNotfication that returns one Notification object. Notification has a field called "userId" and we want users to only get the subscription if that userId matches. We also want to support it for another mutation that returns list of Notifications.

Is it possible to automatically support the same filtering, but if it recognizes that output of the mutation is a list then it loops over each object and filters them accordingly?

matsus2 avatar Apr 18 '22 23:04 matsus2

I ran into this recently too, and would love to have this. We've got this in our schema:

interface Media {
  id: ID!
  name: String!
  duration: Float
  folder: Folder
  mediaType: MediaType!
  owner: User!
  ownerId: ID!
  createdAt: String!
  updatedAt: String!
  deleted: Boolean!
  deletedAt: String
}

You can see my temporary workaround of having ownerId in there, though that's not ideal, since owner is already part of this interface.

It would be nice if we could just specify "fieldName": "owner/id" to filter by the nested field.

ffxsam avatar Jan 17 '23 16:01 ffxsam

+1 on this. Our usecase is a list of subscriber ids. It would be nice for the enhanced filter to work with top level lists so that each subscriber can listen to new data.

azhong-git avatar Aug 02 '23 20:08 azhong-git

It would be great to filter by list of objects!

ilfoxo avatar Oct 10 '23 20:10 ilfoxo

There are two cases for nested object filtering:

  1. Filtering on nested objects: AppSync recently added this feature. Please refer to the public documentation.
  2. Filtering on Object list: AppSync does not yet allow this.

yashpatel6892 avatar Oct 13 '23 18:10 yashpatel6892