hasura/graphql-engine · error

field name for relationship

Error message

field name for relationship {relationship_name} of type {type_name} conflicts with the existing field {field_name}

What it means

Schema-build error specifically for relationships: the field name configured (or defaulted) for a relationship on an object type collides with a field that already exists on that type (e.g. a column field). The relationship cannot be added without overwriting an existing field.

Solutions

  1. Rename the relationship (or set its GraphQL field name) in metadata so it differs from the existing field
  2. Alternatively rename/override the conflicting column's field name
  3. Check for duplicate relationship definitions targeting the same field name

Example fix

# before (metadata yaml)
relationships:
  author: ...
# with a column also named author
# after
relationships:
  writer: ...
  # or map the column to a different field name
Defensive patterns

Strategy: validation

Validate before calling

// Before build: relationship names must not collide with the model's field names
let field_names: HashSet<&str> = model_fields(model);
for rel in &model.relationships {
    assert!(!field_names.contains(rel.field_name()), "relationship {} conflicts", rel.name());
}

Try / catch

// Catch Error::RelationshipFieldNameConflict { relationship_name, field_name, .. } and rename the relationship in metadata

Prevention

When it happens

Trigger: Metadata defines a relationship on a model whose name (or mapped field name) equals an existing field of the same object type — commonly a column or another relationship with the same name.

Common situations: Relationship named identically to a column (e.g. both `author`), renaming fields in metadata so they clash, foreign-key relationships defaulting to the same name as a column.

Related errors


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

Appendix: source

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

        "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,
    },
    #[error(
        "internal error: duplicate aggregatable field {field_name} in the aggregate expression {aggregate_expression} is named {field_name}"
    )]
    InternalDuplicateAggregatableField {

View on GitHub (pinned to 724551b9ae)