PHPackages                             ez-php/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. [Framework](/categories/framework)
4. /
5. ez-php/graphql

ActiveLibrary[Framework](/categories/framework)

ez-php/graphql
==============

GraphQL module for the ez-php framework — schema builder, query executor, and HTTP endpoint via webonyx/graphql-php

1.3.0(1mo ago)00MITPHPPHP ^8.5CI passing

Since Mar 29Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/graphql)[ Packagist](https://packagist.org/packages/ez-php/graphql)[ Docs](https://github.com/ez-php/graphql)[ RSS](/packages/ez-php-graphql/feed)WikiDiscussions main Synced 1mo ago

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

ez-php/graphql
==============

[](#ez-phpgraphql)

GraphQL module for the ez-php framework. Provides a `POST /graphql` HTTP endpoint, schema builder, query executor, and static facade — powered by [webonyx/graphql-php](https://github.com/webonyx/graphql-php).

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

[](#installation)

```
composer require ez-php/graphql
```

Setup
-----

[](#setup)

### 1. Define your schema

[](#1-define-your-schema)

Create a service provider that binds a `GraphQL\Type\Schema`:

```
// app/Providers/GraphQLSchemaProvider.php
use EzPhp\Contracts\ServiceProvider;
use EzPhp\GraphQL\SchemaBuilder;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;

final class GraphQLSchemaProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->bind(Schema::class, function (): Schema {
            return SchemaBuilder::create()
                ->query([
                    'hello' => [
                        'type' => Type::string(),
                        'resolve' => fn(): string => 'Hello, World!',
                    ],
                    'user' => [
                        'type' => Type::string(),
                        'args' => ['id' => ['type' => Type::nonNull(Type::id())]],
                        'resolve' => fn($root, array $args): string => 'User ' . $args['id'],
                    ],
                ])
                ->build();
        });
    }

    public function boot(): void {}
}
```

### 2. Register providers

[](#2-register-providers)

In `provider/modules.php`, register your schema provider **before** `GraphQLServiceProvider`:

```
$app->register(GraphQLSchemaProvider::class);
$app->register(\EzPhp\GraphQL\GraphQLServiceProvider::class);
```

HTTP Endpoint
-------------

[](#http-endpoint)

`POST /graphql` — accepts JSON:

```
{
  "query": "{ hello }",
  "variables": {},
  "operationName": null
}
```

Response:

```
{
  "data": {
    "hello": "Hello, World!"
  }
}
```

Static Facade
-------------

[](#static-facade)

```
use EzPhp\GraphQL\GraphQL;

$result = GraphQL::execute('{ hello }');
// ['data' => ['hello' => 'Hello, World!']]

$result = GraphQL::execute(
    'query GetUser($id: ID!) { user(id: $id) }',
    ['id' => '42'],
);
```

Schema Builder
--------------

[](#schema-builder)

`SchemaBuilder` wraps webonyx's schema API for common cases:

```
use EzPhp\GraphQL\SchemaBuilder;
use GraphQL\Type\Definition\Type;

$schema = SchemaBuilder::create()
    ->query([
        'posts' => [
            'type'    => Type::listOf(Type::string()),
            'resolve' => fn(): array => ['Post 1', 'Post 2'],
        ],
    ])
    ->mutation([
        'createPost' => [
            'type' => Type::string(),
            'args' => ['title' => ['type' => Type::nonNull(Type::string())]],
            'resolve' => fn($root, array $args): string => $args['title'],
        ],
    ])
    ->build();
```

For advanced schemas (interfaces, unions, enums, custom scalars) construct the webonyx `Schema` directly.

Configuration
-------------

[](#configuration)

Optional `config/graphql.php`:

```
return [
    // URI for the GraphQL endpoint. Default: '/graphql'
    'endpoint' => '/graphql',
];
```

Debug mode is read from `app.debug`. When enabled, error responses include `debugMessage` and stack traces.

Error handling
--------------

[](#error-handling)

GraphQL-level errors (unknown fields, failed resolvers) are returned with HTTP 200 in the `errors` array, per the GraphQL spec:

```
{
  "errors": [
    { "message": "Cannot query field \"nonexistent\" on type \"Query\"." }
  ]
}
```

A missing or empty `query` field returns HTTP 400.

Testing
-------

[](#testing)

No external services required.

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a15a63c46d239d42b8ed4c2fe9adbc5fe99eb62f6e5bb90f08021e0c068e8b37?d=identicon)[AU9500](/maintainers/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (6 commits)")

---

Tags

phpapiframeworkschemagraphqlqueryez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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