Skip to content

Strip __fragments field for non-query operations from fat/broad query#623

Merged
alloy merged 4 commits intomicrosoft:mainfrom
ikjot-2605:user/ikjotdhody/strip_fragments_field_for_non_query_ops
Jan 7, 2026
Merged

Strip __fragments field for non-query operations from fat/broad query#623
alloy merged 4 commits intomicrosoft:mainfrom
ikjot-2605:user/ikjotdhody/strip_fragments_field_for_non_query_ops

Conversation

@ikjot-2605
Copy link

Strip __fragments field for non-query operations from fat/broad query

Subscriptions with fragment spreads were failing with errors about __fragments field not being found in the schema.

Root cause:

annotateFragmentReferenceTransform adds "... on Node { __fragments @client }" to all operations with fragment spreads. For queries, stripFragmentReferenceFieldSelectionTransform removes this from executionQueryDocument before output. For subscriptions/mutations, this stripping was being skipped.

Fix:

Move the stripping logic outside the "if (emitNarrowObservables)" block so it runs for all operation types, not just queries.

@alloy
Copy link
Member

alloy commented Jan 7, 2026

Thanks! Can you see what test coverage we have for this, presumably only for a query, and run the same test for subscription/mutation docs?

@ikjot-2605
Copy link
Author

ikjot-2605 commented Jan 7, 2026

Thanks! Can you see what test coverage we have for this, presumably only for a query, and run the same test for subscription/mutation docs?

The tests for stripFragmentReferenceFieldSelectionTransform seem to be covering the main cases. We can still test if a subscription/mutation doc is passed to this helper - it must strip it off the __fragments field.

The tests for formatModule test that mutation and subscription operations "do(es) not add watch node queries for subscriptions". However it does not currently test that the execution document should be stripped off the __fragments @client field.

Added tests in both files. @alloy

@ikjot-2605
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Member

@alloy alloy left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks!

@alloy alloy merged commit 0313839 into microsoft:main Jan 7, 2026
1 of 2 checks passed
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.

3 participants