Sorting grouped data

I’m trying to sort grouped data by a field with createdAt that can be null. I see “alias” and “direction” used in the docs, but I get errors if I try to use those:

https://docs.8base.com/docs/8base-console/graphql-api/grouping-and-aggregations/

    sort: [
      { alias: "authorPosts", direction: DESC }
    ],

How can I sort the groups themselves?

On a similar note, I’m getting “Unknown column ‘featureCreatedAt’ in ‘order clause’” in the following query. The example shows sorting by an alias in the query section, so looks like it should work:

query {
  epicsList(groupBy: {
    query: {
      feature: {
        title: {
          as: "featureTitle"
        }
        createdAt: {
          as: "featureCreatedAt"
        }
      }
      _group: {
        as: "epics"
      }
    }, sort: {
      alias: "featureCreatedAt", direction: ASC
    }
  }) {
    groups {
      featureTitle: String
      epics: EpicGroup {
        items {
          title
        }
      }
    }
  }
}

this error message is wrong. We will fix it.

To solve the issue you just need to add “featureCreatedAt” to your output
I.e.

    groups {
      featureTitle: String
      featureCreatedAt: Date   <---- here
      epics: EpicGroup {
        items {
          title
        }
      }
    }

As for the first message, I am not sure I understand what’s the issue is. Can you please give me more detailed example.

Thanks

Thank you Evgeny, I definitely missed adding the field definition in groups, and is now working when I add it. groupBy is becoming very useful to bring in data that may have null references to other tables.