public function json($query, $variables = [], $headers = [], $assoc = false)
    {
        $response = $this->request($query, $variables, $headers);

        $responseJson = json_decode($response, $assoc);

        if ($responseJson === null) {
            throw new GraphQLInvalidResponse('GraphQL did not provide a valid JSON response. Please make sure you are pointing at the correct URL.');
        } else if (!isset($responseJson->data) && $responseJson->data != null) {
            throw new GraphQLMissingData('There was an error with the GraphQL response, no data key was found.');
        }

        return $responseJson;
    }
public function json($query, $variables = [], $headers = [], $assoc = false)
    {
        $response = $this->request($query, $variables, $headers);

        $responseJson = json_decode($response, $assoc);

        if ($responseJson === null) {
            throw new GraphQLInvalidResponse('GraphQL did not provide a valid JSON response. Please make sure you are pointing at the correct URL.');
        } else if (!isset($responseJson->data) && $responseJson->data != null) {
            throw new GraphQLMissingData('There was an error with the GraphQL response, no data key was found.');
        }

        return $responseJson;
    }
public function json ( $ query , $ variables = [ ] , $ headers = [ ] , $ assoc = false ) { $ response = $ this -> request ( $ query , $ variables , $ headers ) ; $ responseJson = json_decode ( $ response , $ assoc ) ; if ( $ responseJson === null ) { throw new GraphQLInvalidResponse ( 'GraphQL did not provide a valid JSON response. Please make sure you are pointing at the correct URL.' ) ; } else if ( ! isset ( $ responseJson -> data ) && $ responseJson -> data != null ) { throw new GraphQLMissingData ( 'There was an error with the GraphQL response, no data key was found.' ) ; } return $ responseJson ; }
Make a GraphQL Request and get the response body in JSON form.

@param string $query
@param array $variables
@param array $headers
@param bool $assoc

@return mixed

@throws GraphQLInvalidResponse
@throws GraphQLMissingData
Make a GraphQL Request and get the response body in JSON form .