reactjsfiltergraphqlgraphcms

How to filter (remove) first x items in hygraph api (graphql)?


I am currently getting all posts with the hygraph api. But i like to filter the first x items out of that result set. All posts minus the first x items, No idea how to do it. I am using the graphql api from hygraph formerly known as graphcms. Help is appreciated, thanks.

export const getPosts = async () => {
  const query = gql`
    query MyQuery {
        postsConnection(orderBy: created_DESC) {
            edges {
                node {
                    author {
                        bio
                        name
                        id
                        photo {
                            url
                        }
                    }
                    created
                    updatedAt
                    slug
                    title
                    excerpt
                    featuredImage {
                        url
                    }
                    localizations {
                        id
                        locale
                        content {
                            raw
                        }
                    }
                    categories {
                        name
                        slug
                    }
                    words
                }
            }
        }
    }
`
const results = await graphQLClient.request(query);
return results.postsConnection.edges;

};


Solution

  • try skip in your query param

    query {
      products(skip: x) {
        id
      }
    }
    

    https://hygraph.com/docs/api-reference/content-api/pagination#nested-pagination