Skip to content

Fix GraphQL syntax errors with empty fragments in client directive processing #4608

@yomybaby

Description

@yomybaby

Fix critical GraphQL syntax errors that occur when client directives (@SInCE, @deprecatedSince, @skipOnClient) remove all fields from fragments, leaving empty fragment definitions and orphaned fragment spreads.

Background/Purpose

The current GraphQL transformer implementation has a critical bug where client directives that remove all fields from fragments create invalid GraphQL syntax. This causes two types of errors:

  1. Empty fragment definitions without selection sets (e.g., fragment AgentStatsFragment on Query)
  2. Fragment spreads referencing non-existent fragments (e.g., ...AgentStatsFragment when the fragment was removed)

These errors break GraphQL query execution in components like DashboardPage when backend versions don't support certain features.

Acceptance Criteria

  • GraphQL transformer properly handles fragments emptied by client directives
  • No syntax errors when client directives remove all fragment fields
  • No "Unknown fragment" errors for orphaned fragment spreads
  • Generated GraphQL queries remain valid and executable
  • Maintains backward compatibility with existing functionality

Technical Impact

  • Prevents runtime GraphQL errors in production
  • Improves robustness of client-side query transformation
  • Ensures proper version compatibility handling

JIRA Issue: FR-1663

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions