Skip to content

Add verbose logging support to GraphQL tools and validators#1

Open
icezohu wants to merge 1 commit intomainfrom
support-verbose
Open

Add verbose logging support to GraphQL tools and validators#1
icezohu wants to merge 1 commit intomainfrom
support-verbose

Conversation

@icezohu
Copy link

@icezohu icezohu commented Jan 20, 2026

Summary by CodeRabbit

  • New Features
    • Introduced verbose output mode with configurable verbosity levels enabling multi-level debugging and troubleshooting support
    • Debug information now includes execution time, response size, GraphQL query details, validation errors, and comprehensive error context
    • Structured JSON output format available for enhanced analysis and detailed investigation of GraphQL operations and validation results

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

The PR extends GraphQL tools with an optional verbose flag that propagates from agent configuration through the tool creation layer, enabling conditional structured debug output in validation and execution responses based on verbosity levels.

Changes

Cohort / File(s) Summary
Verbose Configuration Propagation
src/index.ts, src/tools/index.ts
Added verbose parameter extraction from agentConfig and propagation through tool factory to underlying tool creators
Tool Function Signatures
src/tools/graphql-schema-info.tool.ts
Extended function signature with optional verbose?: string parameter
Validation & Execution Enhancements
src/tools/graphql-validate-excute.tool.ts
Added verbose?: string parameter, introduced internal DebugInfo and ToolResponse types, implemented formatResponse helper for conditional JSON debug output, enhanced error and success paths with debug metadata (validation errors, execution times, response sizes) based on verbose level ('1' or '2')

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Verbose whispers now flow through the tools,
Debug details wrapped in JSON jewels,
A carrot-coded path from start to end,
Where silence speaks when verbosity's a friend!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add verbose logging support to GraphQL tools and validators' accurately captures the main change across all modified files, which consistently adds a verbose parameter to enable structured debug output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/tools/graphql-validate-excute.tool.ts`:
- Around line 39-51: The comment is wrong because formatResponse treats the
string '0' as truthy; update formatResponse to explicitly treat verbose === '0'
as non-verbose so verbose='0' returns plain text. Change the condition that
currently reads if (!verbose) to explicitly check for undefined/null or the
string '0' (e.g., if (verbose === undefined || verbose === null || verbose ===
'0')) so formatResponse(baseResult, debugInfo) returns baseResult for those
cases and only builds the ToolResponse JSON when verbose indicates structured
output.
🧹 Nitpick comments (2)
src/tools/graphql-schema-info.tool.ts (1)

9-9: Unused verbose parameter.

The verbose parameter is added to the function signature but is never used within the function body. This appears to be dead code or an incomplete implementation. If verbose logging is intended for this tool as well, it should be implemented; otherwise, remove the parameter to avoid confusion.

Option 1: Remove unused parameter
-export function createGraphQLSchemaInfoTool(config: GraphQLProjectConfig, logger?: Logger, verbose?: string): DynamicStructuredTool {
+export function createGraphQLSchemaInfoTool(config: GraphQLProjectConfig, logger?: Logger): DynamicStructuredTool {

This would also require updating the call site in src/tools/index.ts.

src/tools/graphql-validate-excute.tool.ts (1)

128-139: Inconsistent verbose handling for error paths.

These error handling paths (Lines 128, 138) call formatResponse without debug info, while similar error paths (e.g., Lines 83-89 for execution errors, Lines 277-283 for syntax errors) do include debug info when verbose === '2'. For consistency, consider adding debug info to all error paths.

Example for line 138
-      return formatResponse(`Error executing query: ${(error as any).message}`);
+      const baseResult = `Error executing query: ${(error as any).message}`;
+      const debugInfo = verbose === '2' ? {
+        graphql_query: query,
+        execution_errors: [(error as any).message],
+        execution_time_ms: executionTime,
+      } : undefined;
+      return formatResponse(baseResult, debugInfo);

Comment on lines +39 to +51
// Helper function to format response based on verbose level
const formatResponse = (baseResult: string, debugInfo?: DebugInfo): string => {
// verbose = '0' or undefined: return plain text only
if (!verbose) {
return baseResult;
}
// verbose = '1' or '2': return structured JSON
const response: ToolResponse = { result: baseResult };
if (debugInfo) {
response._debug = debugInfo;
}
return JSON.stringify(response);
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Comment contradicts code behavior for verbose='0'.

The comment on Line 41 states verbose = '0' or undefined: return plain text only, but the condition !verbose only handles undefined (and other falsy values). The string '0' is truthy in JavaScript, so !'0' evaluates to false, causing verbose='0' to fall through to the JSON branch unintentionally.

If the intent is for '0' to mean "no verbose output", the condition should explicitly check for it:

Proposed fix
   // Helper function to format response based on verbose level
   const formatResponse = (baseResult: string, debugInfo?: DebugInfo): string => {
     // verbose = '0' or undefined: return plain text only
-    if (!verbose) {
+    if (!verbose || verbose === '0') {
       return baseResult;
     }
     // verbose = '1' or '2': return structured JSON
🤖 Prompt for AI Agents
In `@src/tools/graphql-validate-excute.tool.ts` around lines 39 - 51, The comment
is wrong because formatResponse treats the string '0' as truthy; update
formatResponse to explicitly treat verbose === '0' as non-verbose so verbose='0'
returns plain text. Change the condition that currently reads if (!verbose) to
explicitly check for undefined/null or the string '0' (e.g., if (verbose ===
undefined || verbose === null || verbose === '0')) so formatResponse(baseResult,
debugInfo) returns baseResult for those cases and only builds the ToolResponse
JSON when verbose indicates structured output.

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.

1 participant