Skip to content

Fix GraphQL response parsing for pathless errors#404

Open
jstar0 wants to merge 1 commit into
cloudflare:mainfrom
jstar0:fix/graphql-pathless-errors
Open

Fix GraphQL response parsing for pathless errors#404
jstar0 wants to merge 1 commit into
cloudflare:mainfrom
jstar0:fix/graphql-pathless-errors

Conversation

@jstar0

@jstar0 jstar0 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Fix GraphQL MCP response parsing for valid GraphQL API responses that omit optional
error metadata. This keeps the tool from replacing actionable API messages with a
Zod invalid_union validation dump.

Fixes #402.

Changes

  • Relax the GraphQL error schema so path, locations, and extensions can be
    omitted or null where GraphQL permits it.
  • Allow successful GraphQL responses to omit the top-level errors field.
  • Add regression coverage for pathless GraphQL errors, path: null errors with
    custom extensions, and successful responses without errors.

Verification

pnpm --filter graphql-mcp-server test
pnpm --filter graphql-mcp-server check:types
pnpm --filter graphql-mcp-server check:lint
pnpm exec prettier apps/graphql/src/tools/graphql.tools.ts apps/graphql/src/tools/graphql.tools.spec.ts apps/graphql/vitest.config.ts apps/graphql/tsconfig.json --check

@jstar0 jstar0 force-pushed the fix/graphql-pathless-errors branch from c693d7a to dcc5d8e Compare June 21, 2026 00:05

@18488292860-coder 18488292860-coder 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.

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.

GraphQL MCP: strict Zod response schema crashes with opaque invalid_union on any GraphQL error that lacks a path (masks auth/validation/mutation errors)

2 participants