Search by

darthsoup / php-graphql-client

darthsoup

GraphQL client and query builder.

Package info

github.com/darthsoup/php-graphql-client

pkg:composer/darthsoup/php-graphql-client

Statistics

Installs: 2 119

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-10-08 12:08 UTC

README

CI Latest Version PHP Version Total Downloads License

A PHP 8.3+ GraphQL client with a fluent query builder. Interact with any GraphQL API without writing raw query strings — compose type-safe queries and mutations in pure PHP, then run them against any GraphQL endpoint.

Requirements

  • PHP 8.3 or higher
  • ext-json

Installation

composer require darthsoup/php-graphql-client

Quick start

require __DIR__ . '/vendor/autoload.php';

use GraphQL\Client;
use GraphQL\Query;

$client = new Client('https://example.com/graphql');
$query = (new Query('companies'))->setSelectionSet(['name', 'serialNumber']);
$data = $client->runQuery($query)->getData();

The client uses Guzzle by default. You can also pass a PSR-18 HTTP client. GraphQL errors throw GraphQL\Exception\QueryError and expose the returned errors and partial data.

Documentation

Examples

The examples/ directory contains runnable PHP examples:

Changelog

See CHANGELOG.md for release notes and compatibility changes.

Contributing

Run composer install, composer test, composer phpstan, and composer style:check before opening a pull request. Integration tests use an external API: composer test:integration.