Skip to content

Cast the stream to string instead of getting the contents #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Results
public function __construct(ResponseInterface $response, $asArray = false)
{
$this->responseObject = $response;
$this->responseBody = $this->responseObject->getBody()->getContents();
$this->responseBody = (string) $this->responseObject->getBody();
$this->results = json_decode($this->responseBody, $asArray);

// Check if any errors exist, and throw exception if they do
Expand Down
4 changes: 2 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testConstructClient()

/** @var Request $firstRequest */
$firstRequest = $container[0]['request'];
$this->assertEquals('{"query":"query_string","variables":{}}', $firstRequest->getBody()->getContents());
$this->assertEquals('{"query":"query_string","variables":{}}', (string) $firstRequest->getBody());
$this->assertSame('POST', $firstRequest->getMethod());

/** @var Request $thirdRequest */
Expand All @@ -92,7 +92,7 @@ public function testConstructClient()

/** @var Request $secondRequest */
$secondRequest = $container[2]['request'];
$this->assertEquals('{"query":"query_string","variables":{"name":"val"}}', $secondRequest->getBody()->getContents());
$this->assertEquals('{"query":"query_string","variables":{"name":"val"}}', (string) $secondRequest->getBody());

/** @var Request $fourthRequest */
$fourthRequest = $container[3]['request'];
Expand Down