travelience / laravel-graphql-client
GraphQL Client For Laravel
Installs: 373
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 2
Open Issues: 2
pkg:composer/travelience/laravel-graphql-client
Requires
- php: >=5.6.0
- laravel/framework: ~5.2
This package is auto-updated.
Last update: 2025-09-22 15:31:04 UTC
README
You can install this package via composer using this command:
composer require travelience/laravel-graphql-client
Or add in your composer.json
"require": {
"travelience/laravel-graphql-client": "dev-master"
},
Service Provider
Travelience\GraphQL\GraphQLServiceProvider::class,
Config Files
In order to edit the default configuration for this package you may execute:
php artisan vendor:publish
Example
$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 );
Query params
/** * @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 );