From dd680eb5c06700f9c0b43a762f7870670f9c971b Mon Sep 17 00:00:00 2001 From: Dave Mackey Date: Thu, 14 May 2020 15:32:49 -0400 Subject: [PATCH 1/3] Changed "my" to "by" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6f3f92..fda368f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Whatever method you use to register ACF fields to your WordPress site should wor The first step in using Advanced Custom Fields with WPGraphQL is to [create an ACF Field Group](https://www.advancedcustomfields.com/resources/creating-a-field-group/). -By default, field groups are _not_ exposed to WPGraphQL. You must opt-in to expose your ACF Field Groups and fields to the WPGraphQL Schema as some information managed my your ACF fields may not be intended for exposure in a queryable API like WPGraphQL. +By default, field groups are _not_ exposed to WPGraphQL. You must opt-in to expose your ACF Field Groups and fields to the WPGraphQL Schema as some information managed by your ACF fields may not be intended for exposure in a queryable API like WPGraphQL. #### Show in GraphQL Setting From 51a271d3b5b47efc5de16c0fd57dee629129b95d Mon Sep 17 00:00:00 2001 From: Seagyn Davis Date: Wed, 27 May 2020 16:19:56 +0200 Subject: [PATCH 2/3] Add Composer command I came here looking for it and saw it was missing. I hope there's no specific reason for this. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fda368f..c7392e0 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ To install the plugin from Github, you can [download the latest release zip file [Click here](https://wordpress.org/support/article/managing-plugins/) to learn more about installing WordPress plugins from a Zip file. ### Installing from Composer -`@todo` + +`composer require wp-graphql/wp-graphql-acf` ## Dependencies In order to use WPGraphQL for Advanced Custom Fields, you must have [WPGraphQL](https://github.com/wp-graphql/wp-graphql) and [Advanced Custom Fields](https://advancedcustomfields.com) (free or pro) installed and activated. From a19bd33b7ad8a970aacf168ca40a45d94a48fca3 Mon Sep 17 00:00:00 2001 From: Seagyn Davis Date: Tue, 9 Jun 2020 09:07:25 +0200 Subject: [PATCH 3/3] Add support for select & radio in Taxonomy fields --- src/class-config.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/class-config.php b/src/class-config.php index 91d2dc6..27724e1 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -729,19 +729,25 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { $type = $tax_object->graphql_single_name; } } + + $is_multiple = isset($acf_field['field_type']) && in_array( $acf_field['field_type'], array('checkbox', 'multi_select')); $field_config = [ - 'type' => [ 'list_of' => $type ], - 'resolve' => function( $root, $args, $context, $info ) use ( $acf_field ) { + 'type' => $is_multiple ? ['list_of' => $type ] : $type, + 'resolve' => function( $root, $args, $context, $info ) use ( $acf_field, $is_multiple ) { $value = $this->get_acf_field_value( $root, $acf_field ); - $terms = []; + /** + * If this is multiple, the value will most likely always be an array. + * If it isn't, we want to return a single term id. + */ if ( ! empty( $value ) && is_array( $value ) ) { foreach ( $value as $term ) { $terms[] = DataSource::resolve_term_object( (int) $term, $context ); } + return $terms; + } else { + return DataSource::resolve_term_object( (int) $value, $context ); } - - return $terms; }, ]; break;