gatsbyjs/gatsby-source-wordpress-experimental

An empty string was returned instead of a response on "Post" type.

Closed this issue · 2 comments

My WordPress site has 880 posts but I got errors. In WPGraphql, I saw only 10 posts in response.
image

Gatsby side:

...
warning  gatsby-source-wordpress  

An empty string was returned instead of a response when making a GraphQL request.
This may indicate that you have a WordPress filter running which is causing WPGraphQL
to return an empty string instead of a response.
Please open an issue with a reproduction at
https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/issues/new
for more help

Error occurred while fetching nodes of the "Post" type.

success  gatsby-source-wordpress  Post - 3.736s - fetched 0
success  gatsby-source-wordpress  Category - 4.366s - fetched 41
...

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 ids 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.