aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

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

Open matsus2 opened 2 years ago

matsus2 commented 2 years ago

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?

KoldBrewEd commented 2 years ago

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?

matsus2 commented 2 years ago

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?

ffxsam commented 1 year ago

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.

azhong-git commented 1 year ago

+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.

ilfoxo commented 11 months ago

It would be great to filter by list of objects!

yashpatel6892 commented 11 months ago

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.