Skip to content

Instantly share code, notes, and snippets.

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/95b3fff0ca8fa9f56af723344f11a5c1 to your computer and use it in GitHub Desktop.
Save jasonbahl/95b3fff0ca8fa9f56af723344f11a5c1 to your computer and use it in GitHub Desktop.
add_filter( 'graphql_query_analyzer_graphql_keys', function( $graphql_keys, $return_keys, $skipped_keys, $return_keys_array, $skipped_keys_array ) {
$keys_array = explode( ' ', $return_keys );
if ( empty( $keys_array ) || ! in_array( 'operation:GetPostBySlug', $keys_array, true ) ) {
return $graphql_keys;
}
if ( ( $key = array_search('list:tag', $keys_array ) ) !== false ) {
unset( $keys_array[$key] );
}
if ( ( $key = array_search('list:category', $keys_array ) ) !== false) {
unset( $keys_array[$key] );
}
$graphql_keys['keys'] = implode( ' ', $keys_array );
return $graphql_keys;
}, 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment