facebook/relay · error
Cannot print empty selections for {name}. Please, check tran
Error message
Cannot print empty selections for {name}. Please, check transforms that may produce invalid selections. What it means
Panic in print_selections while serializing an operation or fragment to GraphQL text: the selection set is empty after printing began. The text printer cannot emit a valid selection set with zero fields, so a transform upstream produced an invalid definition (e.g. a fragment left with all fields stripped). The message names the definition to inspect.
Source
Thrown at compiler/crates/graphql-text-printer/src/print_to_text.rs:268
let len = selections.len();
if len > 0 {
self.print_optional_space()?;
write!(self.writer, "{{")?;
self.indentation += 1;
self.print_new_line(true)?;
for (i, selection) in selections.iter().enumerate() {
self.print_selection(selection, None)?;
if i != len - 1 {
self.print_item_separator()?;
}
}
self.indentation -= 1;
self.print_new_line(true)?;
write!(self.writer, "}}")?;
} else {
panic!(
"Cannot print empty selections for {name}. Please, check transforms that may produce invalid selections."
);
}
Ok(())
}
fn print_selection(
&mut self,
selection: &Selection,
conditions: Option<Vec<&Condition>>,
) -> FmtResult {
match selection {
Selection::ScalarField(field) => self.print_scalar_field(field, conditions),
Selection::LinkedField(field) => self.print_linked_field(field, conditions),
Selection::FragmentSpread(field) => self.print_fragment_spread(field, conditions),
Selection::InlineFragment(field) => self.print_inline_fragment(field, conditions),
Selection::Condition(field) => self.print_condition(field, conditions),
}View on GitHub (pinned to 668b1b85e0)
Solutions
- Identify which transform runs before printing removed all selections from the named definition
- Guard custom transforms to skip or prune definitions that would end up with empty selection sets
- Ensure @include/@skip directives don't statically remove every field of a fragment
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at compiler/crates/graphql-text-printer/src/print_to_text.rs:268 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/2e858f5870d10c33.
Report an issue: GitHub.