From c4a00b747ef0aad232cb6a76705bfef3c6e71fde Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Mon, 13 Jul 2020 21:39:59 -0600 Subject: [PATCH 1/2] #152 - This adds support for WPGraphQL Preview --- src/class-config.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/class-config.php b/src/class-config.php index 27724e1..f675fc0 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -24,6 +24,11 @@ class Config { protected $type_registry; + /** + * @var array List of field names registered to the Schema + */ + protected $registered_field_names; + /** * Initialize WPGraphQL to ACF * @@ -48,6 +53,13 @@ public function init( \WPGraphQL\Registry\TypeRegistry $type_registry ) { $this->add_acf_fields_to_individual_posts(); $this->add_acf_fields_to_users(); $this->add_acf_fields_to_options_pages(); + + add_filter( 'graphql_resolve_revision_meta_from_parent', function( $should, $object_id, $meta_key, $single ) { + if ( in_array( $meta_key, $this->registered_field_names, true ) ) { + return false; + } + return $should; + }, 10, 4 ); } /** @@ -360,6 +372,8 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { return false; } + + /** * filter the field config for custom field types * @@ -729,7 +743,7 @@ 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 = [ @@ -1035,6 +1049,7 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { $config = array_merge( $config, $field_config ); + $this->registered_field_names[] = $acf_field['name']; return $this->type_registry->register_field( $type_name, $field_name, $config ); } From bd5df0032b886ffd86e55bef1d289178c74dcb43 Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Mon, 27 Jul 2020 07:28:12 -0600 Subject: [PATCH 2/2] - Update version for release --- wp-graphql-acf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-graphql-acf.php b/wp-graphql-acf.php index 5848415..2f07b8c 100644 --- a/wp-graphql-acf.php +++ b/wp-graphql-acf.php @@ -7,7 +7,7 @@ * Author URI: https://www.wpgraphql.com * Text Domain: wp-graphql-acf * Domain Path: /languages - * Version: 0.3.4 + * Version: 0.3.5 * Requires PHP: 7.0 * GitHub Plugin URI: https://github.com/afragen/github-updater *