hasura/graphql-engine · error · GraphqlConfigError

invalid directions: {directions} defined in orderByInput of

Error message

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

What it means

Raised when an enumTypeNames entry in GraphqlConfig.orderByInput defines only a subset of directions (only 'asc' or only 'desc') instead of both. Partial direction enums are unsupported because every orderBy input needs both sort directions. The message interpolates the offending {directions}.

Source

Thrown at v3/crates/metadata-resolve/src/stages/graphql_config/error.rs:36

    MissingOffsetFieldInGraphqlConfig,
    #[error(
        "the filterInput needs to be defined in GraphqlConfig, when models have filterExpressionType"
    )]
    MissingFilterInputFieldInGraphqlConfig,
    #[error(
        "the orderByInput needs to be defined in GraphqlConfig, when models have orderByExpressionType"
    )]
    MissingOrderByInputFieldInGraphqlConfig,
    #[error(
        "the orderByInput.enumTypeNames needs to be defined in GraphqlConfig, when models have orderByExpressionType"
    )]
    MissingOrderByEnumTypeNamesInGraphqlConfig,
    #[error(
        "only one enumTypeNames can be defined in GraphqlConfig, whose direction values are both 'asc' and 'desc'."
    )]
    MultipleOrderByEnumTypeNamesInGraphqlConfig,
    #[error(
        "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"
    )]
    InvalidOrderByDirection { directions: String },
    #[error(
        "the fieldName for argumentsInput needs to be defined in GraphqlConfig, when models have argumentsInputType"
    )]
    MissingArgumentsInputFieldInGraphqlConfig,
    #[error(
        "the filterInputFieldName for aggregate needs to be defined in GraphqlConfig, when models have a selectAggregate graphql API"
    )]
    MissingAggregateFilterInputFieldNameInGraphqlConfig,
    #[error("\"{name:}\" is not a valid GraphQL name.")]
    InvalidGraphQlName { name: String },
    #[error("multiple graphql types found with the same name: {graphql_type_name:}")]
    ConflictingGraphQlType { graphql_type_name: ast::TypeName },
}

impl ContextualError for GraphqlConfigError {
    fn create_error_context(&self) -> Option<error_context::Context> {

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Set the entry's directions to include both keys, e.g. {"asc": "asc", "desc": "desc"} (values may be customized, keys must be both present)
  2. Check for typos/casing in the direction keys — they must be exactly 'asc' and 'desc'
  3. If you intended a one-way sort, note it is unsupported; use a full asc/desc enum

Example fix

// before
"enumTypeNames": [{"name": "SortDir", "directions": {"asc": "asc"}}]
// after
"enumTypeNames": [{"name": "SortDir", "directions": {"asc": "asc", "desc": "desc"}}]
Defensive patterns

Strategy: validation

Validate before calling

for e in &order_by.enum_type_names {
    assert!(e.directions.contains_key("asc") && e.directions.contains_key("desc"),
        "enum {} must define both asc and desc, got: {:?}", e.name, e.directions);
}

Type guard

fn directions_complete(e: &EnumTypeName) -> bool {
    e.directions.contains_key("asc") && e.directions.contains_key("desc")
}

Try / catch

Err(GraphqlConfigError::InvalidOrderByDirection { directions }) => { /* log directions, fix enum to include both asc and desc, re-resolve */ }

Prevention

When it happens

Trigger: GraphqlConfig.orderByInput.enumTypeNames contains an entry whose `directions` map lacks either 'asc' or 'desc'; resolution of metadata with orderBy models fails with the invalid directions listed.

Common situations: Hand-writing a direction enum and forgetting one member; mapping both directions to the same value; copying an enum from another schema that only sorts ascending; casing mistakes that make a direction unrecognizable.

Related errors


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