hasura/graphql-engine · error

duplicate field name {field_name} generated while building o

Error message

duplicate field name {field_name} generated while building object type {type_name}

What it means

Internal schema-build error: while generating the object type for a model, two generated fields ended up with the same name. The generator creates fields for columns, relationships, commands, etc., and a naming collision was detected via a name→field map insert.

Source

Thrown at v3/crates/graphql/schema/src/lib.rs:321

    InternalObjectTypeFieldNotFound {
        type_name: Qualified<CustomTypeName>,
        field_name: FieldName,
    },
    #[error(
        "internal error while building schema, role {role} not found in argument presets for model {model_name}"
    )]
    InternalModelArgumentPresetLookupFailure {
        model_name: Qualified<ModelName>,
        role: Role,
    },
    #[error(
        "internal error while building schema, role {role} not found in argument presets for command {command_name}"
    )]
    InternalCommandArgumentPresetLookupFailure {
        command_name: Qualified<CommandName>,
        role: Role,
    },
    #[error("duplicate field name {field_name} generated while building object type {type_name}")]
    DuplicateFieldNameGeneratedInObjectType {
        field_name: ast::Name,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "field name for relationship {relationship_name} of type {type_name} conflicts with the existing field {field_name}"
    )]
    RelationshipFieldNameConflict {
        relationship_name: RelationshipName,
        field_name: ast::Name,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "the aggregation function {field_name} conflicts with the aggregatable field {field_name} in the aggregate expression {aggregate_expression} is named {field_name}. Either rename the aggregation function or the field"
    )]
    AggregationFunctionFieldNameConflict {
        aggregate_expression: Qualified<AggregateExpressionName>,
        field_name: ast::Name,

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Rename the relationship/command/custom field in metadata so its generated field name differs from the colliding field
  2. Check the reported field_name and type_name to identify which two producers generated it
  3. Remove any custom field_name overrides that duplicate an existing field
Defensive patterns

Strategy: validation

Validate before calling

// Scan model metadata for generated-name collisions before building
let mut seen = HashSet::new();
for f in columns_fields.iter().chain(rel_fields.iter()).chain(cmd_fields.iter()) {
    assert!(seen.insert(f.graphql_name()), "duplicate field {}", f.graphql_name());
}

Try / catch

// Catch Error::DuplicateFieldNameGeneratedInObjectType { field_name, type_name, .. } and rename the offending metadata object

Prevention

When it happens

Trigger: Building the GraphQL schema when a model has a column and a relationship (or command/aggregate field) whose generated GraphQL field names collide, e.g. a column `posts` and a relationship also named `posts`.

Common situations: Naming a relationship the same as an existing column, custom GraphQL field name overrides in metadata that clash, or command names colliding with column names.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/3609f62a3931c556. Report an issue: GitHub.