Created
August 18, 2022 16:42
-
-
Save jasonbahl/e63f5c1c84df65868077cb666fcbc2a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wpgraphql_cache_purge_nodes', function( $key = 'purge', $nodes = [] ) { | |
$pipedream_debugging = function_exists( 'get_graphql_setting' ) ? \get_graphql_setting( 'pipedream_post', 'off', 'purge_debugging' ) : 'off'; | |
$enabled = $pipedream_debugging === 'on'; | |
if ( ! $enabled || empty( $nodes ) ) { | |
return; | |
} | |
$args = [ | |
'headers' => [ | |
'Content-Type' => 'application/json', | |
], | |
'body' => wp_json_encode([ | |
'endpoint' => site_url( \WPGraphQL\Router::$route ), | |
'key' => $key, | |
'nodes' => $nodes, | |
]), | |
'method' => 'POST', | |
'data_format' => 'body', | |
'blocking' => false, | |
]; | |
wp_safe_remote_post( 'https://eop5fazakbebfeh.m.pipedream.net', $args ); | |
}, 10, 2 ); | |
add_action( 'graphql_register_settings', function() { | |
register_graphql_settings_section( 'purge_debugging', [ | |
'title' => 'Purge Debugging', | |
'desc' => 'Debugging purge events' | |
]); | |
register_graphql_settings_field( 'purge_debugging', [ | |
'name' => 'pipedream_post', | |
'label' => 'Enable Pipedream Payloads', | |
'desc' => 'Enable payloads to be sent to Pipedream for monitoring', | |
'type' => 'checkbox', | |
'default' => 'off' | |
] ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment