1. 15
    Expose WordPress Advanced Custom Field (ACF) Plugin Data to the GraphQL Endpoint
    1m 16s

Expose WordPress Advanced Custom Field (ACF) Plugin Data to the GraphQL Endpoint

Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

The data that is added to the REST API through Advanced Custom Fields (ACF) is also not present automatically in our GraphQL endpoint.

You'll be used to the problem and workflow to fix the issue now.

In this lesson, we will add the wp-graphql-acf plugin which allows us to expose ACF data to our GraphQL endpoint. There's even a UI to flip the switch here.

Instructor: [0:00] One thing that's missing from our GraphQL endpoint is the ACF fields that we've added to our custom post type. To expose those, we're going to have to add another plugin, wp-graphql-acf. Let's download that zip file. Add a new plugin. Upload our plugin. Choose our file, install, and activate.

[0:18] Now if we go to our custom field and to our custom field type and scroll to the bottom, we see we know I have this option to show in GraphQL, which we're going to set to true. We have to give a field name for GraphQL. I normally call this ACF in every instance, and alias it when it returns to my frontend. Let's update that, click on GraphQL.

[0:38] We can see we have ACF available to us with the material price and weight that we added to our chair type. The material here is plastic. Price is 70, and the weight is 10. They didn't exist in the second one. We did not add them to our original post.

[0:52] In the frontend, when lots of GraphQL queries have been amalgamated, we sometimes have a huge width having the same field name. We can alias these fields to be the CHAR-ACF fields, which then would appear that way.

[1:05] We an alias them during the GraphQL query, and keep this consistently ACF. This is how I normally do this, but it is possible instead to have this as CHAR-ACF fields to begin with.

~ 15 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today