我的 React 应用程序利用 Apollo 的自动缓存更新来更新 UI。我想使用该mutate函数的 optimistResponse 选项,但它没有按预期工作。我想知道是否有必要update向 mutate 函数添加一个选项,或者 apollo 是否应该能够使用 id 和类型名自动更新缓存。
以下是我提供的选项:
mutate({
variables: {id: attendee_record_id, meal_choice: meal_option},
optimisticResponse: {
__typename: 'Mutation',
updateAttendeeRecord: {
__typename: "UpdateAttendeeRecordPayload",
attendee_record: {
__typename: "AttendeeRecord",
id: attendee_record_id,
meal_choice: meal_option,
}
}
})
Run Code Online (Sandbox Code Playgroud)
膳食选择会更新,但结果不会显示在用户界面中,直到服务器响应。
| 归档时间: |
|
| 查看次数: |
515 次 |
| 最近记录: |