Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Commit

Permalink
Merge branch 'feature/update-to-0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Nov 3, 2017
2 parents 2e11faf + d864782 commit 93b2226
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 211 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Insights for WPGraphQL. Performance and error logging.",
"type": "wordpress-plugin",
"license": "GPLv3",
"version":"0.2.0",
"authors": [
{
"name": "Jason Bahl",
Expand Down
147 changes: 0 additions & 147 deletions src/InstrumentSchema.php

This file was deleted.

27 changes: 25 additions & 2 deletions src/Tracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,17 @@ public static function add_tracked_queries_to_response_extensions( $response, $s
return $response;
}

public static function init_field_resolver_trace( $field, $type_object, $source, $args, AppContext $context, ResolveInfo $info ) {
/**
* @param $source
* @param $args
* @param $context
* @param $info
* @param $field_resolver
* @param $type_name
* @param $field_key
* @param $field
*/
public static function init_field_resolver_trace( $source, $args, $context, $info, $field_resolver, $type_name, $field_key, $field ) {

$start_offset = Tracing::get_resolver_start_offset();
self::$resolver_start = microtime( true );
Expand All @@ -336,12 +346,25 @@ public static function init_field_resolver_trace( $field, $type_object, $source,

}

public static function close_field_resolver_trace( $field, $type_object, $source, $args, AppContext $context, ResolveInfo $info ) {
/**
* @param $source
* @param $args
* @param $context
* @param $info
* @param $field_resolver
* @param $type_name
* @param $field_key
* @param $field
*/
public static function close_field_resolver_trace( $source, $args, $context, $info, $field_resolver, $type_name, $field_key, $field ) {
self::$field_resolver_trace['duration'] = Tracing::get_resolver_duration( self::$resolver_start );
Tracing::trace_resolver( self::$field_resolver_trace );
self::reset_field_resolver_trace();
}

/**
*
*/
protected static function reset_field_resolver_trace() {
self::$field_resolver_trace = [];
self::$resolver_start = null;
Expand Down
55 changes: 0 additions & 55 deletions tests/test-InstrumentSchema.php

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

return array(
'WPGraphQL\\Extensions\\Insights\\Data' => $baseDir . '/src/Data.php',
'WPGraphQL\\Extensions\\Insights\\InstrumentSchema' => $baseDir . '/src/InstrumentSchema.php',
'WPGraphQL\\Extensions\\Insights\\QueryTrace' => $baseDir . '/src/QueryTrace.php',
'WPGraphQL\\Extensions\\Insights\\Tracing' => $baseDir . '/src/Tracing.php',
);
2 changes: 1 addition & 1 deletion vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ComposerStaticInit9e12acd0d8d678fe7190ac4fe7971f29

public static $classMap = array (
'WPGraphQL\\Extensions\\Insights\\Data' => __DIR__ . '/../..' . '/src/Data.php',
'WPGraphQL\\Extensions\\Insights\\InstrumentSchema' => __DIR__ . '/../..' . '/src/InstrumentSchema.php',
'WPGraphQL\\Extensions\\Insights\\QueryTrace' => __DIR__ . '/../..' . '/src/QueryTrace.php',
'WPGraphQL\\Extensions\\Insights\\Tracing' => __DIR__ . '/../..' . '/src/Tracing.php',
);

Expand Down
10 changes: 5 additions & 5 deletions wp-graphql-insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: https://www.wpgraphql.com
* Text Domain: wp-graphql-insights
* Domain Path: /languages
* Version: 0.0.2
* Version: 0.2.0
*
* @package WPGraphQL_Insights
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ private static function setup_constants() {

// Plugin version.
if ( ! defined( 'WPGRAPHQL_INSIGHTS_VERSION' ) ) {
define( 'WPGRAPHQL_INSIGHTS_VERSION', '0.0.2' );
define( 'WPGRAPHQL_INSIGHTS_VERSION', '0.2.0' );
}

// Plugin Folder Path.
Expand Down Expand Up @@ -147,12 +147,12 @@ private function actions() {
/**
* Initialize each resolver trace
*/
add_action( 'graphql_before_resolve', [ 'WPGraphQL\Extensions\Insights\Tracing', 'init_field_resolver_trace' ], 10, 6 );
add_action( 'graphql_before_resolve_field', [ 'WPGraphQL\Extensions\Insights\Tracing', 'init_field_resolver_trace' ], 10, 8 );

/**
* Close each resolver trace
*/
add_action( 'graphql_after_resolve', [ 'WPGraphQL\Extensions\Insights\Tracing', 'close_field_resolver_trace' ], 10, 6 );
add_action( 'graphql_after_resolve_field', [ 'WPGraphQL\Extensions\Insights\Tracing', 'close_field_resolver_trace' ], 10, 8 );

}

Expand Down Expand Up @@ -183,7 +183,7 @@ private function filters() {
function graphql_insights_init() {

/**
* If the version of WPGraphQL isn't up to date, don't instantiate tracing
* If the version of WPGraphQL isn't up to date, don't instantiate tracing as it won't work properly
* @todo: consider displaying an Admin Notice or something to that tune if the versions aren't compatible
*/
if ( defined( 'WPGRAPHQL_VERSION' ) && version_compare( WPGRAPHQL_VERSION, '0.0.20', '<=' ) ) {
Expand Down

0 comments on commit 93b2226

Please sign in to comment.