WordPress filter hook
graphql_pre_resolve_field
Fired by 2 WordPress plugins, running on 30K+ sites between them.
“When this filter return anything other than the $nil it will be used as the resolved value and the execution of the actual resolved is skipped. This filter can be used to implement field level caches or for efficiently hiding data by returning null.”
How to use graphql_pre_resolve_field
It's a filter: your callback receives the value and 8 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'graphql_pre_resolve_field', function( $nil, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver ) {
// Change $nil here.
return $nil;
}, 10, 9 );Argument names come from WPGraphQL's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
2 plugins that fire graphql_pre_resolve_field
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WPGraphQL30,000+ installs
apply_filters( 'graphql_pre_resolve_field', $nil, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver )src/Utils/InstrumentSchema.php:153 -
Fundrizer Lite10+ installs
apply_filters( 'graphql_pre_resolve_field', $nil, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver )deps/wp-graphql/src/Utils/InstrumentSchema.php:139
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.