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

Strip ACF key from response when not an object #2473

Merged
merged 3 commits into from
Oct 16, 2017
Merged

Strip ACF key from response when not an object #2473

merged 3 commits into from
Oct 16, 2017

Conversation

crgeary
Copy link
Contributor

@crgeary crgeary commented Oct 16, 2017

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 remove acf: false as it's not required.

@KyleAMathews
Copy link
Contributor

Deploy preview failed.

Built with commit 4e771a4

https://app.netlify.com/sites/using-glamor/deploys/59e4fc970b79b77f22960842

@gatsbybot
Copy link
Collaborator

gatsbybot commented Oct 16, 2017

Deploy preview ready!

Built with commit 2066b65

https://deploy-preview-2473--gatsbygram.netlify.com

Copy link
Contributor

@KyleAMathews KyleAMathews left a 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)
Copy link
Contributor

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

@KyleAMathews
Copy link
Contributor

👍

Will wait for tests to pass then merge/release. Thanks!

@crgeary
Copy link
Contributor Author

crgeary commented Oct 16, 2017

Awesome! Sorry it took a while. Thanks for the tips!

@KyleAMathews KyleAMathews merged commit f44e28c into gatsbyjs:master Oct 16, 2017
@crgeary crgeary deleted the gatsby-source-wordpress/fix-acf-boolean-response branch October 16, 2017 21:41
@jlengstorf
Copy link
Contributor

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:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

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

Successfully merging this pull request may close these issues.

4 participants