Reputation: 4035
I am using GatsbyJS and GraphQL. The problem I am facing is there are too many results so it is timing out and breaking the project 50% of the time. Making development a slow and annoying hit or miss process. Right now I am limiting the page to one result doing something like this:
{articles.data[0].title}
Is there a way to limit the number of results returned by GraphQL in or before my query? For example can I just look for the first ten results and load only those?'
Example Query (I am only querying a few items):
export const GatsbyQuery = graphql`
{
articleHub {
articles {
data {
title
subtitle
}
}
}
}
`
Upvotes: 0
Views: 4278
Reputation: 1569
You can use limit
to get only a certain amount of data: https://www.gatsbyjs.org/docs/graphql-reference/#limit
Upvotes: 2