travelience/laravel-graphql-client is a Laravel package for graphql client for laravel.
It currently has 6 GitHub stars and 373 downloads on Packagist.
Install it with composer require travelience/laravel-graphql-client.
Discover more Laravel packages by travelience
or browse all Laravel packages to compare alternatives.
Last updated
composer require travelience/laravel-graphql-client
"require": {
"travelience/laravel-graphql-client": "dev-master"
},
Travelience\GraphQL\GraphQLServiceProvider::class,
In order to edit the default configuration for this package you may execute:
php artisan vendor:publish
$query = "
{ users{id,name,email} }
";
$r = GraphQL::query( $query );
// check if the response has errors
if( $r->hasErrors() )
{
// return a string of the first error messasge
dd($r->getErrorMessage());
// return a laravel collection with the errors
dd($r->errors());
}
// will return laravel collection
dd( $r->get('users') );
dd( $r->users );
/**
* @param string $query : { users{id, name, email} }
* @param array $params : extra parameters in the POST
* @param integer $cache : in minutes
* @return Response
*/
$r = GraphQL::query( $query, $params=[], $cache=false );