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

After createOneDbConnection mutation, update cache manually instead of using refetchQuery #5684

Merged
merged 2 commits into from
May 31, 2024

Conversation

ijreilly
Copy link
Collaborator

Closes #5057.

RefetchQuery is unreliable - it won't be executed if the component is unmounted, which is the case here because of the redirection that occurs after the mutation.
We want to avoid using refetchQuery as much as possible, and write directly in the cache instead.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Removed refetchQueries in useCreateOneDatabaseConnection.ts
  • Manually updated Apollo cache after mutation
  • Ensured cache reliability post-redirection
  • Improved handling of newly created remote server data

},
};

if (isDefined(cache.readQuery(getManyDatabaseConnectionsQuery))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure cache.readQuery returns a defined result before updating the cache.

@ijreilly ijreilly changed the title After mutatio, update cache manually instead of using refetchQuery After mutation, update cache manually instead of using refetchQuery May 30, 2024
@ijreilly ijreilly changed the title After mutation, update cache manually instead of using refetchQuery After createOneDbConnection mutation, update cache manually instead of using refetchQuery May 30, 2024
Copy link
Contributor

@thomtrp thomtrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@ijreilly ijreilly merged commit 5e1dfde into main May 31, 2024
13 checks passed
@ijreilly ijreilly deleted the fix-refetch-query branch May 31, 2024 08:28
Weiko pushed a commit that referenced this pull request May 31, 2024
…f using refetchQuery (#5684)

Closes #5057.

RefetchQuery is unreliable - [it won't be executed if the component is
unmounted](apollographql/apollo-client#5419),
which is the case here because of the redirection that occurs after the
mutation.
We want to avoid using refetchQuery as much as possible, and write
directly in the cache instead.
arnavsaxena17 pushed a commit to arnavsaxena17/twenty that referenced this pull request Oct 6, 2024
…f using refetchQuery (twentyhq#5684)

Closes twentyhq#5057.

RefetchQuery is unreliable - [it won't be executed if the component is
unmounted](apollographql/apollo-client#5419),
which is the case here because of the redirection that occurs after the
mutation.
We want to avoid using refetchQuery as much as possible, and write
directly in the cache instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Remotes][Bug] Fix refresh issue after creating/deleting connection
2 participants