| Package Data | |
|---|---|
| Maintainer Username: | eadortsu | 
| Maintainer Contact: | mail@eadortsu.com (Eugene Adortsu) | 
| Package Create Date: | 2020-04-17 | 
| Package Last Update: | 2020-04-18 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-30 03:02:41 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 18 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 0 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
This package can be used to consume graphql APIs in your laravel or lumen project.
You can install the package via composer:
composer require eadortsu/laravel-graphql-client
php artisan vendor:publish --provider="eadortsu\GraphQL\GraphQLClientServiceProvider" 
Copy and setting up config:
cp vendor/eadortsu/laravel-graphql-client/config/config.php config/graphql-client.php
Add to bootstrap/app.php
$app->configure('graphql-client');
$app->register(eadortsu\GraphQL\GraphQLClientServiceProvider::class);
$query = <<<QUERY
query {
    users {
        id
        email
    }
}
QUERY;
$mutation = <<<MUTATION
mutation {
    login(data: {
        username: "user@mail.com"
        password: "qwerty"
    }) {
        access_token
        refresh_token
        expires_in
        token_type
    }
}
MUTATION;
$variables = [
"username" => "eadortsu",
"email" => "mail@eadortssu.com"
];
$graphqlendpoint_url = "https://eadortsu.com/graphql";
$queryResponse = eadortsu\GraphQL\Facades\Client::fetch($query, $graphqlendpoint_url);
$queryResponse = eadortsu\GraphQL\Facades\Client::fetch($query,$graphqlendpoint_url, [], $token ); // leavel an empty array if there no variables.
$mutationResponse = eadortsu\GraphQL\Facades\Client::fetch($mutation, $graphqlendpoint_url, $variables, $token);