hasura/graphql-engine · error · Error
cannot merge fields with different arguments on the same ali
Error message
cannot merge fields with different arguments on the same alias: {alias} What it means
Thrown by the FieldsCanMerge rule when two fields merged under the same response key pass different arguments, e.g. `{ f(field: A), f(field: B) }` or the same aliased field with different argument sets via fragments. Fields that merge into one response entry must either share identical arguments or not take conflicting ones; the error reports the alias and both source positions (Option<spanning::SourcePosition>) so you can jump to both occurrences in the document.
Source
Thrown at v3/crates/graphql/lang-graphql/src/validation/error.rs:67
field_name: ast::Name,
},
#[error(
"different fields {field1} and {field2} cannot be merged under the same alias: {alias}"
)]
FieldsConflictDifferentFields {
alias: ast::Alias,
field1: ast::Name,
field2: ast::Name,
},
#[error(
"fields of different type {type1} and {type2} cannot be merged under the same alias: {alias}"
)]
FieldsConflictDifferingTypes {
alias: ast::Alias,
type1: ast::Type,
type2: ast::Type,
},
#[error("cannot merge fields with different arguments on the same alias: {alias}")]
FieldsConflictDifferingArguments {
alias: ast::Alias,
location1: Option<spanning::SourcePosition>,
location2: Option<spanning::SourcePosition>,
},
#[error("the string {str} in the provided json value is not a valid GraphQL name")]
NotAValidName { str: String },
#[error("expected a value of type {expected_type} but found a value of type {actual_type}")]
IncorrectFormat {
expected_type: &'static str,
actual_type: &'static str,
},
#[error("a null value found when expected a value of not nullable type: {expected_type}")]
UnexpectedNull { expected_type: ast::Type },
#[error("the field {field_name} on type {type_name} is not found")]
InputFieldNotFound {
type_name: ast::TypeName,
field_name: ast::Name,View on GitHub (pinned to 724551b9ae)
Solutions
- Give each variant a distinct alias (`{ first: user(id: 1), second: user(id: 2) }`)
- Make the arguments identical across all occurrences if a single merged result is intended
- Check fragments spread into the same selection set for duplicated fields with differing arguments
Example fix
// before
{ user(id: 1) { name } user(id: 2) { name } }
// after
{ u1: user(id: 1) { name } u2: user(id: 2) { name } } Defensive patterns
Strategy: validation
Validate before calling
for (key, fields) in group_by_response_key(selection) { for w in fields.windows(2) { assert!(same_args(&w[0].arguments, &w[1].arguments), "alias {key} used with differing arguments"); } } Type guard
fn same_args(a: &[(Name, Value)], b: &[(Name, Value)]) -> bool { a == b } Try / catch
match validate(doc) { Err(Error::FieldsConflictDifferingArguments { alias, .. }) => give_unique_alias(alias), r => r } Prevention
- Always alias repeated fields that differ in arguments
- Check fragments combined into one scope for repeated fields with different args
- Let a query builder deduplicate selections by (field, args)
When it happens
Trigger: Repeating a field with the same alias but different argument values (e.g. `user(id: 1)` and `user(id: 2)` without distinct aliases); fragments that select the same field with different arguments spread into the same scope; default arguments applied differently to two occurrences.
Common situations: Querying the same connection with different filters and forgetting distinct aliases; generated fragments (e.g. pagination or list fragments) reusing a field with varying arguments; copy-pasted selections where arguments were edited in one copy only.
Related errors
- fields of different type {type1} and {type2} cannot be merge
- '{alias:} is not a valid alias
- different fields {field1} and {field2} cannot be merged unde
- unable to fetch introspection schema: %w
- error in fetching introspection schema: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/835271603be246ee.
Report an issue: GitHub.