A simple client to help execute queries and mutations across GraphQL
composer require omnilance/graphql-php-client
or
composer require "omnilance/graphql-php-client": ">=0.0.3"
use Omnilance\GraphQL\Client;
$client = new Client($api_token);
additionaly you can set custom host
$client->setHost($host);
$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;
}
Use $response->all();
to get all of the data returned in the response
Use $response->errors();
to get all the errors returned in the response
Use $response->hasErrors();
to check if the response contains any errors