omnilance / graphql-php-client
A simple client to help execute queries and mutations across GraphQL
Installs: 2 624
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 3
Open Issues: 0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2025-04-27 04:36:18 UTC
README
A simple client to help execute queries and mutations across GraphQL
Installation
composer require omnilance/graphql-php-client
or
composer require "omnilance/graphql-php-client": ">=0.0.3"
Simple Usage
use Omnilance\GraphQL\Client;
$client = new Client($api_token);
additionaly you can set custom host
$client->setHost($host);
Run query
$query = '{
domain_check(domain: "rx-name.net" {
cost,
avail
}
}';
$response = $client->response($query);
$query = '{
allDomains(first:10) {
domain {
id,
name,
register_date,
expired_date,
}
}
}';
$response = $client->response($query);
foreach($response->allDomains->domain as $domain) {
print $domain->name;
}
Response class
all()
Use $response->all();
to get all of the data returned in the response
errors()
Use $response->errors();
to get all the errors returned in the response
hasErrors()
Use $response->hasErrors();
to check if the response contains any errors