{"record":{"id":"5690e8c5e8081aaa","repo":"hasura/graphql-engine","slug":"different-fields-field1-and-field2-cannot-be-m","errorCode":null,"errorMessage":"different fields {field1} and {field2} cannot be merged under the same alias: {alias}","messagePattern":"different fields (.+?) and (.+?) cannot be merged under the same alias: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/validation/error.rs","lineNumber":51,"sourceCode":"    },\n    #[error(\"no such field on type {type_name}: {field_name}\")]\n    NoFieldOnType {\n        type_name: ast::TypeName,\n        field_name: ast::Name,\n    },\n    #[error(\"no such type defined in the document: {0}\")]\n    UnknownType(ast::TypeName),\n    #[error(\"an internal error occurred during validation: type lookup failed for {type_name}\")]\n    InternalTypeNotFound { type_name: ast::TypeName },\n    #[error(\n        \"an internal error occurred during validation: field {field_name} lookup failed for sub type '{sub_type_name}' of type '{type_name}'\"\n    )]\n    InternalNoFieldOnSubtype {\n        type_name: ast::TypeName,\n        sub_type_name: ast::TypeName,\n        field_name: ast::Name,\n    },\n    #[error(\n        \"different fields {field1} and {field2} cannot be merged under the same alias: {alias}\"\n    )]\n    FieldsConflictDifferentFields {\n        alias: ast::Alias,\n        field1: ast::Name,\n        field2: ast::Name,\n    },\n    #[error(\n        \"fields of different type {type1} and {type2} cannot be merged under the same alias: {alias}\"\n    )]\n    FieldsConflictDifferingTypes {\n        alias: ast::Alias,\n        type1: ast::Type,\n        type2: ast::Type,\n    },\n    #[error(\"cannot merge fields with different arguments on the same alias: {alias}\")]\n    FieldsConflictDifferingArguments {\n        alias: ast::Alias,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/validation/error.rs#L33-L69","documentation":"Thrown by the FieldsCanMerge validation rule when two fields responded to the same alias resolve to different field names, e.g. `{ a: petName, a: product }`. Since only one value can be returned per alias, differing field names cannot be merged and the document is rejected with the alias and both field names.","triggerScenarios":"Aliasing two different fields to the same alias in one selection set (`{ x: fieldA, x: fieldB }`), including across fragments spread into the same scope; copy-paste of selections while forgetting to update the alias; conflicting fields defined in different fragments that are spread together.","commonSituations":"Merging fragments from different modules that happen to alias different fields identically; query builders deduplicating by alias and silently collapsing distinct fields; refactoring that renames a field but keeps the alias.","solutions":["Give each field a unique alias (`{ x: fieldA, y: fieldB }`)","If the fields are meant to be the same, correct the duplicate so both selections use the same field name","Audit fragments combined into one operation for alias collisions"],"exampleFix":"// before\n{ x: petName, x: product }\n// after\n{ pet: petName, prod: product }","handlingStrategy":"validation","validationCode":"let mut keys = HashSet::new(); for f in all_fields_in_scope(selection) { let key = f.alias.as_ref().unwrap_or(&f.name); assert!(keys.insert(key.clone()), \"duplicate response key {key} with different fields\"); }","typeGuard":"fn same_field(a: &Field, b: &Field) -> bool { a.name == b.name }","tryCatchPattern":"match validate(doc) { Err(Error::FieldsConflictDifferentFields { alias, .. }) => rename_alias(alias), r => r }","preventionTips":["Use unique aliases for distinct fields","Lint for duplicate response keys in merged selections","When combining fragments, audit overlapping field names"],"tags":["graphql","alias-conflict","fields-merge","validation"],"backgroundTag":"graphql-fields-conflict","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}