{"record":{"id":"6753a8ba93390dcb","repo":"hasura/graphql-engine","slug":"the-orderbyinput-needs-to-be-defined-in-graphqlcon","errorCode":null,"errorMessage":"the orderByInput needs to be defined in GraphqlConfig, when models have orderByExpressionType","messagePattern":"the orderByInput needs to be defined in GraphqlConfig, when models have orderByExpressionType","errorType":"validation","errorClass":"GraphqlConfigError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/graphql_config/error.rs","lineNumber":23,"sourceCode":"#[derive(Debug, thiserror::Error)]\npub enum GraphqlConfigError {\n    #[error(\"graphql configuration is not defined in supergraph\")]\n    MissingGraphqlConfig,\n    #[error(\"graphql configuration should be defined only once in supergraph\")]\n    MultipleGraphqlConfigDefinition,\n    #[error(\n        \"the fieldName for limitInput needs to be defined in GraphqlConfig, when models have a selectMany graphql API\"\n    )]\n    MissingLimitFieldInGraphqlConfig,\n    #[error(\n        \"the fieldName for offsetInput needs to be defined in GraphqlConfig, when models have a selectMany graphql API\"\n    )]\n    MissingOffsetFieldInGraphqlConfig,\n    #[error(\n        \"the filterInput needs to be defined in GraphqlConfig, when models have filterExpressionType\"\n    )]\n    MissingFilterInputFieldInGraphqlConfig,\n    #[error(\n        \"the orderByInput needs to be defined in GraphqlConfig, when models have orderByExpressionType\"\n    )]\n    MissingOrderByInputFieldInGraphqlConfig,\n    #[error(\n        \"the orderByInput.enumTypeNames needs to be defined in GraphqlConfig, when models have orderByExpressionType\"\n    )]\n    MissingOrderByEnumTypeNamesInGraphqlConfig,\n    #[error(\n        \"only one enumTypeNames can be defined in GraphqlConfig, whose direction values are both 'asc' and 'desc'.\"\n    )]\n    MultipleOrderByEnumTypeNamesInGraphqlConfig,\n    #[error(\n        \"invalid directions: {directions} defined in orderByInput of GraphqlConfig , currently there is no support for partial directions. Please specify a type which has both 'asc' and 'desc' directions\"\n    )]\n    InvalidOrderByDirection { directions: String },\n    #[error(\n        \"the fieldName for argumentsInput needs to be defined in GraphqlConfig, when models have argumentsInputType\"\n    )]","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/graphql_config/error.rs#L5-L41","documentation":"Raised when a model declares an `orderByExpressionType` but the GraphqlConfig does not define `orderByInput`. Order-by support requires a named orderBy input argument in the GraphQL schema, which must be configured. Thrown during the graphql_config resolution stage.","triggerScenarios":"Metadata contains a model with orderByExpressionType while GraphqlConfig lacks the `orderByInput` entry; resolution of this metadata fails.","commonSituations":"Adding sorting capabilities to models without updating the shared graphql config; migrations from older metadata versions where orderByInput was optional; partial configs written by hand.","solutions":["Add `orderByInput: {fieldName: \"order_by\"}` to GraphqlConfig","Also define its enumTypeNames since orderBy support requires the direction enum (see the companion error)","Regenerate metadata with current templates"],"exampleFix":"// before\n{\"graphql\": {}, \"models\": [{\"orderByExpressionType\": \"users_order_by\"}]}\n// after\n{\"graphql\": {\"orderByInput\": {\"fieldName\": \"order_by\", \"enumTypeNames\": [{\"name\": \"OrderByDirection\", \"directions\": {\"asc\": \"asc\", \"desc\": \"desc\"}}]}}, \"models\": [{\"orderByExpressionType\": \"users_order_by\"}]}","handlingStrategy":"validation","validationCode":"let uses_order = models.iter().any(|m| m.order_by_expression_type.is_some());\nif uses_order {\n    assert!(config.order_by_input.as_ref().is_some_and(|o| o.field_name.is_some()));\n}","typeGuard":"fn order_by_ok(config: &GraphqlConfig, models: &[Model]) -> bool {\n    !models.iter().any(|m| m.order_by_expression_type.is_some())\n        || config.order_by_input.as_ref().is_some_and(|o| o.field_name.is_some())\n}","tryCatchPattern":"Err(GraphqlConfigError::MissingOrderByInputFieldInGraphqlConfig) => { /* add orderByInput.fieldName and re-resolve */ }","preventionTips":["Add orderByInput (with enumTypeNames) whenever enabling orderByExpressionType","Mirror filter config setup when adding sort config","Validate metadata in CI"],"tags":["graphql","metadata","orderby","validation"],"backgroundTag":"missing-graphql-config-field","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}