hasura/graphql-engine · error · NDCValidationError

Field for type referenced in model is not defined

Error message

Field {field_name} for type {type_name} referenced in model {model_name} is not defined

What it means

A model references a field of a custom object type that the type definition itself does not declare. Validation ensures each field referenced through a mapped type exists in that type's field set.

Solutions

  1. Declare the missing field on the ObjectType definition for that type
  2. Correct the field name in the model's mapping to match a declared field
  3. Regenerate/refresh metadata if types are generated from another source

Example fix

# before
# model maps field 'surname' but ObjectType User only has 'lastName'
# after
# rename mapping to 'lastName' or add field 'surname' to ObjectType User
Defensive patterns

Strategy: type-guard

Type guard

fn field_on_type(field: &FieldName, t: &ObjectTypeDefinition) -> bool { t.fields.contains(field) }

Prevention

When it happens

Trigger: Mapping a model field to type T.fieldX where T's ObjectType definition has no fieldX; adding a field to a model's type mapping without declaring it on the ObjectType.

Common situations: Renaming a field on an ObjectType but not in model mappings; adding mapped fields before declaring them; divergent copies of type definitions.

Related errors


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

Appendix: source

Thrown at v3/crates/metadata-resolve/src/helpers/ndc_validation.rs:107

    )]
    TypeCapabilityNotDefined {
        model_name: ModelName,
        field_name: FieldName,
        r#type: String,
    },
    #[error("type {0} is not defined in the agent schema")]
    NoSuchType(String),
    #[error("mapping for type {type_name} of model {model_name} is not defined")]
    UnknownModelTypeMapping {
        model_name: Qualified<ModelName>,
        type_name: Qualified<CustomTypeName>,
    },
    #[error("mapping for type {type_name} of command {command_name} is not defined")]
    UnknownCommandTypeMapping {
        command_name: Qualified<CommandName>,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "Field {field_name} for type {type_name} referenced in model {model_name} is not defined"
    )]
    UnknownTypeField {
        model_name: ModelName,
        type_name: CustomTypeName,
        field_name: FieldName,
    },
    #[error(
        "Result type of function/procedure {function_or_procedure_name:} is {function_or_procedure_output_type:} but output type of command {command_name:} is {command_output_type:}"
    )]
    FuncProcAndCommandScalarOutputTypeMismatch {
        function_or_procedure_name: String,
        function_or_procedure_output_type: String,
        command_name: String,
        command_output_type: String,
    },
    #[error(
        "Custom result type of function {function_or_procedure_name:} does not match custom output type of command: {command_name:}"

View on GitHub (pinned to 724551b9ae)