hasura/graphql-engine · error · RelayError
Model {model_name:} is marked as a global ID source but ther
Error message
Model {model_name:} is marked as a global ID source but there are no global id fields present in the related object type {type_name:} What it means
Relay stage error: a model is marked globalIdSource: true, but the object type it implements declares no globalIdFields. The model has nothing to derive the Relay global ID from, so metadata resolution fails.
Source
Thrown at v3/crates/metadata-resolve/src/stages/relay/mod.rs:32
// - Throw an error if no model with globalIdSource:true is found for the object type.
for (object_type, model_name_list) in global_id_enabled_types {
if model_name_list.is_empty() {
return Err(RelayError::GlobalIdSourceNotDefined { object_type });
}
}
Ok(())
}
#[derive(Debug, thiserror::Error)]
pub enum RelayError {
#[error(
"'globalIdFields' for type {object_type:} found, but no model found with 'globalIdSource: true' for type {object_type:}"
)]
GlobalIdSourceNotDefined {
object_type: Qualified<CustomTypeName>,
},
#[error(
"Model {model_name:} is marked as a global ID source but there are no global id fields present in the related object type {type_name:}"
)]
NoGlobalFieldsPresentInGlobalIdSource {
type_name: Qualified<CustomTypeName>,
model_name: ModelName,
},
#[error(
"Found multiple models {model_1:}, {model_2:} that implement the same object type {object_type:} to be global ID sources."
)]
DuplicateModelGlobalIdSource {
model_1: Qualified<ModelName>,
model_2: Qualified<ModelName>,
object_type: Qualified<CustomTypeName>,
},
#[error("model {model_name:} with arguments is unsupported as a global ID source")]
ModelWithArgumentsAsGlobalIdSource { model_name: Qualified<ModelName> },
}
View on GitHub (pinned to 724551b9ae)
Solutions
- Add globalIdFields (e.g. the primary key field list) to the object type named in the error
- Or remove globalIdSource: true from the model if Relay IDs are not wanted for that type
- Ensure the field names listed exist on the object type
Example fix
# before kind: ObjectType name: User # model User has globalIdSource: true # after kind: ObjectType name: User globalIdFields: [id]
Defensive patterns
Strategy: validation
Validate before calling
fn check_global_id_fields_present(models: &[Model], types: &[ObjectType]) -> Result<(), String> {
for m in models {
if !m.global_id_source { continue; }
let t = types.iter().find(|t| t.name == m.object_type)
.ok_or("model type missing")?;
if t.global_id_fields.is_empty() {
return Err(format!("model {} is globalIdSource but type {} has no globalIdFields", m.name, t.name));
}
}
Ok(())
} Try / catch
downcast RelayError::NoGlobalFieldsPresentInGlobalIdSource and surface model_name/type_name in CI logs
Prevention
- Never set globalIdSource without confirming the type lists globalIdFields
- Remove the flag when removing globalIdFields during cleanup
When it happens
Trigger: Setting globalIdSource: true on a model whose object type lacks a globalIdFields entry; adding the flag before annotating the type; renaming fields out of globalIdFields.
Common situations: Copy-pasting a Relay-enabled model config onto a type that was never prepared for global IDs; removing globalIdFields during a cleanup pass while leaving the model flag in place.
Related errors
- 'globalIdFields' for type {object_type:} found, but no model
- Found multiple models {model_1:}, {model_2:} that implement
- model {model_name:} with arguments is unsupported as a globa
- Relationship {relationship_name} could not be found for type
- Multiple relationships named {relationship_name} defined for
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/7f62d86bace31142.
Report an issue: GitHub.