hasura/graphql-engine · error · RelationshipError

Relationship mappings from value expressions are not support

Error message

Relationship mappings from value expressions are not supported yet.

What it means

The relationship mapping used a literal/value expression as the mapping source instead of a field reference. Value-expression mappings are recognized by the parser but not yet implemented in the resolver, so any such mapping fails immediately.

Source

Thrown at v3/crates/metadata-resolve/src/stages/object_relationships/error.rs:155

    ModelAggregateExpressionError {
        type_name: Qualified<CustomTypeName>,
        relationship_name: RelationshipName,
        error: models::ModelsError, // ideally, this would return the more accurate
                                    // `ModelAggregateExpressionError` instead
    },
    #[error(
        "The source field '{source_field_name}' of type '{source_field_type}' in the relationship '{relationship_name}' on type '{source_type}' cannot be mapped to the target argument '{target_argument_name}' of type '{target_argument_type}' on the target model '{target_model_name}' because their types are incompatible"
    )]
    ModelArgumentTargetMappingTypeMismatch {
        source_type: Qualified<CustomTypeName>,
        relationship_name: RelationshipName,
        source_field_name: FieldName,
        source_field_type: QualifiedTypeReference,
        target_model_name: Qualified<ModelName>,
        target_argument_name: ArgumentName,
        target_argument_type: QualifiedTypeReference,
    },
    #[error("Relationship mappings from value expressions are not supported yet.")]
    ValueExpressionMappingsNotSupportedYet,
    #[error(
        "The field path provided in the {location:} of the relationship {relationship_name} on type {type_name} is empty"
    )]
    EmptyFieldPath {
        location: String,
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "Model fields cannot be used in command based relationship: {relationship_name:} on type {type_name:}"
    )]
    ModelFieldCannotBeUsedInCommandRelationship {
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error("Relationships with nested field paths are not supported yet.")]
    NestedFieldPathsNotSupportedYet,

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Replace the value expression with a mapping from an actual source field (add the field to the source type if needed)
  2. Give the target argument a default value in the command/model metadata instead of mapping a constant
  3. Wait for/upgrade to a version that supports value-expression mappings

Example fix

// before
argument_mappings:
  limit: { value: 10 }
// after
# add a field to the source type and map it:
fields: [ ..., page_size ]
argument_mappings:
  limit: page_size
Defensive patterns

Strategy: validation

Validate before calling

for (const v of Object.values(rel.argument_mappings ?? {})) {
  if (typeof v === 'object' && v !== null && 'value' in v) {
    throw new Error('value-expression mappings are not supported yet');
  }
}

Try / catch

try { await applyMetadata(md); } catch (e) { if (/value expressions are not supported/.test(e.message)) { /* switch to field mapping or default */ } throw e; }

Prevention

When it happens

Trigger: Writing a relationship mapping whose source is `{ value: ... }` / an inline literal expression rather than `{ field: ... }`.

Common situations: Trying to pass constants to command/model arguments via mappings on current engine versions.

Related errors


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