Skip to content

Conversation

tobias-tengler
Copy link
Member

@tobias-tengler tobias-tengler commented Oct 10, 2025

If either all selections on the root level or below a lookup are conditional, we can pull out those conditions directly onto the execution node and skip execution entirely, if the conditions are not met.

For example for this operation

query testQuery($skip: Boolean!) {
  productBySlug(slug: "product") @skip(if: $skip) {
    name
  }
}

we can generate this execution node

- id: 1
  type: Operation
  schema: A
  operation: |
    query testQuery_60827aef_1 {
      productBySlug(slug: "product") {
        name
      }
    }
  conditions:
    - variable: $skip
      passingValue: false

This PR does not yet account for all edge cases that come with this.
For a fully functional solution we'll also have to rewrite the SelectionSetPartitioner as it's currently not preserving conditional inline fragments around selections.

@tobias-tengler tobias-tengler force-pushed the tte/fusion-conditional-nodes branch 3 times, most recently from f8a11f9 to c270543 Compare October 11, 2025 19:53
@tobias-tengler tobias-tengler force-pushed the tte/fusion-conditional-nodes branch from c270543 to c7bddb8 Compare October 12, 2025 21:51
@tobias-tengler tobias-tengler force-pushed the tte/fusion-conditional-nodes branch from c7bddb8 to f7068c9 Compare October 12, 2025 21:52
@tobias-tengler tobias-tengler marked this pull request as ready for review October 12, 2025 21:53
@Copilot Copilot AI review requested due to automatic review settings October 12, 2025 21:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for conditions to execution plan nodes in the Fusion GraphQL system. The changes enable the execution planner to extract conditional directives (@Skip and @include) from GraphQL operations and represent them as execution node conditions, allowing for optimized conditional execution.

Key changes:

  • Added ExecutionNodeCondition class to represent conditional directives
  • Extended execution nodes with condition support and evaluation logic
  • Updated execution planner to extract and process conditional selections
  • Modified serialization/deserialization to handle node conditions

Reviewed Changes

Copilot reviewed 77 out of 77 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Test snapshot files Updated to reflect new condition and forwardedVariables fields in execution plans
ConditionalTests.cs Added comprehensive test cases for conditional directive handling across different scenarios
WorkItem.cs Changed visibility from public to internal for planning components
OperationPlanStep.cs Added Conditions property and Lookup field to plan steps
NodeFieldPlanStep.cs Added Conditions property and renamed from NodePlanStep
Various planning files Updated to support condition extraction and node field work items
ExecutionNode classes Added condition support with evaluation logic in base ExecutionNode
Serialization classes Updated formatters and parsers to handle conditions in JSON/YAML output

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tobias-tengler tobias-tengler merged commit 46afcc8 into main Oct 12, 2025
110 checks passed
@tobias-tengler tobias-tengler deleted the tte/fusion-conditional-nodes branch October 12, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant