Skip to content

Instantly share code, notes, and snippets.

@jasonbahl
Created November 5, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonbahl/f7c109f363f3de74dc4f847ca398a9ad to your computer and use it in GitHub Desktop.
Save jasonbahl/f7c109f363f3de74dc4f847ca398a9ad to your computer and use it in GitHub Desktop.
add_action( 'init_graphql_request', function() {
$analyzer = null;
add_action( 'graphql_determine_graphql_keys', function( \WPGraphQL\Utils\QueryAnalyzer $query_analyzer, $query ) use ( &$analyzer ) {
$analyzer = $query_analyzer;
}, 10, 2 );
add_filter( 'graphql_query_analyzer_get_runtime_nodes', function( $nodes ) use ( &$analyzer ) {
if ( 'operation:GetPostsForBlog' === $analyzer->get_operation_name() ) {
return [];
}
return $nodes;
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment