-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Strip ACF key from response when not an object #2473
Strip ACF key from response when not an object #2473
Conversation
Deploy preview failed. Built with commit 4e771a4 https://app.netlify.com/sites/using-glamor/deploys/59e4fc970b79b77f22960842 |
Deploy preview ready! Built with commit 2066b65 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! Thanks for finding the root cause of the trouble + putting together the PR.
Could you also add a simple test as well — e.g. make up a fake entity array [{id: 1, acf: false}]
and test that acf
is gone.
// Remove the ACF key from the response when it's not an object | ||
const normalizeACF = entities => | ||
entities.map(e => { | ||
Object.keys(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to iterate over keys
👍 Will wait for tests to pass then merge/release. Thanks! |
Awesome! Sorry it took a while. Thanks for the tips! |
Hiya @crgeary! 👋 This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here. Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! 💪💜 |
Fixes: #2471
This PR removes
acf: false
from the WP API response.When a post doesn't have any ACF fields, the WP API is set to
acf: false
which breaks all posts in that post type. Instead, we should just removeacf: false
as it's not required.