Let's say I have a task list. I use 2 apis -
- getTask which gives a response of the type
type TaskData = {
_id: ObjectId,
title: string,
tasker: {
_id: ObjectId,
name: string,
email: string
}
}
- updateTask which has a request of the type
type TaskRequest = {
_id: ObjectId,
title?: string;
taskerId?: ObjectId
}
Let's say I am updating the tasker for a task. My request for the updateTask is of type TaskRequest
{
_id: ObjectId,
taskerId: ObjectIdd,
}
However, to make an optimistic update, I need to locally replace an object of the type TaskData.
How should I do this? Should my mutation take in 2 params (request for the api and an object of type TaskData for the optimistic update)?