Skip to content

Filter contentNodes by author #2761

Answered by marco910
marco910 asked this question in Q&A
Discussion options

You must be logged in to vote

Already solved this by using a custom action which looks like this:

function register_custom_graphql_types() {

    // Add the field `author` to the `where` arguments of the `contentNodes` query
    register_graphql_field('RootQueryToContentNodeConnectionWhereArgs', 'author', [
        'type' => 'Integer',
        'description' => __("Filter by the userId of the user that's connected as the author of the object", 'wp-graphql'),
    ]);

}
add_action('graphql_register_types', 'register_custom_graphql_types');

This adds the field author to the where arguments of the contentNodes query and will filter the results by the specified author id.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marco910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant