public function debugLastQuery()
    {
        if ($this->client->getGraphQL()) {

            /** @var Response $response */
            $response = $this->client->getResponse();

            $content = $response->getContent();
            $json = @json_decode($content, true);

            $error = $response->getStatusCode() >= 400;
            if ($json && isset($json['errors'])) {
                $error = true;
            }

            $bg = $error ? 41 : 42;
            print_r("\n\n");
            print_r("\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n");
            print_r(sprintf("STATUS: [%s] %s \n", $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()] ?? 'Unknown Status'));

            if ($json) {
                $output = json_encode($json, JSON_PRETTY_PRINT);
            } else {
                $output = $content;
            }

            print_r($output);

            print_r("\n\n");
            print_r("\033[46m------------------- VARIABLES-----------------------\033[0m\n\n");
            $variables = $this->client->getVariables() ?? null;
            print_r(json_encode($variables, JSON_PRETTY_PRINT));

            $query = $this->client->getGraphQL() ?? null;
            $type = 'QUERY';
            if (preg_match('/^\s*mutation/', $query)) {
                $type = 'MUTATION';
            }

            print_r("\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n");
            print_r($query ?? null);
            print_r("\n\n");
            print_r("-----------------------------------------------------\n\n");
            ob_flush();
        } else {
            throw new \RuntimeException('Does not exist any executed query on current test, try use this method after "send" the query.');
        }
    }
public function debugLastQuery()
    {
        if ($this->client->getGraphQL()) {

            /** @var Response $response */
            $response = $this->client->getResponse();

            $content = $response->getContent();
            $json = @json_decode($content, true);

            $error = $response->getStatusCode() >= 400;
            if ($json && isset($json['errors'])) {
                $error = true;
            }

            $bg = $error ? 41 : 42;
            print_r("\n\n");
            print_r("\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n");
            print_r(sprintf("STATUS: [%s] %s \n", $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()] ?? 'Unknown Status'));

            if ($json) {
                $output = json_encode($json, JSON_PRETTY_PRINT);
            } else {
                $output = $content;
            }

            print_r($output);

            print_r("\n\n");
            print_r("\033[46m------------------- VARIABLES-----------------------\033[0m\n\n");
            $variables = $this->client->getVariables() ?? null;
            print_r(json_encode($variables, JSON_PRETTY_PRINT));

            $query = $this->client->getGraphQL() ?? null;
            $type = 'QUERY';
            if (preg_match('/^\s*mutation/', $query)) {
                $type = 'MUTATION';
            }

            print_r("\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n");
            print_r($query ?? null);
            print_r("\n\n");
            print_r("-----------------------------------------------------\n\n");
            ob_flush();
        } else {
            throw new \RuntimeException('Does not exist any executed query on current test, try use this method after "send" the query.');
        }
    }
public function debugLastQuery ( ) { if ( $ this -> client -> getGraphQL ( ) ) { /** @var Response $response */ $ response = $ this -> client -> getResponse ( ) ; $ content = $ response -> getContent ( ) ; $ json = @ json_decode ( $ content , true ) ; $ error = $ response -> getStatusCode ( ) >= 400 ; if ( $ json && isset ( $ json [ 'errors' ] ) ) { $ error = true ; } $ bg = $ error ? 41 : 42 ; print_r ( "\n\n" ) ; print_r ( "\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n" ) ; print_r ( sprintf ( "STATUS: [%s] %s \n" , $ response -> getStatusCode ( ) , Response :: $ statusTexts [ $ response -> getStatusCode ( ) ] ?? 'Unknown Status' ) ) ; if ( $ json ) { $ output = json_encode ( $ json , JSON_PRETTY_PRINT ) ; } else { $ output = $ content ; } print_r ( $ output ) ; print_r ( "\n\n" ) ; print_r ( "\033[46m------------------- VARIABLES-----------------------\033[0m\n\n" ) ; $ variables = $ this -> client -> getVariables ( ) ?? null ; print_r ( json_encode ( $ variables , JSON_PRETTY_PRINT ) ) ; $ query = $ this -> client -> getGraphQL ( ) ?? null ; $ type = 'QUERY' ; if ( preg_match ( '/^\s*mutation/' , $ query ) ) { $ type = 'MUTATION' ; } print_r ( "\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n" ) ; print_r ( $ query ?? null ) ; print_r ( "\n\n" ) ; print_r ( "-----------------------------------------------------\n\n" ) ; ob_flush ( ) ; } else { throw new \ RuntimeException ( 'Does not exist any executed query on current test, try use this method after "send" the query.' ) ; } }
Print helpful debug information for latest executed query

@Then debug last query
Print helpful debug information for latest executed query