When using Apollo's optimisticResponse, should the cache update automatically?

Viewed 391

My react application takes advantage of Apollo's automatic cache updates to update the UI. I'd like to use the optimisticResponse option for the mutate function but it's not working as expected. I'm wondering if it's necessary to add an update option to the mutate function, or if apollo should be able to update the cache automatically using the id's and typenames.

Here are the options I've provided:

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,                                                     
       }                                                 
   }                                            
})

The meal choice gets updated but the result doesn't show up in the UI until the server responds.

0 Answers
Related