{"record":{"id":"40382be140fef087","repo":"hasura/graphql-engine","slug":"recursive-reference-detected-for-object-type-typ","errorCode":null,"errorMessage":"Recursive reference detected for object type '{type_name}' through non-null field path: {field_path}","messagePattern":"Recursive reference detected for object type '(.+?)' through non-null field path: (.+?)","errorType":"validation","errorClass":"ObjectTypesIssue","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/object_types/types.rs","lineNumber":484,"sourceCode":"    #[error(\n        \"the field {field_name:} in {type_name:} should have the type {expected:} for data connector {data_connector:} but the field has type {provided:}\"\n    )]\n    FieldTypeMismatch {\n        field_name: FieldName,\n        type_name: Qualified<CustomTypeName>,\n        data_connector: Qualified<DataConnectorName>,\n        expected: QualifiedTypeName,\n        provided: QualifiedTypeName,\n    },\n    #[error(\n        \"Field type {field_type} could not be found in field {field_name} for object type {object_type_name}\"\n    )]\n    FieldTypeNotFound {\n        field_type: Qualified<CustomTypeName>,\n        object_type_name: Qualified<CustomTypeName>,\n        field_name: FieldName,\n    },\n    #[error(\n        \"Recursive reference detected for object type '{type_name}' through non-null field path: {field_path}\"\n    )]\n    RecursiveObjectType {\n        type_name: Qualified<CustomTypeName>,\n        field_path: String,\n    },\n    #[error(\n        \"The field '{field_name}' in object type '{type_name}' cannot be mapped to data connector '{data_connector}' field '{data_connector_object}.{data_connector_column}' because: {issue}\"\n    )]\n    FieldTypeNdcMappingIssue {\n        field_name: FieldName,\n        type_name: Qualified<CustomTypeName>,\n        data_connector: Qualified<DataConnectorName>,\n        data_connector_object: DataConnectorObjectType,\n        data_connector_column: DataConnectorColumnName,\n        issue: TypeCompatibilityIssue,\n    },\n}","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/object_types/types.rs#L466-L502","documentation":"A cycle was detected in object type fields where every field along the path is non-null: an object type transitively contains itself through required (non-null) fields. Such layouts cannot be represented (they imply infinite nesting) and resolution aborts.","triggerScenarios":"Type A has a non-null field of type B, and B has a non-null field of type A (or A → A directly); nullable fields would be fine, but the non-null chain creates the invalid recursion.","commonSituations":"Modeling bidirectional relationships (parent/child, author/posts) with required fields on both sides; self-referencing structures like trees with a required 'parent' field.","solutions":["Make at least one field in the cycle nullable (remove the non-null/! marker on that field)","Restructure the model to break the cycle (e.g. represent one side as a relationship instead of a required nested field)","Use an explicit relationship with argument mapping instead of a direct nested non-null object field"],"exampleFix":"// before\n{\"name\":\"parent\",\"type\":\"Category!\"} // in Category itself\n// after\n{\"name\":\"parent\",\"type\":\"Category\"} // nullable breaks the cycle","handlingStrategy":"validation","validationCode":"// Build a nullability-aware graph and reject non-null cycles\nfunction hasNonNullCycle(types) {\n  const g = buildNonNullGraph(types); // edge only for non-null object fields\n  return detectCycle(g);\n}\nif (hasNonNullCycle(objectTypes)) throw new Error('Non-null recursive object type');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model bidirectional links as relationships rather than required nested fields","Make at least one side of any cycle nullable by design"],"tags":["hasura","metadata","object-types","recursion","nullability"],"backgroundTag":"circular-reference","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}