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

Change Apollo cache policy #9296

Merged
merged 1 commit into from
Dec 31, 2024
Merged

Change Apollo cache policy #9296

merged 1 commit into from
Dec 31, 2024

Conversation

FelixMalfait
Copy link
Member

Set the default cache policy to 'cache-and-network' to make sure user get more fresh data without refreshing the browser. Better for workspace with several users working at the same time.

It will put more load on the server...

Note: I don't think the previous setting was taken into account
Screenshot 2024-12-31 at 10 59 56

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

Modified Apollo Client's fetch policy in useApolloFactory to improve real-time data synchronization across collaborative workspaces.

  • Changed default fetch policy from 'cache-first' to 'cache-and-network' in /packages/twenty-front/src/modules/apollo/hooks/useApolloFactory.ts
  • Moved fetch policy configuration from 'query' to 'watchQuery' for proper application to all watched queries
  • Increased server load expected due to network requests on every query, even with cached data
  • Previous fetch policy setting was likely ineffective due to incorrect configuration location

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@lucasbordeau
Copy link
Contributor

@FelixMalfait Are we sure that the backend will scale accordingly ? If yes let's try and see how it goes, maybe we can release it under a feature flag if it's too risky.

@lucasbordeau
Copy link
Contributor

As a reminder for the conversation, here are the fetch policies : https://www.apollographql.com/docs/react/data/queries#supported-fetch-policies

@lucasbordeau
Copy link
Contributor

I'll do a round of tests with fetch more to see how it behaves in local development also, which can be a concern for contributors

@lucasbordeau lucasbordeau self-assigned this Dec 31, 2024
@FelixMalfait
Copy link
Member Author

Thanks @lucasbordeau I tested it locally no issue, it worked well for me.
I'm not too worried for the server, it remains the same order of magnitude, we can merge like this

@lucasbordeau
Copy link
Contributor

It's ok for me, thanks to fetch more there's no real difference, plus there is not a noticeable difference, because the component loading takes more time than the network rounds.

@lucasbordeau
Copy link
Contributor

Let's if we have problems in the future with this but seems like we can be confident.

@lucasbordeau lucasbordeau merged commit 03370b4 into main Dec 31, 2024
22 checks passed
@lucasbordeau lucasbordeau deleted the change-cache-policy branch December 31, 2024 11:12
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