Hi, experts, I just tried orderby feature, but got errors below. is that a known bug? Thanks for your help.
Query:
query Posts($orderby: [PostObjectsConnectionOrderbyInput],
$status: PostStatusEnum
){
posts(where: {status: $status, orderby: $orderby }){
edges {
node {
id
}
}
}
}
variables
{
"orderby": {
"field": "DATE",
"order": "ASC"
}
}
Error:
{
"errors": [
{
"message": "Variable \"$orderby\" got invalid value {\"field\":\"DATE\",\"order\":\"ASC\"}.\nIn element #field: Expected \"PostObjectsConnectionOrderbyInput\", found not an object.\nIn element #order: Expected \"PostObjectsConnectionOrderbyInput\", found not an object.",
"category": "graphql",
"locations": [
{
"line": 29,
"column": 13
}
]
}
]
}
@jimmyshen007 hey, you just need to update your variables to be an array, since you're telling the query to expect a list of inputs
change to:
{
"orderby": [
{
"field": "DATE",
"order": "ASC"
}
]
}
Cool! Thanks Jason. works for me!
Most helpful comment
@jimmyshen007 hey, you just need to update your variables to be an array, since you're telling the query to expect a list of inputs
change to: