hasura/graphql-engine · error · ApolloError

multiple models are marked as entity source for the object t

Error message

multiple models are marked as entity source for the object type {type_name:}

What it means

The Apollo Federation stage enforces that each object type has at most one entity source. This error fires when two or more models mapped to the same object type are all marked apolloFederation.entitySource: true, making it ambiguous which model serves entity resolutions for that type.

Source

Thrown at v3/crates/metadata-resolve/src/stages/apollo/mod.rs:69

    #[error(
        "'apolloFederation.keys' for type {object_type:} found, but no model found with 'apolloFederation.entitySource: true' for type {object_type:}"
    )]
    ApolloFederationEntitySourceNotDefined {
        object_type: Qualified<CustomTypeName>,
    },
    #[error(
        "model {model_name:} with arguments is unsupported as an Apollo Federation entity source"
    )]
    ModelWithArgumentsAsApolloFederationEntitySource { model_name: Qualified<ModelName> },

    #[error(
        "Model {model_name:} is marked as an Apollo Federation entity source but there are no keys fields present in the related object type {type_name:}"
    )]
    NoKeysFieldsPresentInEntitySource {
        type_name: Qualified<CustomTypeName>,
        model_name: ModelName,
    },
    #[error("multiple models are marked as entity source for the object type {type_name:}")]
    MultipleEntitySourcesForType {
        type_name: Qualified<CustomTypeName>,
    },
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Choose exactly one model to be the entity source for the type and set apolloFederation.entitySource: true only on it.
  2. Remove the entitySource flag (or the whole apolloFederation block) from the other models mapping to the same type_name.
  3. If both models genuinely need to serve entity data, consolidate them or expose one as a relationship/command instead.

Example fix

# before
models:
  users_table:
    graphql: { type_name: users }
    apolloFederation: { entitySource: true }
  users_api:
    graphql: { type_name: users }
    apolloFederation: { entitySource: true }
# after
models:
  users_table:
    graphql: { type_name: users }
    apolloFederation: { entitySource: true }
  users_api:
    graphql: { type_name: users }
    # entitySource removed
Defensive patterns

Strategy: validation

Validate before calling

use std::collections::HashMap;
fn single_entity_source(models: &[Model]) -> bool {
    let mut counts: HashMap<&str, usize> = HashMap::new();
    for m in models {
        if m.apollo_federation.as_ref().map(|a| a.entity_source).unwrap_or(false) {
            *counts.entry(m.graphql.type_name.as_str()).or_default() += 1;
        }
    }
    counts.values().all(|c| *c <= 1)
}

Prevention

When it happens

Trigger: Marking two models that map to the same graphql type_name with apolloFederation.entitySource: true — e.g. a table-backed model and a command-backed model both exposing the same type.

Common situations: Adding a new model for the same type (e.g. a command variant) and copying the federation flags over; refactoring one type into multiple models and leaving entitySource on both; copy-paste of model configuration blocks.

Related errors


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