Apollo Optimistic Result: detect if object comes from server

Viewed 28

Our users need to answer a sequence of questions one by one and each time an answer is selected it gets saved while the user can go to the next question

To make everything as smooth as possible we are using Apollo optimistic result so the user always has the feeling that the answer is processed immediately

When answering the last question they have the option to submit the survey but they should be able to do this only if all the answers have been saved correctly

We cannot fake an id (like 'fake-answer-001') because the object would not be recognized by the object tree and apollo would not be able to track it and also we cannot add a new field (eg: state: 'being-saved') because this would mean updating the type definitions and it doesn't feel right to change the server for something purely cosmetic/ui related

Is there a way to detect if an object in the cache comes from an optimistic result or it was returned by the server?

0 Answers
Related