0

I'm using the fantastic WPGraphQL plugin and also the WPGraphQL for ACF plugin.

So far I have been able to query by an ACF custom field of type String, but now I want to query by another field (also String) inside a repeater field.

When I add the repeater field using the regular functions to register the field and the where clause, the GraphiQL IDE page doesn't load, so there's probably an Internal Server Error.

Here is my code. I have tried both "Repeater" and "repeater" (lower case) as the type.

register_graphql_field('Post', 'matchedProducts', [
    'description' => 'The matched products of the post object',
    'type' => 'repeater',
    'resolve' => function(\WPGraphQL\Model\Post $post) {
        return get_post_meta($post->databaseId, 'matched_products', true);
    }
]);
register_graphql_field('RootQueryToPostConnectionWhereArgs', 'matchedProducts', [
    'type' => 'repeater',
    'description' => 'Query posts by matched products',
]);
Sean H
  • 1,045
  • 1
  • 14
  • 32

0 Answers0