In Graphql, I need to find how to filer like this.
first filter with Groupby and then sort by custom field and get first 10 data
Hey @maxb47163 !
Let’s consider there is a table called Posts
that exists, having expected field title
and authors
relation in your schema.
I still need some time to deal with sorting by custom field inside the grouping, but the query for your scenario will be look like this:
query groupWithSortAndFirst {
postsList(groupBy: {
query: {
authors: {
name: {
as: "authorName"
}
},
_group: {
as: "authorPosts"
}
},
sort: {
direction: ASC
alias: "authorPosts"
}, first: 10
}) {
groups {
authorName: String
authorPosts: PostGroup {
items {
id
title
}
}
}
}
}
Are you sure the grouping feature is suitable for your use case?
Can you describe it more specifically with the given schema and expected result and I will try to find the best solution with our API instruments?
Thank you for reply.
I think your answer is based on 8base service.
Does it work for pure graphql?
If not, please give me answer in pure graphql.
Thanks in advance!