hasura/graphql-engine · error · ApolloError

empty keys in apollo federation configuration defined for th

Error message

empty keys in apollo federation configuration defined for the object type {object_type:}

What it means

This error is raised by the Apollo Federation resolution stage when an object type has an apolloFederation configuration block whose keys array is empty. Federation configuration on a type implies it is (or relates to) an entity, which requires at least one key; an empty keys list is treated as invalid rather than meaningless.

Source

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

    }
    Ok(())
}

#[derive(Debug, thiserror::Error)]
pub enum ApolloError {
    #[error("empty fields in apollo federation keys defined for the object type {object_type:}")]
    EmptyFieldsInApolloFederationConfigForObject {
        object_type: Qualified<CustomTypeName>,
    },

    #[error(
        "unknown field {field_name:} in apollo federation keys defined for the object type {object_type:}"
    )]
    UnknownFieldInApolloFederationKey {
        field_name: FieldName,
        object_type: Qualified<CustomTypeName>,
    },
    #[error(
        "empty keys in apollo federation configuration defined for the object type {object_type:}"
    )]
    EmptyKeysInApolloFederationConfigForObject {
        object_type: Qualified<CustomTypeName>,
    },
    #[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:}"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Either populate the keys array with at least one valid key (list of field names that exist on the type), or remove the apolloFederation block entirely from that object type.
  2. If you intended this type to be a federation entity, define proper keys and mark the corresponding model with apolloFederation.entitySource: true.

Example fix

# before
type: orders
apolloFederation:
  keys: []
# after
type: orders
apolloFederation:
  keys:
    - [id]
# (or remove the apolloFederation block entirely)
Defensive patterns

Strategy: validation

Validate before calling

fn has_keys(af: &Option<ApolloFederationConfig>) -> bool {
    af.as_ref().map(|c| !c.keys.is_empty()).unwrap_or(false)
}

Prevention

When it happens

Trigger: Adding an apolloFederation: {} or apolloFederation: keys: [] block to an object type in metadata without specifying any keys.

Common situations: Adding the apolloFederation block as scaffolding/placeholder and forgetting to fill in keys; programmatic metadata generation emitting the block only when a partial config is present; misunderstanding that entitySource alone (without keys) should be configured on the model side rather than as empty keys on the type.

Related errors


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