I have an iOS AWS Amplify Project using GraphQL API and DynamoDB to store data. This is a chat app.
Initially when a user signs in he will get all messages for a conversation. If then he comes back to the app a few days later I want to update any new messages in each conversation.
At the moment I am using the Date of the last message as a predicate for future queries. However I was wondering if there is a better or more standard way of querying a table for changes since the last time you queried?
I am not using DataStore. I am managing my own local storage.
let keys = Message.keys
let predicate = keys.conversationID == conversationID && keys.createdAt > lastQueryDate
Amplify.API.query(request: .paginatedList(Message.self, where: predicate, limit: 100)) { [weak self]
    DispatchQueue.main.async {
        switch event {
        case .success(let result):
            switch result {
            case .success(let messages):
                // handle data
            case .failure(let error):
                print("Got failed result with \(error.errorDescription)")
            }
        case .failure(let error):
            print("Got failed event with error \(error)")
        }
    }
}