gatsby: [gatsby-source-wordpress] Cannot query field "localFile" on type "wordpress__wp_media"

We are trying to query acf/featured_image images from wordpress and following the image processing example, we are getting this error:

Cannot query field "localFile" on type "wordpress__wp_media"

This is the config entry:

{
  resolve: 'gatsby-source-wordpress',
  options: {
     baseUrl: config.baseWPUrl,
     protocol: 'https',
     hostingWPCOM: false,
     useACF: true
  }
}

And here is an example query that is failing:

{
  allWordpressWpWork(sort: {fields: [date], order: DESC}) {
    edges {
      node {
        slug
        date
        acf {
          project_image {
            localFile {
              childImageSharp {
                fluid(maxWidth: 500) {
                  ...GatsbyImageSharpFluid_withWebp
                }
              }
            }
            source_url
          }
        }
      }
    }
  }
}

We are currently using the source_url to display images hosted on wordpress:

<img src={`${config.baseWPUrl}/${work.node.acf.project_image.source_url}`}/>

But this is not ideal as some of the images are unnecessarily large (would benefit a lot from the imageSharp plugin).

We are aware of other issues opened on this matter, but none are actually solved (most are closed due to inactivity). The solution we have is working, but the site speed is impacted by this.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 15 (13 by maintainers)

Most upvoted comments

Its to do with Wordpress itself or the server where it hosted. I am 100% sure. I come cross this nasty issue while developing client projects. Initially no issue, everything goes well, it started when i uploaded more than 100+ large images in wordpress and use image optimization plugin tinyjpeg it then started. Each time i run gatsby develop at last stage it crashes. And i notice after it fails, i can’t even access Wordpress site for few minutes, it becomes inaccessible, nonresponsive. It comes back after few minutes. I think server doesn’t handle that many queries, either it has memory or bandwidth issues. For time being i am using source_url but its bad and make the site slow to load.

Update

Try this: GATSBY_CONCURRENT_DOWNLOAD=8 gatsby develop or GATSBY_CONCURRENT_DOWNLOAD=8 gatsby build

It was to do with the Soil plugin - disabling this allows the media files to be downloaded - so this all all good now.

The issue that I now have is that there are about 3500 thumbnail to get generated which takes about 5-10 mins locally, but much longer on Netlify (>24mins) which fails because it takes too long #8056

@iamtimsmith interesting - I will use the repo you have from the blogpost with my wp endpoint and try and figure out which plugin messes up with this. At least now I know the issues is not on the Gatsby side.