Reputation: 1649
I'm having issues on another relation. I want the ability to sort on the column title that is in the relation on the front end. Here's my setup:
extend type Query {
entries(first: Int!,
page: Int,
type: String @eq,
site_id: ID @eq,
orderBy: _ @orderBy(
columns: ["created_at", "published_at"],
relations: [{ relation: "content", columns: ["title"] }]
)
): [Entry!]! @paginate
}
export const ALL_SITE_ENTRIES = gql`
query Entries(
$first: Int!,
$page: Int,
$type: String,
$site_id: ID,
$title: Mixed = null,
$orderBy: [EntriesOrderByOrderByClause!]) {
entries(
first: $first,
page: $page,
type: $type,
site_id: $site_id,
hasContent: {column: TITLE, operator: LIKE, value: $title},
orderBy: $orderBy
) {
data {
...EntryDetails
content{
id
title
status
}
}
paginatorInfo {
currentPage
lastPage
total
}
}
}
${EntryDetailsFragment}
`
Now according to the documentation on sorting, this should be fine. Published at and created at work just fine and dandy. When I try to sort on title, by
My Apollo call:
this.$apollo.addSmartQuery('entries', {
query: ALL_SITE_ENTRIES,
fetchPolicy: 'no-cache',
variables() {
return {
type: this.entryType,
site_id: null,
blog_type: this.siteSettings.blog_type,
first: 25,
page: this.selectedPage,
orderBy: [{content: {column: 'TITLE'}, order: 'DESC'}],
}
},
});
I get the error Expected type EntriesOrderByColumn at value[0].field
. Published at works with just: [{field: 'PUBLISHED_AT', order: 'DESC'}]
I'm getting mixed signals from the errors and what the documentation says. Help?
Upvotes: 0
Views: 1167
Reputation: 1
Well... I'm not the best on GraphQL, but had the same question and found the answer that worked for me.
Try replacing:
$orderBy: [EntriesOrderByOrderByClause!]) {
by:
$orderBy: [EntriesOrderByRelationOrderByClause!]) {
Upvotes: 0