How to increase the WPGraphQL query limit using graphql_connection_max_query_amount
Overview
By default, WPGraphQL limits the amount of posts per page that you can query at any one time to 100.
As per the WPGraphQL documentation the reasoning for this is:
The default is 100 to prevent queries from being exceedingly resource intensive, however individual systems can override this for their specific needs.
While the warning about the default value being set low is sensible, there are many valid reasons as to why you would want to increase this value.
For example, maybe you want to get a full list of all post titles and you have more than 100 posts on your site. Or maybe you need to add all your posts and their corresponding publication date and URL to a sitemap.xml file.
Solution: Add new function and filter
In your functions.php file within your Wordpress theme, add the following code snippet:
// This will return a maximum of 200 queries - adjust to suit.
add_filter('graphql_connection_max_query_amount',
function (int $max_amount, $source, array $args, $context, $info) {
return 200;
}, 10, 5);