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

Commit

Permalink
Merge commit 'c5c36a4079f2bf6f71c32ac53e4e4f0d5e27d185' into release/…
Browse files Browse the repository at this point in the history
…v0.3.1
  • Loading branch information
jasonbahl committed Dec 13, 2019
2 parents e0dea5c + c5c36a4 commit 35753df
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ protected function register_graphql_field( $type_name, $field_name, $config ) {
} else {
$type_names = [];
foreach ( $acf_field['post_type'] as $post_type ) {
if ( in_array( $post_type, \WPGraphQL::get_allowed_post_types(), true ) ) {
if ( in_array( $post_type, \get_post_types( [ 'show_in_graphql' => true ]), true ) ) {
$type_names[ $post_type ] = get_post_type_object( $post_type )->graphql_single_name;
}
}
Expand Down Expand Up @@ -547,7 +547,22 @@ protected function register_graphql_field( $type_name, $field_name, $config ) {
return new Post( $value );
}

return absint( $value ) ? DataSource::resolve_post_object( (int) $value, $context ) : null;
/**
* This hooks allows for filtering of the post object source. In case an non-core defined
* post-type is being targeted.
*
* @param mixed|null $source GraphQL Type source.
* @param mixed|null $value Root ACF field value.
* @param AppContext $context AppContext instance.
* @param ResolveInfo $info ResolveInfo instance.
*/
return apply_filters(
'graphql_acf_post_object_source',
absint( $value ) ? DataSource::resolve_post_object( (int) $value, $context ) : null,
$value,
$context,
$info
);

},
];
Expand Down

0 comments on commit 35753df

Please sign in to comment.