aws / aws-appsync-community

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

extensions.invalidateSubscriptions function missing for JS resolvers #265

Closed sashee closed 1 year ago

sashee commented 1 year ago

In VTL, there is an extensions.invalidateSubscriptions function for invalidating subscriptions:

image

But this is not available for JS resolvers:

image

Without this, we need to use VTL resolvers to close subscriptions.

lijithwv commented 1 year ago

Similar problem here, not able to use $extensions.setSubscriptionFilter in a direct lambda resolver. I can implement the filtering using a VTL mapping-template. But would be nice if we can use the extensions in all resolvers.

onlybakam commented 1 year ago

this should be fixed. i recommend using util.transform as well. example in TypeScript:

import { util } from '@aws-appsync/utils'

type Notice = { team: string; severity: number }

export function request() {}

export function response(ctx) {
  const filter = util.transform.toSubscriptionFilter<Notice>({
    team: { eq: 'mine' },
    severity: { gt: 34 },
  })
  extensions.setSubscriptionFilter(filter)
}