https://github.com/evilfreelancer/simplegqlient
The simplest GraphQL client written in PHP
https://github.com/evilfreelancer/simplegqlient
api-client graphql graphql-client
Last synced: 5 months ago
JSON representation
The simplest GraphQL client written in PHP
- Host: GitHub
- URL: https://github.com/evilfreelancer/simplegqlient
- Owner: EvilFreelancer
- License: mit
- Created: 2022-11-02T05:53:32.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T10:16:21.000Z (about 2 years ago)
- Last Synced: 2025-06-08T01:43:06.222Z (7 months ago)
- Topics: api-client, graphql, graphql-client
- Language: PHP
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleGQLient - Simple GraphQL client
The simplest GraphQL client written in PHP.
Inspired by the [Lighthouse PHP](https://lighthouse-php.com/) project,
in particular by [embedded client](https://github.com/nuwave/lighthouse/blob/master/src/Testing/MakesGraphQLRequests.php)
that can be used for testing of Laravel-based GraphQL
implementation of server.
```shell
composer require evilfreelancer/simplegqlient
```
## Small example
```php
require_once __DIR__ . '/../vendor/autoload.php';
$githubToken = 'xxx';
$client = new \SimpleGQLient\Client('https://api.github.com/graphql', [
'Authorization' => 'Bearer ' . $githubToken,
'Accept' => 'application/vnd.github.hawkgirl-preview+json,',
]);
$response = $client->graphQL(/** @lang GraphQL */ '
{
user(login: "evilfreelancer") {
repositories(ownerAffiliations: OWNER, isFork: false, first: 100) {
nodes {
name
languages(first: 10, orderBy: { field: SIZE, direction: DESC }) {
edges {
size
node {
color
name
}
}
}
}
}
}
}
');
// \Psr\Http\Message\ResponseInterface in response
$output = $response->getBody()->getContents();
var_dump($output);
```
## Roadmap
- [x] Basic client
- [ ] Multipart support