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

Commit

Permalink
Add support for query batching
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Feb 5, 2018
1 parent 031d5a8 commit d1541d7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Tracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ public static function get_trace() {
]
];



/**
* Filer and return the trace data
* @param array $trace An array of Trace data
Expand Down Expand Up @@ -293,11 +295,17 @@ public static function add_tracing_to_response_extensions( $response, $schema, $
*/
if ( is_array( $response ) ) {
foreach ( $response as $key => $res ) {
/**
* Only include the trace data once per request
*/
if ( 0 !== $key ) {
return false;
}
if ( true === self::include_tracing_in_response( $res, $schema, $operation_name, $request, $variables ) ) {
if ( is_object( $res ) ) {
$res->extensions['tracing'] = self::get_trace();
$res->extensions['tracing'] = self::get_trace( $key );
} else if ( is_array( $res ) ) {
$res['extensions']['tracing'] = self::get_trace();
$res['extensions']['tracing'] = self::get_trace( $key );
}
}
$response[ $key ] = $res;
Expand Down Expand Up @@ -329,11 +337,17 @@ public static function add_tracked_queries_to_response_extensions( $response, $s

if ( is_array( $response ) ) {
foreach( $response as $key => $res ) {
/**
* Only include the trace data once per request
*/
if ( 0 !== $key ) {
return false;
}
if ( true === self::include_tracing_in_response( $res, $schema, $operation_name, $request, $variables ) ) {
if ( is_object( $res ) ) {
$res->extensions['queryLog'] = self::get_trace();
$res->extensions['queryLog'] = QueryTrace::get_trace( $key );
} else if ( is_array( $res ) ) {
$res['extensions']['queryLog'] = self::get_trace();
$res['extensions']['queryLog'] = QueryTrace::get_trace( $key );
}
}
$response[ $key ] = $res;
Expand Down

0 comments on commit d1541d7

Please sign in to comment.