Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gatsby-source-wordpress] ACF not working when there actually is ACF data #2417

Closed
garytokyo opened this issue Oct 11, 2017 · 10 comments
Closed

Comments

@garytokyo
Copy link

I am having an issue whereby if there are no ACF fields attached to Posts or Pages then the acf field is available to use in graphiql. See screenshot:

screen shot 2017-10-11 at 12 09 14

When I attach a test field group to Posts the acf field is no longer available and will error saying you cannot use that field on the type wordpress__POST (same for posts or pages):

screen shot 2017-10-11 at 11 48 31

I am using ACF Pro (latest) and I have latest acf to rest plugin and latest versions of gatsby and gatsby-source-wordpress. ACF pro was working fine in older version of gatsby and wordpress source plugin when you had to do:

childWordpressAcfField {
    internal {
      content
   }
}

that query no longer seems to do anything though even though the docs still say this is how to do it.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Oct 11, 2017

Does the using-wordpress example site work for you? Can you grep through .cache/redux-state.json in your site to see if your acf data is there?

@garytokyo
Copy link
Author

garytokyo commented Oct 11, 2017

@KyleAMathews the acf data IS in redux-state.json and it shows the correct fields for pages that do have ACF attached.

@KyleAMathews
Copy link
Contributor

Hmmm but the schema isn't being generated correctly then? Just to double-check, you're refreshing graphiql when you restart gatsby develop to get the latest schema?

@garytokyo
Copy link
Author

Correct the schema is not being generated correctly. Yes and just to be sure I deleted .cache and ran develop again to rebuild .cache. The acf field is correct again in redux-state.json but if I try and run a GraphQL query on the page with the acf field on I get the error.

query aboutPageQuery {
  wordpressPage(wordpress_id: {eq: 7}) {
    title
    content
    slug
    acf
  }
}

results in

{
  "errors": [
    {
      "message": "Cannot query field \"acf\" on type \"wordpress__PAGE\".",
      "locations": [
        {
          "line": 73,
          "column": 5
        }
      ]
    }
  ]
}

And that is the page that has the correct acf data in redux-state.json.

@garytokyo
Copy link
Author

@KyleAMathews is there anything else I can try on this?

@KyleAMathews
Copy link
Contributor

Are you on gatsby-source-wordpress v2?

Did you verify that the using-wordpress site works?

@akmur
Copy link

akmur commented Oct 15, 2017

I have the same issue,, and for me using-wordpress works, while using my own wp install it does not.
I also get the acf fields in redux-state.json

@KyleAMathews
Copy link
Contributor

This should be fixed by @chrisgeary92 in #2471!

The issue turned out to be that if you had a post without acf, the API returns acf:false which causes all the acf fields to be removed as Gatsby ignores fields with conflicting types. The fix was to just remove the acf: false data.

Try out gatsby-source-wordpress@2.0.21 and see if things are working for ya!

@garytokyo
Copy link
Author

@KyleAMathews Can confirm this fixed my issue thank you very much. Sorry never got back to you from your last reply been away from work.

@KyleAMathews
Copy link
Contributor

@garytokyo great! Glad it's working. Credit goes to @chrisgeary92 though as he debugged the issue and wrote the PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants