PHPackages                             maiscraft/graphql-hyperf - 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. maiscraft/graphql-hyperf

ActiveLibrary[API Development](/categories/api)

maiscraft/graphql-hyperf
========================

Hyperf adapter for Maiscraft GraphQL - Auto-wiring, PSR container bridge, HTTP controller, and configuration provider

1.0.0(1mo ago)00MITPHP ^8.2

Since Jun 21Compare

[ Source](https://github.com/mslbit/graphql-hyperf)[ Packagist](https://packagist.org/packages/maiscraft/graphql-hyperf)[ Docs](https://github.com/mslbit/graphql-hyperf)[ RSS](/packages/maiscraft-graphql-hyperf/feed)WikiDiscussions Synced 2w ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Maiscraft GraphQL Hyperf Adapter
================================

[](#maiscraft-graphql-hyperf-adapter)

[maiscraft/graphql](https://github.com/mslbit/graphql) 的 Hyperf 框架适配包，提供自动装配、PSR 容器桥接、HTTP 控制器和配置发布。

功能
--

[](#功能)

- **ConfigProvider**：自动注册 GraphQLEngine 及所有依赖到 Hyperf DI 容器
- **HyperfContainer**：PSR-11 容器桥接，将 Hyperf DI 适配为 `Maiscraft\GraphQL\Contract\ContainerInterface`
- **GraphQLController**：处理 `POST /graphql`、`GET /graphql`、`GET /playground` 请求
- **适配器**：Cache、Logger、EventDispatcher、Validator、RateLimiter 全部桥接到 Hyperf 对应组件
- **配置发布**：`php bin/hyperf.php vendor:publish maiscraft/graphql-hyperf`

安装
--

[](#安装)

```
composer require maiscraft/graphql
composer require maiscraft/graphql-hyperf
```

配置
--

[](#配置)

安装后发布配置文件：

```
php bin/hyperf.php vendor:publish maiscraft/graphql-hyperf
```

生成 `config/autoload/graphql.php`：

```
return [
    'debug' => env('GRAPHQL_DEBUG', true),

    // 显式指定 Resolver 类
    'sources' => [
        // App\GraphQL\ArticleResolver::class,
    ],

    // 目录路径扫描（从文件内容解析 namespace 获取类名）
    'scan_paths' => [
        BASE_PATH . '/app',
    ],

    'security' => [
        'max_query_depth' => 15,
        'max_query_complexity' => 1000,
    ],

    'rate_limit' => [
        'max_attempts' => 100,
        'decay_seconds' => 60,
    ],
];
```

使用
--

[](#使用)

定义 Entity、Enum、DTO、Resolver 后（参见 [maiscraft/graphql](https://github.com/mslbit/graphql)），Hyperf 自动发现并构建 Schema：

```
namespace App\GraphQL;

use App\Domain\Entity\Article;
use Maiscraft\GraphQL\Annotation\Query;
use Maiscraft\GraphQL\Annotation\Arg;
use Maiscraft\GraphQL\Contract\ResolverInterface;

class ArticleResolver implements ResolverInterface
{
    public function __construct(
        private ArticleRepositoryInterface $repository
    ) {}

    #[Query(description: 'Get an article')]
    public function article(#[Arg(type: 'ID!')] string $id): ?Article
    {
        return $this->repository->findById((int) $id);
    }
}
```

查询：

```
curl -X POST http://localhost:9501/graphql \
  -H "Content-Type: application/json" \
  -d '{"query": "{ article(id: \"1\") { id title } }"}'
```

API 端点
------

[](#api-端点)

方法路径说明POST`/graphql`执行 GraphQL 查询GET`/graphql`Introspection 查询GET`/playground`GraphQL Playground 调试界面项目结构
----

[](#项目结构)

```
src/
├── ConfigProvider.php        # Hyperf 服务注册
├── Contract/                 # Hyperf 组件适配器
│   ├── HyperfCache.php
│   ├── HyperfContainer.php
│   ├── HyperfEventDispatcher.php
│   ├── HyperfLogger.php
│   ├── HyperfRateLimiter.php
│   └── HyperfValidator.php
├── Controller/
│   └── GraphQLController.php # HTTP 控制器
publish/
└── graphql.php               # 配置模板

```

依赖
--

[](#依赖)

- PHP ^8.2
- Hyperf ^3.1
- [maiscraft/graphql](https://github.com/mslbit/graphql) ^1.0

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23d2c2d4840594d8f9e145b55384df97d32e8a25e301fc767e924ec3901edd84?d=identicon)[mslbit](/maintainers/mslbit)

---

Tags

PSR-11graphqladapterswoolephp8hyperf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[friendsofhyperf/sentry

The sentry component for Hyperf.

1977.7k](/packages/friendsofhyperf-sentry)[hyperf/xxl-job-incubator

php hyperf xxljob

4638.1k17](/packages/hyperf-xxl-job-incubator)[hyperf/hyperf-skeleton

A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.

315191.9k](/packages/hyperf-hyperf-skeleton)[mineadmin/mineadmin

Quickly build a background management system for web applications

1.2k2.2k](/packages/mineadmin-mineadmin)[hyperf/watcher

Hot reload watcher for Hyperf

19924.3k33](/packages/hyperf-watcher)[hyperf/swagger

A swagger library for Hyperf.

20381.0k8](/packages/hyperf-swagger)

PHPackages © 2026

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