facebook/relay · error
Duplicate operation definitions named {name}: first one: {
Error message
Duplicate operation definitions named {name}:
first one: {loc:?}
second one: {another:?}
What it means
Panic while constructing a Program::from_definitions: two operation definitions in the same compilation unit share the same name. The first occurrence's source location and the duplicate's location are printed. Operations must be uniquely named because generated artifacts and the operation map are keyed by operation name.
Source
Thrown at compiler/crates/graphql-ir/src/program.rs:52
fragments: Default::default(),
operations: Default::default(),
}
}
pub fn from_definitions(
schema: Arc<SDLSchema>,
definitions: Vec<ExecutableDefinition>,
) -> Self {
let mut operations = Vec::new();
let mut fragments = HashMap::default();
let mut seen_operation_loc = HashMap::new();
for definition in definitions {
match definition {
ExecutableDefinition::Operation(operation) => {
let loc = operation.name.location;
let name = operation.name.item;
if let Some(another) = seen_operation_loc.insert(name, loc) {
panic!(
"\nDuplicate operation definitions named {name}: \nfirst one: {loc:?}\nsecond one: {another:?}\n"
);
}
operations.push(Arc::new(operation)); // Keep the order the operations same as inputs.
}
ExecutableDefinition::Fragment(fragment) => {
let loc = fragment.name.location;
let name = fragment.name.item;
if let Some(another) = fragments.insert(name, Arc::new(fragment)) {
panic!(
"\nDuplicate fragment definitions named {}: \nfirst one: {:?}\nsecond one: {:?}\n",
name, loc, &another.name.location
);
}
}
}
}
Self {View on GitHub (pinned to 668b1b85e0)
Solutions
- Rename one of the colliding operations so each name is unique
- Delete or exclude the duplicated file from the compiler sources
- If using multiple --src globs, make sure the same file isn't included twice
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at compiler/crates/graphql-ir/src/program.rs:52 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/4d15fac680b45594.
Report an issue: GitHub.