Archives: Actions

  • graphql_update_term

    Fires an action when a term is updated via a GraphQL Mutation

    do_action( 'graphql_update_term', int $term_id, WP_Taxonomy $taxonomy, array $args, string $mutation_name, AppContext $context, ResolveInfo $info );

    Params

    For graphql_update_term

    • $term_id (int): Inserted term object
    • $taxonomy (WP_Taxonomy): The taxonomy of the term being updated
    • $args (array): The args used to insert the term
    • $mutation_name (string): The name of the mutation being performed
    • $context (AppContext): The AppContext passed down the resolve tree
    • $info (ResolveInfo): The ResolveInfo passed down the resolve tree

    Source

    File: wp-graphql/src/Mutation/TermObjectUpdate.php

  • graphql_settings_form_bottom

    Allow additions to the bottom of the GraphQL settings form

    do_action( 'graphql_settings_form_bottom', array $form );

    Params

    • $form (array): The form to be modified

    Source

    File: wp-graphql/src/Admin/Settings/SettingsRegistry.php

  • graphql_settings_form_top

    Allow additions to the top of the GraphQL settings form

    do_action( 'graphql_settings_form_top', array $form );

    Params

    • $form (array): The form to be modified

    Source

    File: wp-graphql/src/Admin/Settings/SettingsRegistry.php

  • graphql_init_settings

    Action that fires when settings are being initialized

    do_action( 'graphql_init_settings', WPGraphQL\Admin\Settings\SettingsRegistry $registry );

    Params

    • $registry (WPGraphQL\Admin\Settings\SettingsRegistry): The instance of the SettingsRegistry class

    Source

    File: wp-graphql/src/Admin/Settings/SettingsRegistry.php

    Examples

    Registers a GraphQL Settings Section

    /**
     * Registers a GraphQL Settings Section
     *
     * @param string $slug   The slug of the group being registered
     * @param array  $config Array configuring the section. Should include: title
     */
    function register_graphql_settings_section( $slug, $config ) {
    	add_action( 'graphql_init_settings', function( \WPGraphQL\Admin\Settings\SettingsRegistry $registry ) use ( $slug, $config ) {
    		$registry->register_section( $slug, $config );
    	} );
    }

    Registers a GraphQL Settings Field

    /**
     * Registers a GraphQL Settings Field
     *
     * @param string $group  The name of the group to register a setting field to
     * @param array  $config The config for the settings field being registered
     */
    function register_graphql_settings_field( $group, $config ) {
    	add_action( 'graphql_init_settings', function( \WPGraphQL\Admin\Settings\SettingsRegistry $registry ) use ( $group, $config ) {
    		$registry->register_field( $group, $config );
    	} );
    }
  • graphql_register_settings

    Action to hook into to register settings

    do_action( 'graphql_register_settings', WPGraphQL\Admin\Settings\Settings $this );

    Params

    • $settings (WPGraphQL\Admin\Settings\Settings): Instance of the Settings class

    Source

    File: wp-graphql/src/Admin/Settings/Settings.php

  • graphql_process_http_request_response

    Run an action after the HTTP Response is ready to be sent back. This might be a good place for tools to hook in to track metrics, such as how long the process took from graphql_process_http_request to here, etc.

    do_action( 'graphql_process_http_request_response', array $response, array $result, string $operation_name, string $query, array $variables );

    Params

    • $response (array): The GraphQL response
    • $result (array): The result of the GraphQL Query
    • $operation_name (string): The name of the operation
    • $query (string): The request that GraphQL executed
    • $variables (array): Variables passed to your GraphQL query

    Source

    File: wp-graphql/src/Router.php

  • graphql_process_http_request

    This action can be hooked to to enable various debug tools, such as enableValidation from the GraphQL Config

    do_action( 'graphql_process_http_request' );

    Source

    File: wp-graphql/src/Router.php

  • graphql_response_set_headers

    Fires an action when the headers are set

    do_action( 'graphql_response_set_headers', array $headers );

    Params

    • $headers (array): An array containing the response headers

    Source

    File: wp-graphql/src/Router.php

  • graphql_server_config

    Run an action when the server config is created. The config can be acted upon directly to override default values or implement new features, e.g., $config->setValidationRules()

    do_action( 'graphql_server_config', ServerConfig $config, OperationParams $params );

    Params

    • $config (ServerConfig): The Server config
    • $params (OperationParams): Request operation params

    Source

    File: wp-graphql/src/Request.php

  • do_graphql_request

    Run an action for reach request

    do_action( 'do_graphql_request', string $query, string $operation, array $variables, OperationParams $params );

    Params

    • $query (string): The GraphQL query
    • $operation (string): The name of the operation
    • $variables (array): Variables to be passed to your GraphQL request
    • $params (OperationParams): The Operation Params. This includes any extra params, such as extensions or any other modifications to the request body

    Source

    File: wp-graphql/src/Request.php