Skip to content

dataconnect(chore): refactor variable encoding and data decoding logic into a single class#8142

Merged
dconeybe merged 14 commits into
mainfrom
dconeybe/dataconnect/DataConnectSerialization
May 12, 2026
Merged

dataconnect(chore): refactor variable encoding and data decoding logic into a single class#8142
dconeybe merged 14 commits into
mainfrom
dconeybe/dataconnect/DataConnectSerialization

Conversation

@dconeybe

@dconeybe dconeybe commented May 12, 2026

Copy link
Copy Markdown
Contributor

This PR refactors the variable encoding and data decoding logic for Firebase Data Connect into a new DataConnectSerialization class. This consolidation simplifies the core client logic and improves maintainability by centralizing serialization concerns.

Highlights

  • Introduced DataConnectSerialization to handle all encoding and decoding of GraphQL data and variables.
  • Refactored DataConnectGrpcClient, MutationRefImpl, and QueryRefImpl to delegate serialization tasks to the new class.
  • Updated DataConnectBidiConnectStream to support null data in ExecuteResponse.
  • Added comprehensive unit tests for the new serialization logic in DataConnectSerializationUnitTest.

Changelog

15 files affected
  • DataConnectGrpcRPCsConnectIntegrationTest.kt: Added null check for data in shouldBeGetStringByKeyQueryResponse.
  • DataConnectBidiConnectStream.kt: Changed data to be nullable in ExecuteResponse.
  • DataConnectGrpcClient.kt: Removed internal serialization logic and updated OperationResult to use GraphqlError.
  • DataConnectInternal.kt: Added serialization property to FirebaseDataConnectInternal.
  • FirebaseDataConnectInternal.kt: Added serialization property.
  • MutationRefImpl.kt: Updated to use serialization for encoding variables and decoding data.
  • QueryRefImpl.kt: Updated to use serialization for encoding variables and decoding data.
  • DataConnectSerialization.kt: New file containing the core serialization logic.
  • ProtoUtil.kt: Added toValueProto() and toErrorInfoImpl() helper functions.
  • DataConnectGrpcClientUnitTest.kt: Removed serialization tests (moved to DataConnectSerializationUnitTest) and updated existing tests.
  • DataConnectSerializationUnitTest.kt: New unit tests for DataConnectSerialization.
  • MutationRefImplUnitTest.kt: Updated mocks to include serialization.
  • KotestPrinters.kt: Updated import for toErrorInfoImpl.
  • arbs.kt: Added new arbitraries for GraphqlErrorProto and updated operationResult.

dconeybe added 13 commits May 11, 2026 18:02
…sDataConnectGrpcStreamingServer.kt and TurbineUtils.kt

This enables these classes to be used from both `androidTest` to `test`
(thanks to the `@SharedWithAndroidTest` annotation and the associated gradle plugin)
instead of just in `androidTest`. A future test will make use of this.
… streaming connection with the backend for realtime queries.
…le(): T` (moved from ConnectRPCIntegrationTest.kt)
…ared errors with itself instead of with the expected list [skip actions]
…sts if ConnectorStreamServiceCoroutineStub.connect() throws an exception
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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.

@dconeybe dconeybe changed the title Dconeybe/dataconnect/data connect serialization dataconnect(chore): refactor variable encoding and data decoding logic into a single class May 12, 2026
@dconeybe

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the DataConnectSerialization class to centralize variable encoding and data decoding logic, offloading these CPU-bound tasks to a background dispatcher. Existing components like MutationRefImpl, LiveQueries, and RegisteredDataDeserializer have been refactored to use this class, and internal models now utilize raw GraphqlError types. Review feedback identifies a missing null-safe call in DataConnectSerialization.kt that would lead to a compilation error and suggests improving consistency in error path string representations.

@dconeybe dconeybe marked this pull request as ready for review May 12, 2026 07:39
aashishpatil-g
aashishpatil-g previously approved these changes May 12, 2026
Base automatically changed from dconeybe/dataconnect/RealtimeRewire1 to main May 12, 2026 20:31
@dconeybe dconeybe dismissed aashishpatil-g’s stale review May 12, 2026 20:31

The base branch was changed.

@github-actions

Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our 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.

@dconeybe dconeybe requested a review from aashishpatil-g May 12, 2026 21:25
@dconeybe dconeybe merged commit a214af0 into main May 12, 2026
48 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/DataConnectSerialization branch May 12, 2026 22:37
@github-actions github-actions Bot mentioned this pull request May 13, 2026
@firebase firebase locked and limited conversation to collaborators Jun 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants