Skip to content

feat(fdc): Add request execution and response parsing to _DataConnectApiClient - #969

Merged
mk2023 merged 5 commits into
winefrom
barolo
Jul 29, 2026
Merged

feat(fdc): Add request execution and response parsing to _DataConnectApiClient#969
mk2023 merged 5 commits into
winefrom
barolo

Conversation

@mk2023

@mk2023 mk2023 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

feat(fdc): Add execute_graphql request execution and response parsing to _DataConnectApiClient
Introduced execute_graphql and execute_graphql_read methods to DataConnect and _DataConnectApiClient. This includes GraphQL payload preparation, HTTP request execution via JsonHttpClient, error handling, and raw response parsing into ExecuteGraphqlResponse.
Testing: All unit tests passed with 10.00/10 pylint score in tests/test_data_connect.py.

Implemented _make_gql_request on _DataConnectApiClient to execute and handle responses/errors for GraphQL operations. Added corresponding unit tests in tests/test_data_connect.py.

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

Copy link
Copy Markdown

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 _make_gql_request method to the _DataConnectApiClient class in firebase_admin/dataconnect.py to handle GraphQL requests, along with corresponding unit tests in tests/test_data_connect.py. Feedback on these changes highlights opportunities to improve error handling robustness. Specifically, it is recommended to ensure resp_dict is a dictionary before checking for errors, to avoid silent failures when the errors field is present but empty or malformed, and to add a unit test verifying that GraphQL errors are correctly parsed and raised as FirebaseError exceptions.

Comment thread firebase_admin/dataconnect.py Outdated
Comment thread tests/test_data_connect.py
Refactored _parse_graphql_response and added robust recursive type deserialization to _DataConnectApiClient.

- Implemented _deserialize_type and _deserialize_dataclass helper methods to support nested dataclasses, generic lists (List[T]), generic dictionaries (Dict[K, V]), Unions (Union[...]), Enums, and primitive casting.
- Enhanced _make_gql_request error handling to prevent silent error swallowing when the errors key is present.
- Added comprehensive unit test coverage in tests/test_data_connect.py.
@mk2023 mk2023 changed the title feat(fdc): Add internal GraphQL request helper method and tests feat(fdc): Add request execution and response parsing to _DataConnectApiClient Jul 20, 2026

@stephenarosaj stephenarosaj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some comments - haven't looked at tests yet

Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
Comment thread firebase_admin/dataconnect.py Outdated
mk2023 added 2 commits July 23, 2026 10:29
…helper

- Introduced QueryError subclass of FirebaseError for Data Connect GraphQL query/mutation errors and exposed it in __all__.
- Extracted _check_graphql_errors helper method on _DataConnectApiClient.
- Updated error handling for non-dictionary response payloads in _parse_graphql_response to raise InternalError.
- Note: Did not edit parse_graphql_response because we are waiting on whether this will even be a function or not.
…nt instantiation

- Removed output deserialization helpers (_extract_actual_type, _deserialize_type, _deserialize_dataclass) to return raw JSON payload dictionaries (ExecuteGraphqlResponse.data), aligning Data Connect with Firestore and Realtime Database patterns for user-defined schemas.
- Updated DataConnect.__init__ to immediately instantiate _DataConnectApiClient for consistency with Node.js and other Python Admin SDK services.
- Updated test suite in tests/test_data_connect.py to cover raw response parsing and immediate client instantiation.

@itsrakhil itsrakhil left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@mk2023
mk2023 requested a review from jonathanedey July 27, 2026 18:07

@stephenarosaj stephenarosaj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM! the simplification of removing deserialization is a gr8 :P

Comment thread firebase_admin/dataconnect.py

@jonathanedey jonathanedey 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.

LGTM with a few comments, Thanks!

Comment thread firebase_admin/dataconnect.py
Comment thread firebase_admin/dataconnect.py
…n error message

Added a TODO comment referencing b/406281627 for partial errors support in ExecuteGraphqlResponse and _parse_graphql_response. Updated _parse_graphql_response to include the raw response payload in the InternalError message string for improved debug visibility.
@mk2023
mk2023 merged commit 2eb6bd8 into wine Jul 29, 2026
15 checks passed
@mk2023
mk2023 deleted the barolo branch July 29, 2026 19:24
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.

4 participants