@@ -226,7 +226,9 @@ def execute_graphql(
226226 InternalError: If the server response payload is invalid or malformed.
227227 FirebaseError: The base platform exception.
228228 """
229- raise NotImplementedError
229+ return self ._client .execute_graphql (
230+ query = query , options = options , variables_type = variables_type
231+ )
230232
231233 def execute_graphql_read (
232234 self ,
@@ -256,7 +258,10 @@ def execute_graphql_read(
256258 InternalError: If the server response payload is invalid or malformed.
257259 FirebaseError: The base platform exception.
258260 """
259- raise NotImplementedError
261+ return self ._client .execute_graphql_read (
262+ query = query , options = options , variables_type = variables_type
263+ )
264+
260265
261266
262267class _DataConnectService :
@@ -348,12 +353,18 @@ def _validate_variables_type(
348353 if variables is not None :
349354 if not (isinstance (variables , Mapping ) or is_dataclass (variables )):
350355 raise ValueError ("variables must be a collections.abc.Mapping or a dataclass" )
351- if variable_type is not None :
356+ if (
357+ variable_type is not None
358+ and variable_type is not Any
359+ and variable_type is not typing .Any
360+ ):
352361 expected_type = typing .get_origin (variable_type ) or variable_type
353362 if not isinstance (variables , expected_type ):
354363 type_name = getattr (expected_type , '__name__' , str (expected_type ))
355364 raise ValueError (f"variables must be of type { type_name } " )
356365
366+
367+
357368 def _validate_impersonation_options (self , impersonate : Any ) -> None :
358369 """Validates impersonation dictionary options."""
359370 if impersonate is not None :
@@ -460,9 +471,10 @@ def _get_headers(self) -> Dict[str, str]:
460471
461472 @staticmethod
462473 def _check_graphql_errors (resp_dict : Any , resp : Any ) -> None :
463- """Raises QueryError if the GraphQL response payload contains an errors key ."""
464- if isinstance (resp_dict , dict ) and "errors" in resp_dict :
474+ """Raises QueryError if the GraphQL response payload contains non-empty errors."""
475+ if isinstance (resp_dict , dict ) and resp_dict . get ( "errors" ) :
465476 errors = resp_dict ["errors" ]
477+
466478 all_messages = ""
467479 if isinstance (errors , list ):
468480 messages = []
@@ -527,7 +539,20 @@ def _execute_graphql_helper(
527539 variables_type : Type [_Variables ] = Any ,
528540 ) -> ExecuteGraphqlResponse [Any ]:
529541 """Helper method to execute GraphQL queries or mutations against a specified endpoint."""
530- raise NotImplementedError
542+ if not isinstance (query , str ):
543+ raise ValueError ("query must be a string" )
544+ if not query .strip ():
545+ raise ValueError ("query must be a non-empty string" )
546+
547+ self ._validate_graphql_options (options , variable_type = variables_type )
548+
549+ url = self ._get_firebase_dataconnect_service_url (endpoint )
550+ headers = self ._get_headers ()
551+ payload = self ._prepare_graphql_payload (query , options )
552+
553+ resp_dict = self ._make_gql_request (url = url , headers = headers , payload = payload )
554+ return self ._parse_graphql_response (resp_dict )
555+
531556
532557 def execute_graphql (
533558 self ,
@@ -536,7 +561,9 @@ def execute_graphql(
536561 variables_type : Type [_Variables ] = Any ,
537562 ) -> ExecuteGraphqlResponse [Any ]:
538563 """Executes a GraphQL query or mutation and returns the result."""
539- raise NotImplementedError
564+ return self ._execute_graphql_helper (
565+ query , _EXECUTE_GRAPHQL_ENDPOINT , options , variables_type
566+ )
540567
541568 def execute_graphql_read (
542569 self ,
@@ -545,4 +572,6 @@ def execute_graphql_read(
545572 variables_type : Type [_Variables ] = Any ,
546573 ) -> ExecuteGraphqlResponse [Any ]:
547574 """Executes a read-only GraphQL query and returns the result."""
548- raise NotImplementedError
575+ return self ._execute_graphql_helper (
576+ query , _EXECUTE_GRAPHQL_READ_ENDPOINT , options , variables_type
577+ )
0 commit comments