PHPackages                             goltzchristian/graphql-client-php - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. goltzchristian/graphql-client-php

ActiveLibrary[Testing &amp; Quality](/categories/testing)

goltzchristian/graphql-client-php
=================================

A graphql client for php.

1.0.8(8y ago)831.7k10[2 PRs](https://github.com/christiangoltz/graphql-client-php/pulls)BSD-3-ClausePHPPHP ^7.0CI failing

Since Jan 17Pushed 4y ago2 watchersCompare

[ Source](https://github.com/christiangoltz/graphql-client-php)[ Packagist](https://packagist.org/packages/goltzchristian/graphql-client-php)[ RSS](/packages/goltzchristian-graphql-client-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

GraphQL Client for PHP
======================

[](#graphql-client-for-php)

A client made for testing and consuming GraphQL endpoints

Targeting Symfony and Laravel GraphQL implementations

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

[](#installation)

`composer require goltzchristian/graphql-client-php`

Setup
-----

[](#setup)

#### Laravel

[](#laravel)

```
use GraphQLClient\Client;

abstract class TestCase extends \Laravel\Lumen\Testing\TestCase
{
  /** @var Client */
  protected $graphql;

  public function setUp()
  {
    parent::setUp();
    $this->graphql = new LaravelTestGraphQLClient(
      $this->app,
      '/graphql'
    );
  }

}

```

#### Symfony

[](#symfony)

```
class RegistrationTest extends TestCase
{
  /** @var Client */
  protected $graphql;

  public function setUp()
  {
    parent::setUp();
    $this->graphql = new \GraphQLClient\SymfonyWebTestGraphQLClient(
      new Symfony\Bundle\FrameworkBundle\Client,
      '/graphql'  // change it to your endpoint's URI
    );
  }
}

```

Examples
--------

[](#examples)

#### Mutations

[](#mutations)

```
public function testRegistrationSuccess()
{
  $params = [
    'secret' => 'mySecret',
    'password' => $this->getFaker()->password()
    'email' => $this->getFaker()->email()
  ];  // build a query
  $query = new Query('registerUser', $params, [
    new Field('id'),
    new Field('email'),
    new Field('id'),
  ]);  // execute the query
  $fields = $this->graphql->mutate($query)->getData();  // check if the server returned values for all requested fields
  $this->graphql->assertGraphQlFields($fields, $query);  // check if the user was created in the db
  $user = User::query()->where([
    'email' => $params['email'],
  ])->first();
  $this->assertNotNull($user);
}

```

#### Queries

[](#queries)

```

public function testReadProfile()
{
  // build the query
  $query = new Query('viewer', [ 'token' => 'myToken', [
    new Field('profile', [
      new Field('id'),
      new Field('email'),
      new Query('posts', [ 'first' => 10 ], [
        new Field('edges', [
          new Field('node', [
            new Field('id'),
            new Field('content')
          ])
        ])
      ])
    ])
  ]);  // execute the query
  $fields = $this->graphql->query($query)->getData();  // check if the server returned all requested fields
  $this->assertGraphQlFields($fields, $query);  // check some simple field
  $this->assertEquals(
    $this->getUser()->getId(),
    $result['profile']['id']
  );  // retrieve post ids from response
  $postIds = array_map(function(array $item) {
    return $item['node']['id'];
  }, $fields['profile']['posts']['edges']);  // check if all user posts were contained in the response
  foreach ($this->getUser()->getPosts() as $post) {
    $this->assertNotFalse(array_search($post->getId(), $postIds));
  }

```

You can also checkout this [link](https://medium.com/@goltzchristian/testing-your-graphql-backend-in-php-41a2530ea556 "link") for detailed instructions

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% 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 ~3 days

Total

9

Last Release

3019d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e902b6b76a68aed689d93987bb6c72f096d6bea30d9be875a2674bc9c894e82?d=identicon)[christiangoltz](/maintainers/christiangoltz)

---

Top Contributors

[![christiangoltz](https://avatars.githubusercontent.com/u/2478085?v=4)](https://github.com/christiangoltz "christiangoltz (7 commits)")[![dimuziop](https://avatars.githubusercontent.com/u/12821342?v=4)](https://github.com/dimuziop "dimuziop (2 commits)")[![manonworldrepository](https://avatars.githubusercontent.com/u/175624480?v=4)](https://github.com/manonworldrepository "manonworldrepository (2 commits)")[![Yalpa](https://avatars.githubusercontent.com/u/26508918?v=4)](https://github.com/Yalpa "Yalpa (1 commits)")

---

Tags

testinggraphql

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k892.4M1.5k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k201.2M4.2k](/packages/symfony-phpunit-bridge)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)

PHPackages © 2026

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