Fires after themes have been setup, allowing for both plugins and themes to register things before graphql_init
do_action( 'graphql_init', WPGraphQL $instance );
Params
- $instance (WPGraphQL): The instance of the WPGraphQL class
Fires after themes have been setup, allowing for both plugins and themes to register things before graphql_init
do_action( 'graphql_init', WPGraphQL $instance );
Fire an action when the Type Register is returned
do_action( 'graphql_get_type_registry', WPGraphQL\Registry\TypeRegistry $type_registry );
Fire an action when the Schema is returned
do_action( 'graphql_get_schema', WPGraphQL\WPSchema $schema );
Fire an action as the type registry is initialized. This executes before the graphql_register_types
action to allow for earlier hooking
do_action( 'graphql_register_initial_types', WPGraphQL\Registry\TypeRegistry $type_registry );
Fires when the debug logs are retrieved
do_action( 'graphql_get_debug_log', WPGraphQL\Utils\DebugLog $debug_log );
File: wp-graphql/src/Utils/DebugLog.php
add_action( 'graphql_get_debug_log', function( \WPGraphQL\Utils\DebugLog $debug_log ) use ( $message, $config ) {
return $debug_log->add_log_entry( $message, $config );
} );
Run an action when the WPObjectType is instantiating
do_action( 'graphql_wp_union_type', array $config, WPGraphQL\Type\WPUnionType $union_type );
Run an action when the WPObjectType is instantiating
do_action( 'graphql_wp_object_type', array $config, WPGraphQL\Type\WPObjectType $object_type );
Run an action after the additional data has been updated. This is a great spot to hook into to update additional data related to users, such as setting relationships, updating additional usermeta, or sending emails to Kevin… whatever you need to do with the userObject
do_action( 'graphql_user_object_mutation_update_additional_data', int $user_id, array $input, string $mutation_name, AppContext $context, ResolveInfo $info );
File: wp-graphql/src/Data/UserMutation.php
Extending mutation for user
/**
* Run an action after the additional data has been updated. This is a great spot to hook into to
* update additional data related to users, such as setting relationships, updating additional usermeta,
* or sending emails to Kevin... whatever you need to do with the userObject.
*
* @param int $user_id The ID of the user being mutated
* @param array $input The input for the mutation
* @param string $mutation_name The name of the mutation (ex: create, update, delete)
* @param AppContext $context The AppContext passed down the resolve tree
* @param ResolveInfo $info The ResolveInfo passed down the Resolve Tree
*/
add_action( 'graphql_user_object_mutation_update_additional_data', 'graphql_register_user_mutation', 10, 5 );
function graphql_register_user_mutation( $user_id, $input, $mutation_name, $context, $info ) {
if ( isset( $input['hobbies'] ) ) {
// Consider other sanitization if necessary and validation such as which
// user role/capability should be able to insert this value, etc.
update_user_meta( $user_id, 'hobbies', $input['hobbies'] );
}
}
Fire an action as the type registry is initialized. This executes during the graphql_register_types
action to allow for earlier hooking
do_action( 'graphql_register_types_late', WPGraphQL\Registry\TypeRegistry $type_registry );
Fires an action as the Type registry is being initiated
do_action( 'init_graphql_type_registry', WPGraphQL\Registry\TypeRegistry $type_registry );