{"record":{"id":"7af0e0b6755d2675","repo":"hasura/graphql-engine","slug":"the-orderable-field-field-name-in-model-mode","errorCode":null,"errorMessage":"The orderable field '{field_name}' in model '{model_name}' is not a scalar field (type: {field_type}) and therefore cannot be used for ordering. Upgrade to version 2 Models and use OrderByExpressions to order by nested fields","messagePattern":"The orderable field '(.+?)' in model '(.+?)' is not a scalar field \\(type: (.+?)\\) and therefore cannot be used for ordering\\. Upgrade to version 2 Models and use OrderByExpressions to order by nested fields","errorType":"validation","errorClass":"ModelsIssue","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/models/types.rs","lineNumber":108,"sourceCode":"}\n\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]\npub struct NDCFieldSourceMapping {\n    pub ndc_mapping: BTreeMap<FieldName, NdcColumnForComparison>,\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum ModelsIssue {\n    #[error(\n        \"An issue occurred while mapping arguments in the model {model_name:} to the collection {collection_name:} in the data connector {data_connector_name:}: {issue:}\"\n    )]\n    FunctionArgumentMappingIssue {\n        data_connector_name: Qualified<DataConnectorName>,\n        model_name: Qualified<ModelName>,\n        collection_name: CollectionName,\n        issue: ArgumentMappingIssue,\n    },\n    #[error(\n        \"The orderable field '{field_name}' in model '{model_name}' is not a scalar field (type: {field_type}) and therefore cannot be used for ordering. Upgrade to version 2 Models and use OrderByExpressions to order by nested fields\"\n    )]\n    ModelV1OrderableFieldIsNotAScalarField {\n        model_name: Qualified<ModelName>,\n        field_name: FieldName,\n        field_type: QualifiedTypeReference,\n    },\n    #[error(\n        \"The orderable field '{field_name}' in model '{model_name}' is an array type (type: {field_type}) and therefore cannot be used for ordering\"\n    )]\n    ModelV1OrderableFieldIsAnArrayType {\n        model_name: Qualified<ModelName>,\n        field_name: FieldName,\n        field_type: QualifiedTypeReference,\n    },\n    #[error(\n        \"The order by expression '{order_by_expression_identifier}' used in model '{model_name}' contains a nested field '{nested_field_name}', however the data connector '{data_connector_name}' used in the model does not support ordering by nested fields\"\n    )]","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/models/types.rs#L90-L126","documentation":"In a v1 model, a field listed in orderable_fields is not a scalar field (e.g. an object or relationship) so it cannot be used for ordering. v1 models only support ordering by scalar fields.","triggerScenarios":"Adding a nested/object-typed field to orderable_fields in a model whose type is an object or object-array rather than a scalar.","commonSituations":"Trying to expose ordering on a nested field with v1 model syntax; migrating object models where relationships were mistakenly marked orderable.","solutions":["Remove the non-scalar field from orderable_fields","Upgrade to version 2 Models and use OrderByExpressions to order by nested fields","Restructure the model so the field is a scalar"],"exampleFix":"# before\norderable_fields:\n  - field: user  # object field\n# after (v2 model)\norder_by_expressions:\n  - name: user_name\n    expression:\n      field: user\n      then: name\n","handlingStrategy":"validation","validationCode":"// only scalar fields may be orderable in v1\nfor f in &model.orderable_fields {\n    assert!(is_scalar(&model.type_.fields[f]), \"field {} is not scalar\", f);\n}","typeGuard":"const isScalarField = (t) => t.type.kind === 'scalar';","tryCatchPattern":null,"preventionTips":["Use v2 models with order_by_expressions for nested ordering","Validate orderable_fields against the type schema in CI"],"tags":["hasura","models","orderable-fields","v1-models","graphql"],"backgroundTag":"schema-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}