FragmentResolver

Resolves fragment references in operations by inlining fragment definitions.

Fragment references (...FragmentName) are replaced with InlineFragment nodes containing the fragment's selection set. The AstTransformer recursively visits transformed nodes, so nested fragment references are resolved automatically.

The resolution proceeds in distinct phases:

  1. Transitive reachability — computes the full transitive closure of fragment names reachable from each operation's direct fragment spreads. Missing fragment definitions cause immediate failure.

  2. Cycle detection — validates that no cycles exist among reachable fragments.

  3. Inlining — replaces each FragmentSpread with an InlineFragment carrying the definition's selection set, type condition, and any directives (e.g. @include, @skip) from the original spread node.

  4. Invariant check — verifies no named fragment spreads remain after inlining.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard

Resolves all fragment references in all operations.