PHPackages                             joetjen/graphql - 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. [API Development](/categories/api)
4. /
5. joetjen/graphql

ActiveLibrary[API Development](/categories/api)

joetjen/graphql
===============

A small, fluent query builder for hand-writing GraphQL query documents in PHP.

0.1.0(2w ago)0808MITPHPPHP ^8.2

Since Jul 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/joetjen/php-graphql)[ Packagist](https://packagist.org/packages/joetjen/graphql)[ Docs](http://github.com/joetjen/php-graphql)[ RSS](/packages/joetjen-graphql/feed)WikiDiscussions master Synced 1w ago

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

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

[](#php-graphql)

A small, fluent query builder for hand-writing [GraphQL](https://graphql.org/) query documents in PHP — no code generation, no schema introspection, just a lightweight object API for assembling query strings and their variables payload.

Documentation
-------------

[](#documentation)

- [QUICKSTART.md](QUICKSTART.md) — install the package and send your first query in a couple of minutes
- [TUTORIAL.md](TUTORIAL.md) — a guided, step-by-step walkthrough of every concept in the library
- [CHEATSHEET.md](CHEATSHEET.md) — terse, skimmable reference of every class and method
- [EXAMPLES.md](EXAMPLES.md) — a gallery of self-contained, copy-pasteable recipes
- [CONTRIBUTION.md](CONTRIBUTION.md) — how to set up the project, run the tests, and submit changes
- [CHANGELOG.md](CHANGELOG.md) — a history of notable changes to the project
- [LICENSE](LICENSE) — MIT license

Requirements
------------

[](#requirements)

- PHP 8.2 or later

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

[](#installation)

```
composer require joetjen/graphql
```

Quick start
-----------

[](#quick-start)

```
use JOetjen\GraphQL\GraphQL;
use JOetjen\GraphQL\GraphQLVariable;

$document = GraphQL::create()->query('GetUser', function ($query) {
    $query->select('user', function ($user) {
        $user->argument('id', new GraphQLVariable('id', 42, GraphQL::INT));
        $user->select('name');
        $user->select('email');
    });
});

echo $document->toString();
// query GetUser($id:Int){user(id:$id){name,email}}

print_r($document->variables());
// ['id' => 42]
```

The two return values map directly onto a standard GraphQL HTTP request body:

```
$payload = json_encode([
    'query'     => $document->toString(),
    'variables' => $document->variables(),
]);
```

See [QUICKSTART.md](QUICKSTART.md) for the full round trip (including sending the request), or [TUTORIAL.md](TUTORIAL.md) for a deeper introduction to aliases, arguments, and variables.

Development
-----------

[](#development)

```
composer install
composer test
```

See [CONTRIBUTION.md](CONTRIBUTION.md) for coding standards and how to submit changes.

License
-------

[](#license)

Released under the [MIT license](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance53

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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 ~2190 days

Total

2

Last Release

19d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.3

0.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1041663?v=4)[Jan Oetjen](/maintainers/joetjen)[@joetjen](https://github.com/joetjen)

---

Tags

graphqlqueryquery builder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joetjen-graphql/health.svg)

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

###  Alternatives

[gmostafa/php-graphql-client

GraphQL client and query builder.

3218.5M30](/packages/gmostafa-php-graphql-client)[gmostafa/php-graphql-oqm

GraphQL Object-to-Query Mapper (QOM) which generates objects from API schema

46952.1k2](/packages/gmostafa-php-graphql-oqm)[cfpinto/graphql

A GraphQL query builder class

19279.3k4](/packages/cfpinto-graphql)

PHPackages © 2026

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