Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge commit '01577deb0a474f5387d60d3680a69ff810bddf35' into release/…
Browse files Browse the repository at this point in the history
…v0.3.5
  • Loading branch information
jasonbahl committed Jul 27, 2020
2 parents bd5df00 + 01577de commit 40c2f3f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Config {

protected $type_registry;

/**
* @var array <string> List of field names registered to the Schema
*/
protected $registered_field_names;

/**
* Initialize WPGraphQL to ACF
*
Expand All @@ -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 );
}

/**
Expand Down Expand Up @@ -360,6 +372,8 @@ protected function register_graphql_field( $type_name, $field_name, $config ) {
return false;
}



/**
* filter the field config for custom field types
*
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit 40c2f3f

Please sign in to comment.