Gatsby: Cannot query localFile on wordpress__wp_media

Created on 11 May 2018  路  3Comments  路  Source: gatsbyjs/gatsby

hello - I was following the example provided in the wordpress plugin, however when I tried adding the localFile part to my query I get GraphQL Error Unknown field 'localFile' on type 'wordpress__wp_media'

```
featured_media {
source_url
localFile {
childImageSharp {
sizes(maxWidth: 500) {
...GatsbyImageSharpSizes_withWebp
}
}
}
}

All 3 comments

Hey @b0gd4n, it's really difficult to help with the amount of information here. Could you open a new issue and fill out the issue template? Ideally post a link to a GitHub repo that demonstrates the problem. Thanks.

In the meantime, this issue might be useful? https://github.com/gatsbyjs/gatsby/issues/2492

I've created a more detailed issue for this, as I am having exactly the same problem out of nowhere: https://github.com/gatsbyjs/gatsby/issues/6273

To add some more details to this...

I know Gatsby dynamically creates the schemas from your data source(s), but is there something on wordpress's side I need to do in order to see the localFile property in featured_media?

I've been trying to understand why localFile isn't present in my schema for a while now. And I am constantly seeing examples like in the Gatsby gatsby-source-wordpress plugin docs. But when I copy a query like this:

{
  allWordpressPost {
    edges {
      node {
        title
        featured_media {
          localFile {
            childImageSharp {
              fixed{
                src
              }
            }
          }
        }
      }
    }
  }
}

into my GraphiQL editor, I get this error:

{
  "errors": [
    {
      "message": "Cannot query field \"localFile\" on type \"wordpress__wp_media\".",
      "locations": [
        {
          "line": 8,
          "column": 11
        }
      ]
    }
  ]
}

Both @m-allanson and @filipetedim links are regarding acf fields and featured_media which isn't quite the same here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  路  3Comments

benstr picture benstr  路  3Comments

totsteps picture totsteps  路  3Comments

timbrandin picture timbrandin  路  3Comments

jimfilippou picture jimfilippou  路  3Comments