Orderings sometimes does not work, Next.js

Hello, I am using the orderings to order the results by first publication date, however this works works in one my components and does not work in the other.

Here is the working one:

  const searchValue = query.v;
  const currentPage = query.page === 1 ? 1 : query.page;

  try {
    const postsData = await client.query(
      [
        Prismic.Predicates.at("document.type", "blog_post"),

        Prismic.Predicates.fulltext("document", searchValue),
      ],

      {
        orderings: "[my.blog_post.first_publication_date desc]",
        pageSize: 12,
        page: currentPage,
      }

    );

    return {
      props: { postsData, searchValue },
    };

  } catch (err) {
    console.error(err);
  }
}

Here is the one that does not work:

export const getStaticProps = async (context) => {

  const client = Client();
  const postsData = await client.query(
    Prismic.Predicates.at("document.type", "blog_post"),
    {
      orderings: "[my.blog_post.first_publication_date desc]",
      pageSize: 10,
    }
  );

  return {
    revalidate: 10,
    props: { postsData },
  };

};

Hi Kęstutis,

Welcome to the Prismic community,
I'm trying to reproduce this on my end and I will get back to you soon.

Fares

Thank you for the quick reply! I also wanted to add that the working example was inside of getServerSideProps function. Not sure if that changes anything, but thought it was important to mention.

Hi,

I apologize for the delay.

Have you tried to use the API browser to test your queries, does it work when using the rest API? have you tried to log postsData in both queries? do they have the expected data in the right order?

For me, it seems that the issue is in your code, but I try to debug this issue with you, to do so can you share with us your repository name (in a private message if necessary)?

Looking forward to your reply,
Fares

This issue has been closed due to inactivity. Flag to reopen.