Skip to content
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

Merged
merged 20 commits into from
Sep 5, 2024
Merged

Conversation

cdriesler
Copy link
Member

Description & motivation

  • Use new utils to also mutate on join

Changes:

To-do before merge:

Screenshots:

Validation of changes:

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

References

@cdriesler cdriesler requested a review from fabis94 August 30, 2024 13:55
const result = await apollo
.mutate({
mutation: DashboardJoinWorkspaceDocument,
variables: {
input: {
workspaceId: props.workspace.id
}
},
update(cache) {
modifyObjectField(
Copy link
Contributor

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 }) => {
Copy link
Contributor

@fabis94 fabis94 Aug 30, 2024

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

Copy link
Contributor

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

@cdriesler
Copy link
Member Author

Ok, updated, but now it's pretty similar to the mutation when creating a workspace. Acceptable for now?

@cdriesler cdriesler requested a review from fabis94 August 30, 2024 14:35
Base automatically changed from fabians/fe2-better-cache-utilities to main September 3, 2024 07:59
Copy link
Contributor

@fabis94 fabis94 left a 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

@cdriesler cdriesler merged commit 4896816 into main Sep 5, 2024
23 of 25 checks passed
@cdriesler cdriesler deleted the chuck/mutateOnJoinWorkspace branch September 5, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants