ciloe/graphql-client-php
Lightweight PHP GraphQL client with a basic bridge/client setup or quick factory creation. Supports simple queries, named queries with variables, and optional caching via Symfony Cache adapters. Configure host/URI/token and send requests easily.
graphql-php/graphql-php or laravel-graphql instead).JsonSerializable or custom DTOs).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Deprecation | Last release in 2018; no recent activity or Laravel 10+ compatibility testing. | Evaluate forks (e.g., webonyx/graphql-php) or modern alternatives like overblog/graphql-client. |
| Performance | No benchmarking data; potential overhead for high-frequency calls. | Profile with Laravel’s HTTP client or Guzzle middleware (e.g., caching, compression). |
| Security | No built-in CSRF protection or query validation for malicious inputs. | Sanitize queries/variables server-side; use Laravel’s Validator for input validation. |
| Testing | Limited test coverage; no Laravel-specific tests. | Write integration tests with Laravel’s HTTP tests or Pest. |
| Maintenance Burden | Manual setup for Laravel (e.g., service container binding, middleware). | Create a Laravel wrapper package or use traits for reusable configurations. |
spatie/laravel-query-builder)?overblog/graphql-client) with better maintenance?users { id name }) or deeply nested (requiring custom response handling)?spatie/laravel-queueable-middleware)?Illuminate\Support\Facades\Http) or Guzzle.Authenticate, ThrottleRequests) for request/response processing.$this->getJson()) or Pest.Cache::remember).laravel-debugbar.Benchmark facade).GET /users/1 → query User { id: 1 }).Cache::tags('graphql')->remember) and retries.| Component | Compatibility Notes |
|---|---|
| Laravel Version | Tested on Laravel 5.x; may require adjustments for Laravel 10+ (e.g., PSR-15 middleware). |
| PHP Version | Requires PHP 7.2+; Laravel 10+ uses PHP 8.1+, which may need polyfills for older package code. |
| HTTP Clients | Defaults to Guzzle; can be swapped for Symfony’s HTTP client or Laravel’s HTTP client. |
| Query Language | Supports GraphQL 16.0; ensure the target API is compatible. |
| Authentication | No built-in auth; use Laravel’s HTTP client auth (e.g., ->withToken($token)) or headers. |
composer require ciloe/graphql-client-php.config/services.php.$this->app->singleton('graphql', function () {
return new \Ciloe\GraphQLClient\Client(
new \GuzzleHttp\Client(),
'https://api.example.com/graphql'
);
});
use Ciloe\GraphQLClient\Client;
use Ciloe\GraphQLClient\Request;
$client = app('graphql');
$request = new Request('query { users { id name } }');
$response = $client->send($request);
$request = new Request('query User($id: ID!) { user(id: $id) { name } }', ['id' => 1]);
json_decode with custom casting.$data = json_decode($response->getBody(), true);
$user = collect($data['data']['user'])->first();
if ($response->getStatusCode() !== 200) {
throw new \RuntimeException($response->getBody());
}
README.md.dd($response->getBody())) for troubleshooting.\Log::debug('GraphQL Query', ['query' => $request->getQuery(), 'variables' => $request->getVariables()]);
App\Exceptions\Handler or Sentry.$client->batch([$request1, $request2]);
How can I help you explore Laravel packages today?