Can someone point me to the API docs that reference getting the latest "number" results of a particular type?
For example, I would like to get the most recent "n" results of a content type that is being created.
Can someone point me to the API docs that reference getting the latest "number" results of a particular type?
For example, I would like to get the most recent "n" results of a content type that is being created.
Hey Tom,
I’ll be happy to help, but I just want to be sure what you mean. You want to for example do something like “Get the latest 12 blog posts”? Also what technology are you using?
Thanks.
Thank you Phil for the quick response. I appreciate it.
And yes, exactly. “Get the latest 12 blog posts” would be perfect.
We are using Node and GraphQL.
OK in that case you would use a combination of the SortBy (to get the latest)and first (to get less than 20 docs) arguments in your query to make a query like:
query{
allBlog_posts(sortBy:meta_firstPublicationDate_DESC, first:12){
edges{
node{
title
_meta{
firstPublicationDate
}
}
}
}
}
You can read more about sortBy here:
https://prismic.io/docs/graphql/query-the-api/order-your-results#6_0-sort-by-publication-date
Also the first argument here:
Reading about pagination in Prismic’s GraphQL api might help too:
https://prismic.io/docs/graphql/query-the-api/paginate-your-results
Perfect. Thank you. I appreciate it.