hasura/graphql-engine · error · ObjectTypesIssue

the field {field_name:} in {type_name:} should have the type

Error message

the field {field_name:} in {type_name:} should have the type {expected:} for data connector {data_connector:} but the field has type {provided:}

What it means

A field on a custom object type has a declared type that differs from the type the resolver computed it should have for the given data connector. Expected vs provided are both printed as qualified type names, so the mismatch is usually visible directly in the message.

Source

Thrown at v3/crates/metadata-resolve/src/stages/object_types/types.rs:466

        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "Multiple {function_name} aggregate functions found for type {scalar_type} in data connector {data_connector_name}"
    )]
    DuplicateAggregateFunctionsDefined {
        scalar_type: ndc_models::ScalarTypeName,
        function_name: String,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "Multiple {function_name} extraction functions found for type {scalar_type} in data connector {data_connector_name}"
    )]
    DuplicateExtractionFunctionsDefined {
        scalar_type: ndc_models::ScalarTypeName,
        function_name: String,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "the field {field_name:} in {type_name:} should have the type {expected:} for data connector {data_connector:} but the field has type {provided:}"
    )]
    FieldTypeMismatch {
        field_name: FieldName,
        type_name: Qualified<CustomTypeName>,
        data_connector: Qualified<DataConnectorName>,
        expected: QualifiedTypeName,
        provided: QualifiedTypeName,
    },
    #[error(
        "Field type {field_type} could not be found in field {field_name} for object type {object_type_name}"
    )]
    FieldTypeNotFound {
        field_type: Qualified<CustomTypeName>,
        object_type_name: Qualified<CustomTypeName>,
        field_name: FieldName,
    },
    #[error(

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Compare the expected/provided types in the message and update the field's type in the custom type definition to match
  2. If the database column type changed, re-track the table / refresh the connector schema and update metadata accordingly
  3. Align the data_connector_scalar_type mappings so the connector's type resolves to the declared Hasura type

Example fix

// before
{"field_name":"age","type":"String"} // column is int
// after
{"field_name":"age","type":"Int"}
Defensive patterns

Strategy: validation

Validate before calling

// Compare declared field type with the mapped NDC column type
const ndcType = ndcSchema.object_types[obj].fields[col]?.type;
if (!typesCompatible(field.type, mapNdcType(ndcType))) throw new Error(`Field ${field.name} type mismatch`);

Prevention

When it happens

Trigger: A field mapping resolves to a different NDC type than the field's declared Hasura type — e.g. field declared as String while the connector column type maps to Int, or a nested object field whose mapped target type differs.

Common situations: Changing a column type in the database without updating metadata; mismatched type mappings in data_connector_scalar_type entries; connector version changing its type mapping for a scalar.

Related errors


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