Reputation: 21
I am using WordPress, Gatsby + GraphQL to build a blog. Yesterday everything worked and I got the featured_media field but today it just stopped working and I'm getting this error telling me the that it can't query the field. (WordPress site is hosted on Bluehost).
Error
wordpress__wp_media fetched : 0
Cannot query field "featured_media" on type "wordpress__POST"
Inside GraphiQL there is indeed no featured_media field but when I use my local Wordpress website it works correctly.
gatsby-config.js file
{
resolve: 'gatsby-source-wordpress',
options: {
baseUrl: process.env.WORDPRESS_URL,
protocol: 'http',
hostingWPCOM: false,
useACF: false,
auth: {}
},
},
GraphQL query: ( this works locally )
featured_media {
alt_text
localFile {
childImageSharp {
fluid(maxWidth: 600, quality: 100) {
...GatsbyImageSharpFluid
presentationWidth
}
}
}
}
I don't have much experience making a blog with Gatsby + WordPress.
What I tried:
Better REST API Featured Images
plugin to my WordPress site but then I'm getting back only the source_url
.Upvotes: 2
Views: 805
Reputation: 352
This looks related to a persisting issue in that gatsby-source-wordpress
plugin, described here: Troubleshooting for gatsby-source-wordpress
Basically some images are coupled with a certain post_parent
in Wordpress and can become inaccessible when their post_parent
object becomes inaccessible.
The suggested solution is to edit the post_parent
manually in your Wordpress database and to set it to 0
so that changes on the post_parent
can't affect the accessibility of your image.
There is also a respecting change request for Wordpress.
Upvotes: 1
Reputation: 413
Have you trying to remove the cache with gatsby clean
when you change the sourceURL ?
Not sure that's the problem but this option solve most of mine when Gatsby don't find data in my GraphQL when I change the source url.
Hope that help you!
Upvotes: 1