hasura/graphql-engine · error · RelationshipError

The target argument {argument_name} of command {command_name

Error message

The target argument {argument_name} of command {command_name} has been mapped more than once in the relationship {relationship_name} on type {type_name}

What it means

Two or more mappings in one relationship assign values to the same target argument of the target command. Command arguments must be mapped at most once per relationship.

Source

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

    },
    #[error(
        "Mapping for source field {field_name} already exists in the relationship {relationship_name} on type {type_name}"
    )]
    MappingExistsInRelationship {
        type_name: Qualified<CustomTypeName>,
        field_name: FieldName,
        relationship_name: RelationshipName,
    },
    #[error(
        "The target argument {argument_name} of model {model_name} has been mapped more than once in the relationship {relationship_name} on type {type_name}"
    )]
    ModelArgumentMappingExistsInRelationship {
        argument_name: ArgumentName,
        model_name: Qualified<ModelName>,
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "The target argument {argument_name} of command {command_name} has been mapped more than once in the relationship {relationship_name} on type {type_name}"
    )]
    CommandArgumentMappingExistsInRelationship {
        argument_name: ArgumentName,
        command_name: Qualified<CommandName>,
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "No mapping for target command argument {argument_name} in the relationship {relationship_name} on type {type_name}"
    )]
    MissingArgumentMappingInRelationship {
        type_name: Qualified<CustomTypeName>,
        argument_name: ArgumentName,
        relationship_name: RelationshipName,
    },
    #[error(
        "The target data connector {data_connector_name} for relationship {relationship_name} on type {type_name} does not support the variables capability"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Find the colliding target-argument entries in the relationship's mappings
  2. Keep exactly one mapping per command argument and delete the duplicates

Example fix

// before
argument_mappings:
  id: author_id
  id: author_slug   # duplicate target argument 'id'
// after
argument_mappings:
  id: author_id
Defensive patterns

Strategy: validation

Validate before calling

const argTargets = Object.values(rel.argument_mappings ?? {});
const dupes = argTargets.filter((t, i) => argTargets.indexOf(t) !== i);
if (dupes.length) throw new Error(`command argument mapped twice: ${dupes}`);

Try / catch

try { await applyMetadata(md); } catch (e) { if (/of command .* has been mapped more than once/.test(e.message)) { /* dedupe */ } throw e; }

Prevention

When it happens

Trigger: Duplicate argument mappings targeting the same command argument within a single command-based relationship.

Common situations: Merged metadata contributions adding conflicting mappings; refactoring that leaves a stale duplicate.

Related errors


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