Skip to content

Commit

Permalink
Add sendGraphQL()
Browse files Browse the repository at this point in the history
  • Loading branch information
iampersistent committed Jan 7, 2024
1 parent 524cdf4 commit 8663938
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ it('contains response data')
#### `toHaveErrors(array $errors)`

Assert that the underlying response GraphQL errors are canonically equal to the
exepected set of errors.
expected set of errors.

```php
it('has errors')
Expand Down
5 changes: 5 additions & 0 deletions src/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ function isValidSdl($document = '')
return $this;
});

function sendGraphQL(string $query, array $variables = [], array $headers = [])
{
return test()->sendGraphQL($query, $variables, $headers);
}

/**
* @param string|Schema|null $document Schema file path or document instance
*
Expand Down
7 changes: 7 additions & 0 deletions src/GraphQl.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
trait GraphQl
{
protected ResponseInterface $clientResponse;

/**
* Get an instance of a GraphQL schema.
*
Expand Down Expand Up @@ -72,6 +74,11 @@ public function isValidSdl($document): TestCase
return $this;
}

public function sendGraphQL(string $query, array $variables = [], array $headers = [])
{
$this->clientResponse = Client::client()->raw($query, $variables, $headers);
}

/**
* @param string|Schema|null $document Schema file path or document instance
* @param string $interface The name of the interface as defined in the schema document
Expand Down

0 comments on commit 8663938

Please sign in to comment.