Skip to content

Conversation

fredzqm
Copy link
Contributor

@fredzqm fredzqm commented Aug 27, 2025

Description

Merges four dataconnect execute tools (execute_graphql, execute_graphql_read, execute_query, and execute_mutation) into a single dataconnect_execute tool.

Remove the functionality to execute_operation on a connector. In practice, it's difficult to get LLM to use it correctly. It's simpler to ask LLM to pass the query from local files.

Added auth_token_json, so LLM can execute query that requires auth as well.

Remove read_only flag. We can detect whether it's a query with a simple heurestic.

Scenarios Tested

Execute query against emulator and prod, with and without auth token.

https://screencast.googleplex.com/cast/NDg1MzYzNjE0NzQ0NTc2MHw2ZTE2OWNjMy1hNA

Sample Commands

fredzqm and others added 11 commits July 15, 2025 08:31
Merges four dataconnect execute tools (`execute_graphql`, `execute_graphql_read`, `execute_query`, and `execute_mutation`) into a single `dataconnect_execute` tool.

The new tool provides a more versatile interface by accepting either a `query` or an `operationName`, and includes a `read_only` flag to control whether the operation can write data. This change simplifies the toolset while preserving all existing functionality.
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @fredzqm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the Data Connect toolset by merging four existing execution tools into a single, more versatile dataconnect_execute tool. The primary goal is to simplify the interface for executing GraphQL operations against Data Connect services, whether they are arbitrary queries/mutations or deployed operations. The consolidated tool now intelligently handles different operation types and read/write permissions through a unified input schema, improving usability and reducing code duplication without sacrificing any existing capabilities.

Highlights

  • Tool Consolidation: The pull request consolidates four distinct Data Connect execution tools (execute_graphql, execute_graphql_read, execute_query, execute_mutation) into a single, unified dataconnect_execute tool.
  • Enhanced Flexibility: The new dataconnect_execute tool offers a more flexible interface, allowing users to specify either a raw GraphQL query or an operationName for deployed operations.
  • Read-Only Flag: A new read_only flag has been introduced within the unified tool, providing explicit control over whether the operation should use a read-only endpoint, effectively replacing the need for separate read-specific tools.
  • Simplified Toolset: This refactoring simplifies the overall toolset for Data Connect operations, reducing redundancy and streamlining future maintenance, while ensuring all previous functionalities are preserved.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue comments and review comments.
Help /gemini help Displays a list of available commands.

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

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 successfully refactors four separate dataconnect execution tools into a single, more versatile dataconnect_execute tool. This is a great simplification of the toolset. The implementation is solid, using zod for robust input validation. My review focuses on reducing some code duplication within the new tool to enhance maintainability. I've provided specific suggestions to make the code more concise by dynamically selecting the execution function based on the read_only flag.

Comment on lines 107 to 121
if (read_only) {
const response = await dataplane.executeGraphQLRead(apiClient, serviceInfo.serviceName, {
name: "",
query,
variables: parseVariables(unparsedVariables),
});
return graphqlResponseToToolResponse(response.body);
} else {
const response = await dataplane.executeGraphQL(apiClient, serviceInfo.serviceName, {
name: "",
query,
variables: parseVariables(unparsedVariables),
});
return graphqlResponseToToolResponse(response.body);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The if (read_only) and else blocks contain very similar logic, with the only difference being the dataplane function called. This can be refactored to reduce code duplication and improve maintainability. You can determine the function to call based on the read_only flag and then call it once.

      const executeFn = read_only ? dataplane.executeGraphQLRead : dataplane.executeGraphQL;
      const response = await executeFn(apiClient, serviceInfo.serviceName, {
        name: "",
        query,
        variables: parseVariables(unparsedVariables),
      });
      return graphqlResponseToToolResponse(response.body);

Comment on lines 139 to 151
if (read_only) {
const response = await dataplane.executeGraphQLQuery(apiClient, connectorPath, {
operationName,
variables: parseVariables(unparsedVariables),
});
return graphqlResponseToToolResponse(response.body);
} else {
const response = await dataplane.executeGraphQLMutation(apiClient, connectorPath, {
operationName,
variables: parseVariables(unparsedVariables),
});
return graphqlResponseToToolResponse(response.body);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the query block, this part has duplicated code for the read_only and non-read_only cases. This can be simplified by selecting the appropriate execution function based on the read_only flag and then making a single call.

      const connectorPath = `${serviceInfo.serviceName}/connectors/${connector_id}`;
      if (read_only) {
        const response = await dataplane.executeGraphQLQuery(apiClient, connectorPath, {
          operationName,
          variables: parseVariables(unparsedVariables),
        });
        return graphqlResponseToToolResponse(response.body);
      } else {
        const response = await dataplane.executeGraphQLMutation(apiClient, connectorPath, {
          operationName,
          variables: parseVariables(unparsedVariables),
        });
        return graphqlResponseToToolResponse(response.body);
      }

@fredzqm fredzqm requested a review from tammam-g August 27, 2025 23:06
@fredzqm
Copy link
Contributor Author

fredzqm commented Aug 27, 2025

@tammam-g Fun PR generated by Jules~ It did a great job!!

Per Michael's feedback, we should prefer fewer more powerful tools.

Copy link
Contributor

@tammam-g tammam-g left a comment

Choose a reason for hiding this comment

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

Looks good but could we add scenarios tested?

@github-project-automation github-project-automation bot moved this to Changes Requested [PR] in [Cloud] Extensions + Functions Aug 28, 2025
@fredzqm
Copy link
Contributor Author

fredzqm commented Aug 29, 2025

[Not time sensitive]

@tammam-g Added a screencast of test scenarios~
Feel free to take another pass.

@github-project-automation github-project-automation bot moved this from Changes Requested [PR] to Approved [PR] in [Cloud] Extensions + Functions Aug 29, 2025
@fredzqm fredzqm enabled auto-merge (squash) August 29, 2025 19:43
@fredzqm fredzqm disabled auto-merge August 29, 2025 19:45
@fredzqm fredzqm enabled auto-merge (squash) August 29, 2025 19:50
@fredzqm fredzqm merged commit ad3051f into master Aug 29, 2025
48 checks passed
@fredzqm fredzqm deleted the feat/merge-dataconnect-execute-tools branch August 29, 2025 20:01
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Aug 29, 2025
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.

2 participants