Laravel5.8 GraphQL cliente

instalar la libreria

composer require softonic/graphql-client
para testear rapidamente, editamos web.php:
Route::get('/', function () {
$client = \Softonic\GraphQL\ClientBuilder::build('https://countries.trevorblades.com/');
$query = '
{
countries{
code
name
languages{
name
}
}
}
';
$variables = [
];
$response = $client->query($query, $variables);
dd($response->getData());
});
si quisieramos llamar a una query con parametros:
$query = '
{
query getCountry($code: String){
country (code: $code){
code
name
languages{
name
}
}
}
}
';
$variables = [
"code" => "AR"
];


No hay comentarios:

Publicar un comentario

linux ubuntu mint actualizar chrome

 desde una terminal: $ sudo apt update $ sudo apt install google-chrome-stable