dataconnect: wire up DataSource for caching and extract entity IDs from response extensions#7814
Conversation
…a server or cache, and implements getEntityIdForPathFunction to extract entity ID mapping from GraphQL response extensions.
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. |
📝 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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request wires up DataSource for caching and extracts entity IDs from response extensions, which is a significant step towards enabling offline caching. The changes correctly plumb the DataSource information through various layers of the architecture. The core logic for extracting entity IDs from ExecuteQueryResponse extensions is well-implemented in DataConnectGrpcRPCs.kt. The addition of new tests to cover this functionality is also a great inclusion. I have a few minor suggestions for refactoring to improve code clarity and conciseness.
…with implicit name `it`
… "0.0.0" becoming 0, which IS a valid user_version value.
This PR wires up the
DataSourceto indicate the origin of query results (cache or server) and implements the logic to extract entity paths and IDs from the GraphQL response extensions. These changes are critical for enabling fine-grained entity-level caching and normalization.Highlights
DataSourceTracking: TheQueryResultnow includes adataSourcefield, allowing consumers to know if the data was fetched from theCACHEorSERVER.data_connectextensions in the GraphQL response to extract entity IDs and their corresponding paths. This enables the cache to correctly store and look up individual entities.DataConnectGrpcRPCsUnitTest.ktto verify the entity path extraction logic and cache behavior. Existing tests were updated to reflect theDataSourcechanges.Changelog
DataSourceand extracting entity paths.OperationResultto include asourceof typeDataSource.sourceis now passed when creatingOperationResult.getEntityIdForPathFunctionto extract entity IDs and paths from theExecuteQueryResponseextensions.executeto handle the newDataSourcePairreturned fromqueryManagerand pass thedataSourcetoQueryResultImpl.DataConnectGrpcRPCsUnitTest.ktto test entity path extraction.DataConnectGrpcClientUnitTest.kt,MutationRefImplUnitTest.ktandQueryRefImplUnitTest.ktto reflect theDataSourceinOperationResult.