AppSync Enhanced Filtering resolver

AppSync Enhanced Filtering resolver


0

My schema:

type Mutation {
    createOrder(order: OrderDTO!): Order!
}

type Subscription {
    onNewOrder(minimumPrice: Float): Order @aws_subscribe(mutations: ["createOrder"])
}

My Lambda resolver for createOrder mutation:

exports.handler = async function (event: OrderEvent): Promise<OrderWithPrice> {
    const order = await orderRepository.createOrder(event);
    ...
    return {
        ...order,
        totalPrice: await calculateTotalPrice(order)
    }
};

The user should pass minimumPrice parameter on subscription and subscribe to only orders with totalPrice higher than minimal. Enhanced Filtering is required for that.

AWS docs recommend to create request and response functions with extensions.setSubscriptionFilter but in this case AppSync won’t be able to use my handler (it cannot have 1 handler and 2 additional exported functions).

What is a proper way to use Enhanced Filtering for my case?


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *