dataconnect(change): Implement FetchPolicy.SERVER_ONLY - #7887
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request successfully implements the SERVER_ONLY fetch policy for executeQuery. The changes correctly bypass the cache for reads while still updating it with server results. The accompanying tests are thorough, covering both the new policy's behavior and its interaction with the cache. I've made a couple of suggestions to improve the clarity of test names for better maintainability, but overall this is a solid contribution.
…"ReturnsServerData" (was "ReturnsCachedData") [skip actions]
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
This PR implements the dataconnect
SERVER_ONLYfetch policy for theexecuteQuerymethod. This ensures that queries executed with this policy will strictly retrieve data from the server, while correctly interacting with the local cache by updating it and bypassing any previously cached results.Highlights
FetchPolicy.SERVER_ONLYinDataConnectGrpcRPCs.ktwhen executing queries, guaranteeing that it fetches results from the server instead of the local cache.QueryCachingIntegrationTest.ktto ensureSERVER_ONLYcorrectly returns server data regardless of cache age or availability.DataConnectGrpcRPCsUnitTest.ktto verify thatSERVER_ONLYbypasses the cache, properly updates cached entities, and correctly retrieves both non-normalized and normalized results.Changelog
FetchPolicy.SERVER_ONLYbehavior under various cache conditions (e.g.,maxAgelimits, missing cache data).executeCreateQueryUpdateQueryTestto use a data class for strings, and simplified the verification logic to accommodate the new fetch policy.executeQueryto accept and processFetchPolicy.SERVER 8000 _ONLY.SERVER_ONLYskip pulling from the cache, while still proceeding to update the cache when a result is received from the server.DataConnectGrpcRPCsUnitTestfor consistency.assumeTruestubs with actual unit tests verifying the behavior ofSERVER_ONLY.toExecuteQueryResponseextension methods for configuring mock responses in tests.