Closed xerenahmed closed 3 years ago
Hey @Eren5960 ,
The query on the screenshot and the error are unlikely to be directly related. Correct me if I'm wrong, you're trying to retrieve your posts with this query? If yes, there's an important distinction between nodes and edges, where node
represents data, and edge
represents its relationship with other data, so you need nodes.
In order to get, say, all the id
s for posts, the query will look like this:
query MyQuery {
posts {
nodes {
id
}
}
}
Now to the error when Gatsby fetches these nodes. I found that my WPGraphql API returns an empty string sometimes too. gatsby-source-wordpress-experimental uses pagination when it fetches nodes, and by default it fetches 100 nodes at a time.
My issue was fixed only when I changed this value all the way down to 30 nodes per page (per request). I suggest that you try to do something similar too. See it in the docs here.
You just add it in your gatsby-config like this:
plugins: [
..., // your plugins
{
resolve: `gatsby-source-wordpress-experimental`,
options: {
..., // your options
schema: {
typePrefix: `Wp`, // your prefix
perPage: 30, // nodes per page
},
},
},
],
Please let me know if it helps.
Thank you for your help. It's solved when I use "perPage" option.
My WordPress site has 880 posts but I got errors. In WPGraphql, I saw only 10 posts in response.
Gatsby side: