• Resolved austinkeener

    (@austinkeener)


    Hello,

    As a user of the GraphiQL IDE I want to query all of the blog posts that have been added to my webistes WordPress CMS.

    _____________________________________________________________
    First solution that I tried:

    When I query posts by slug I currently receive the first 10 posts.

    query MyQuery {
      posts {
        edges {
          node {
            slug
          }
        }
      }
    }

    ____________________________________________________________
    Second solution that I tried:

    If I try including a depth to the results (first:1000) then I am still receiving only 20% of the posts instead of all 850 of them.

    query MyQuery {
      posts(first: 1000) {
        edges {
          node {
            slug
          }
        }
      }
    }

    _____________________________________________________________
    Third solution that I tried:

    When I go to the general settings for WPGraphQL, check “Enable Query Depth Limiting”, and then change the “Max Depth to allow for GraphQL Queries” to something closer to 1000, I am still only receiving around 20% of posts in my query results.

    I have searched for information on this topic through the forums and have not found a solution.

    Any advice?

    Thanks,
    Austin
    Atlanta Creative Consulting
    Atlanta, Georgia

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jason Bahl

    (@jasonbahl)

    @austinkeener Thanks for using WPGraphQL!

    Sorry this has been difficult to accomplish for you.

    Large requests, like posts(first:1000){ can lead to client and server performance issues.

    This is why WPGraphQL limits to a max of 100 nodes by default. We’re trying to keep both the server and the client working well.

    The more data that the WordPress server needs to process in a single request, the slower the requests are to process and return. This can lead to server issues and can definitely lead to slower client applications.

    The recommended solution here is to make paginated requests.

    You can read more about making paginated with WPGraphQL requests here:

    https://www.wpgraphql.com/2020/03/26/forward-and-backward-pagination-with-wpgraphql/

    Plugin Author Jason Bahl

    (@jasonbahl)

    @austinkeener I should also share, there is a way to increase the limit on the server.

    I typically recommend against this, because of the performance issues / user experience issues that can ensue, but here’s some information on that:

    Hi, this indeed does not work at all, including the solution offered by plugin author. I tested with wp 6.0 will test again with wp 5.8 to see if that’s the issue.

    I’m able to query unlimited amount of posts but limited to query up to 10 menu items. Why is that?

    add_filter( 'graphql_connection_max_query_amount', function( $amount, $source, $args, $context, $info  ) {
        if(current_user_can( 'manage_options')) {
             $amount = 1000; // increase post limit to 1000
        }
        return $amount;
    }, 10, 5 );

    ^^ Do I need to add to function to also remove query limit for menu items?

    • This reply was modified 2 years, 9 months ago by ogwebchef.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘GraphiQL IDE: get more results in query’ is closed to new replies.