PHP code example of camuthig / graphql-client
1. Go to this page and download the library: Download camuthig/graphql-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
camuthig / graphql-client example snippets
use Camuthig\Graphql\Client\Client;
$headers = [
'X-From' => 'The Test',
];
$client = new Client('https://9jv9z4w3kr.lp.gql.zone/graphql', $headers);
$graphql = <<<'GRAPHQL'
query($input: String!) {
hello(input: $input)
}
GRAPHQL;
$result = $client->execute($graphql, ['input' => 'everyone']);
var_dump($result->hasErrors()); // false
var_dump($result->getErrors()); // []
var_dump($result->getData());
/*
array(1) {
["hello"]=>
string(15) "Hello everyone! From The Test"
}
*/