PHPackages                             hearst-hatchery/graphql-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. hearst-hatchery/graphql-php-client

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

hearst-hatchery/graphql-php-client
==================================

PHP Client for GraphQL

0.4.1(5y ago)0101[1 PRs](https://github.com/Hearst-Hatchery/graphql-php-client/pulls)MITPHPPHP ^7.1

Since Oct 12Pushed 5y ago59 watchersCompare

[ Source](https://github.com/Hearst-Hatchery/graphql-php-client)[ Packagist](https://packagist.org/packages/hearst-hatchery/graphql-php-client)[ RSS](/packages/hearst-hatchery-graphql-php-client/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (6)Dependencies (11)Versions (9)Used By (0)

graphql-php-client
==================

[](#graphql-php-client)

[![Current Release](https://camo.githubusercontent.com/d83b20fafa7b77b34e6d277645d6d1ea6dd97d4ba9bd1c6f652cbcfa6ff8ab4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d302e332e302d3165623066632e737667)](https://github.com/Hearst-Hatchery/graphql-php-client/releases/tag/0.3.0)[![Build Status](https://camo.githubusercontent.com/0790f51f51ad796eca12a19dcc617f98815b773387d941835768be99ab42be94/68747470733a2f2f7472617669732d63692e636f6d2f4865617273742d48617463686572792f6772617068716c2d7068702d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Hearst-Hatchery/graphql-php-client)

A GraphQL client in PHP. This uses Guzzle, but it's compatible with any [PSR-18](http://www.php-fig.org/psr/psr-18/) client through [HTTPlug](http://httplug.io/)

Installation
------------

[](#installation)

```
composer require hearst-hatchery/graphql-php-client
```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';
use GraphQLClient\Client;

$client = new Client("https://swapi.graph.cool/");

$query =
    array(4) {
      ["name"]=>
      string(14) "Luke Skywalker"
      ["birthYear"]=>
      string(5) "19BBY"
      ["gender"]=>
      string(4) "MALE"
      ["homeworld"]=>
      array(1) {
        ["name"]=>
        string(8) "Tatooine"
      }
    }
    [1]=>
    array(4) {
      ["name"]=>
      string(5) "C-3PO"
      ["birthYear"]=>
      string(6) "112BBY"
      ["gender"]=>
      string(7) "UNKNOWN"
      ["homeworld"]=>
      array(1) {
        ["name"]=>
        string(8) "Tatooine"
      }
    }
  }
}

```

### Advanced Example

[](#advanced-example)

You can easily extend the client, and it supports Httplug's Plugins. This one uses Github's API and variables.

This example needs `composer require php-http/message` before running. Adapted from

```
require 'vendor/autoload.php';
use GraphQLClient\Client;
use Http\Message\Authentication\Bearer;
use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Client\Common\PluginClient;

class GithubClient extends Client
{
    public function __construct(){
        parent::__construct("https://api.github.com/graphql");
    }

    protected function buildClient(array $options = [])
    {
        $authentication = new Bearer('');
        $authenticationPlugin = new AuthenticationPlugin($authentication);

        return new PluginClient(
            parent::buildClient($options),
            [$authenticationPlugin]
        );
    }
}

$client = new GithubClient();

$query =  3]);

var_dump($response);
```

### Client options

[](#client-options)

Currently, this client accepts all [Guzzle request options](http://docs.guzzlephp.org/en/stable/request-options.html).

#### Default options

[](#default-options)

- `method` : `POST`
- `headers` : `['Content-Type: application/json']`
- `json` : `true`

Using our GraphQL Query Builder
-------------------------------

[](#using-our-graphql-query-builder)

We also use a query builder in our applications (). Using the first example, installation is easy:

```
composer require hearst-hatchery/graphql-php-query-builder
```

Then include it

```
use GraphQLQueryBuilder\QueryBuilder;
```

Then `$query` can be shortened to:

```
$query->setObjectField('allPersons')->setArguments(['first' => 2])->setQueryObject([
  'name',
  'birthYear',
  'gender',
  'homeworld' => ['name']
]);
```

And expand it in our `query()` call:

```
$response = $client->query($query->buildQuery());
```

Which should give the same result, while having access to dynamic GraphQL queries!

Contributing
------------

[](#contributing)

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting pull requests to us.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~223 days

Total

6

Last Release

1858d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23240?v=4)[felton](/maintainers/felton)[@felton](https://github.com/felton)

---

Top Contributors

[![felton](https://avatars.githubusercontent.com/u/23240?v=4)](https://github.com/felton "felton (51 commits)")[![hetmansky](https://avatars.githubusercontent.com/u/8969321?v=4)](https://github.com/hetmansky "hetmansky (3 commits)")[![dee2716](https://avatars.githubusercontent.com/u/37081175?v=4)](https://github.com/dee2716 "dee2716 (2 commits)")[![mp-app-bot](https://avatars.githubusercontent.com/u/20564938?v=4)](https://github.com/mp-app-bot "mp-app-bot (2 commits)")[![eduardosibaja](https://avatars.githubusercontent.com/u/54280363?v=4)](https://github.com/eduardosibaja "eduardosibaja (1 commits)")[![lfre](https://avatars.githubusercontent.com/u/1093848?v=4)](https://github.com/lfre "lfre (1 commits)")

---

Tags

graphqlphp-clientpsr-7clientpsr-18graphqlhttplugphp-http

###  Code Quality

TestsCodeception

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/hearst-hatchery-graphql-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/hearst-hatchery-graphql-php-client/health.svg)](https://phpackages.com/packages/hearst-hatchery-graphql-php-client)
```

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[php-http/httplug-bundle

Symfony integration for HTTPlug

38921.0M54](/packages/php-http-httplug-bundle)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[elastic/transport

HTTP transport PHP library for Elastic products

1920.6M7](/packages/elastic-transport)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[vultr/vultr-php

The Official Vultr API PHP Wrapper.

2243.9k1](/packages/vultr-vultr-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
