Hi Dato team,
I’m running into an odd ordering issue related to publish times and the orderBy query filter. I recorded a Loom walking through the behavior, and wanted to summarize the workflow here as well.
I created a Dato demo environment and added an Order (number) field to the BlogPost model. The problem appears when a scheduled publish transitions into an actual publish, specifically around a date change.
For example, our API timezone is US Eastern. If posts are scheduled to publish at 12:01 AM EST (00:01), the moment they go live _publicationScheduledAt becomes null, and _firstPublishedAt becomes equal to _publishedAt as expected.
However, based on our sorting rule, the results should then fall back to the order field, but that does not happen.
Here’s the orderBy configuration we are using:
orderBy: [
_firstPublishedAt_DESC,
_publicationScheduledAt_DESC,
order_ASC,
_createdAt_DESC,
id_DESC
]
Once published, we would expect all three posts to sort by order_ASC, but instead the results remain sorted by their publish time.
I was able to reproduce the issue in this environment:
https://demo-4567.admin.datocms.com
I can invite anyone to access if needed.
Query and result shown below:
{
allPosts(
filter: { order: { exists: true } }
orderBy: [
_firstPublishedAt_DESC,
_publicationScheduledAt_DESC,
order_ASC,
_createdAt_DESC,
id_DESC
]
) {
id
title
_publishedAt
_firstPublishedAt
_publicationScheduledAt
order
}
}
{
"data": {
"allPosts": [
{
"id": "UiKgiPoZTsesocwVHk3gtg",
"title": "Autopublish 3",
"_publishedAt": "2025-12-05T00:01:00-05:00",
"_firstPublishedAt": "2025-12-05T00:01:00-05:00",
"_publicationScheduledAt": null,
"order": 3
},
{
"id": "Dr40xxUGRNqOIiFclfHqfQ",
"title": "Autopublish 2",
"_publishedAt": "2025-12-05T00:01:00-05:00",
"_firstPublishedAt": "2025-12-05T00:01:00-05:00",
"_publicationScheduledAt": null,
"order": 2
},
{
"id": "WCvr_A4OSlqBHPsqsZhhnw",
"title": "Autopublish 1",
"_publishedAt": "2025-12-05T00:01:00-05:00",
"_firstPublishedAt": "2025-12-05T00:01:00-05:00",
"_publicationScheduledAt": null,
"order": 1
}
]
}
}
Please let me know if this makes sense or if I can provide any additional context, happy to help however I can!
