-
Notifications
You must be signed in to change notification settings - Fork 177
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
fix(workspaces): mutate on join workspace #2833
Conversation
const result = await apollo | ||
.mutate({ | ||
mutation: DashboardJoinWorkspaceDocument, | ||
variables: { | ||
input: { | ||
workspaceId: props.workspace.id | ||
} | ||
}, | ||
update(cache) { | ||
modifyObjectField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should always use the 2nd param of update
- data
- to get the actual data from the response and validate that the mutation did in fact go through successfully before you make any cache updates
getCacheId('User', userId), | ||
'workspaces', | ||
({ helpers: { createUpdatedValue, ref } }) => { | ||
return createUpdatedValue(({ update }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdriesler User.workspaces has variables as well, you usually want to just evict all filtered (e.g. search specified) cache values cause there's no way to accurately tell if the new workspace fits that filter or not. then only modify the lists in non-filtered cache values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evict means - wherever that evicted value was referenced, e.g. in some kind of query living in a UI component, the query will understand that its now missing a part of its data and refetch it
Ok, updated, but now it's pretty similar to the mutation when creating a workspace. Acceptable for now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think u need to merge main, there's conflicts and it shows my changes here
Description & motivation
Changes:
To-do before merge:
Screenshots:
Validation of changes:
Checklist:
References