Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eadortsu's avatar

GraphQL client for laravel

Is there a GraphQL client package available for PHP, laravel to be specific?

From the Apollo website, I can only see clients for React, Vue.js, Angular, Android, iOS, Ember and Meteor.

I need to consume a GraphQL endpoint in the controller of my laravel project.

0 likes
4 replies
laurentg's avatar

Lighthouse is excellent for creating endpoints.

But consuming may simply use the new HTTP Client, as dannielb said here : https://laracasts.com/discuss/channels/laravel/how-to-comsume-graphql-api-in-laravel

You may also use packages such as https://github.com/alexaandrov/laravel-graphql-client or https://github.com/mghoneimy/php-graphql-client

Here is a simple example of consuming graphql with Laravel 7 :


use Illuminate\Support\Facades\Http;


$query = <<<GQL
query {
    user(id: $id) {
        id
        name
        email
    }
}
GQL;

$response = Http::withHeaders([
    'Content-Type' => 'application/json',
])->post('http://graphql.end.point/graphql', [
    'query' => $query
]);


dump($response->json());
8 likes

Please or to participate in this conversation.