-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
offlineExchange doesn't apply cyclic optimistic mutations #2478
Labels
bug 🐛
Oh no! A bug or unintented behaviour.
Comments
Hm, this could be a regression in regards to:
|
I have managed to reproduce this in a test but generally this feels like it has never worked, it only happens when the second mutation has the same key it('supports updating an optimisticly updated entity', () => {
const store = new Store({
optimistic: {
updateTodo: (args) => ({
__typename: 'Todo',
id: args.id,
complete: args.completed,
}),
},
});
const todosData = {
__typename: 'Query',
todos: [
{ id: '0', complete: false, text: '0', __typename: 'Todo' },
{ id: '1', complete: false, text: '1', __typename: 'Todo' },
],
};
write(store, { query: Todos }, todosData);
const updateTodo = gql`
mutation($id: ID!, $completed: Boolean!) {
__typename
updateTodo(id: $id, completed: $completed) {
__typename
complete
id
}
}
`;
writeOptimistic(store, { query: updateTodo, variables: { id: '0', completed: true } }, 1);
let queryRes = query(store, { query: Todos });
expect(queryRes.partial).toBe(false);
expect(queryRes.data.todos[0].complete).toEqual(true);
writeOptimistic(store, { query: updateTodo, variables: { id: '0', completed: false } }, 2);
queryRes = query(store, { query: Todos });
expect(queryRes.partial).toBe(false);
expect(queryRes.data.todos[0].complete).toEqual(false);
writeOptimistic(store, { query: updateTodo, variables: { id: '0', completed: true } }, 1);
queryRes = query(store, { query: Todos });
expect(queryRes.partial).toBe(false);
expect(queryRes.data.todos[0].complete).toEqual(true);
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
urql version & exchanges:
urql
2.2.1urql/exchange-graphcache
4.4.2Using exchanges
[dedupExchange, offlineExchange, fetchExchange]
Steps to reproduce
A minimal reproduction is available here: https://github.com/jdkula/urql-graphcache-layering-bug-reproduction
offlineExchange
with optimistic mutationsExpected behavior
Cyclical mutations should be allowed (e.g. set value to 0, set value to 1, set value to 0, set value to 1, ...)
Actual behavior
Additional mutations once the cycle is established seem to be lost (it appears to be updating the resultant optimistic result somewhere deeper in the cache's optimistic layers, according to the calculated hash/key of the mutation/operation).
The text was updated successfully, but these errors were encountered: