Skip to content

Instantly share code, notes, and snippets.

@jasonbahl
Created November 19, 2021 17:58
Show Gist options
  • Save jasonbahl/c556a273c41a90356cab8f94b93385a5 to your computer and use it in GitHub Desktop.
Save jasonbahl/c556a273c41a90356cab8f94b93385a5 to your computer and use it in GitHub Desktop.
add_filter( 'graphql_pre_resolve_field', function( $default, $source, $args, $context, $info, $type_name, $field_key, $field, $field_resolver ) {
if ( 'content' === $field_key && 'Post' === $type_name ) {
return 'your override value';
}
return $default;
}, 10, 9 );
@jasonbahl
Copy link
Author

This example shows how to override the "content" resolver for the "Post" type.

You can see the results of this filter in this screensot, where the "content" field returns your override value for each post returned.

Screen Shot 2021-11-19 at 10 57 00 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment