PHPackages                             johnlui/graphql-laravel - 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. johnlui/graphql-laravel

ActiveLibrary[API Development](/categories/api)

johnlui/graphql-laravel
=======================

A Laravel GraphQL reference implementation forked from webonyx/graphql-php

v1.5.1(2y ago)3181MITPHPPHP ^7.1||^8.0

Since Nov 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/johnlui/GraphQL-Laravel)[ Packagist](https://packagist.org/packages/johnlui/graphql-laravel)[ Docs](https://github.com/johnlui/GraphQL-Laravel)[ RSS](/packages/johnlui-graphql-laravel/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (3)Dependencies (13)Versions (11)Used By (0)

 [![](https://user-images.githubusercontent.com/2127912/99667011-b71cfc80-2aa6-11eb-95d2-b2e1bbfa73f4.png)](https://github.com/johnlui/GraphQL-Laravel)

 [![GitHub version](https://camo.githubusercontent.com/5c334926459f5cc4de8d58233f7ec522fad85a140141e097874bbd56d83e0c8f/68747470733a2f2f706f7365722e707567782e6f72672f6a6f686e6c75692f4772617068514c2d4c61726176656c2f762f737461626c65)](https://packagist.org/packages/johnlui/GraphQL-Laravel) [![php-version](https://camo.githubusercontent.com/ee3bceb8628bc2479c2a166ab2c28cb88e2a99163326b7dcc1022546baa31106/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e312532422d6f72616e67652e737667)](https://github.com/Pinatra/Pinatra) [![License](https://camo.githubusercontent.com/3eff044bd7b2611f7091d81fe56cb8cc03e2735b8385ecdda88764a57972e40e/68747470733a2f2f706f7365722e707567782e6f72672f6a6f686e6c75692f4772617068514c2d4c61726176656c2f6c6963656e73652e737667)](https://packagist.org/packages/johnlui/GraphQL-Laravel) [![](https://camo.githubusercontent.com/146ef8c997d3f6b2ab50a10af6f95635ad56dee543553eb7925d8e0b18bb785b/68747470733a2f2f7472617669732d63692e6f72672f6a6f686e6c75692f4772617068514c2d4c61726176656c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/johnlui/GraphQL-Laravel)

[`webonyx/graphql-php`](https://github.com/webonyx/graphql-php) 的 Laravel 适配，魔改原库，将其彻底融入 Laravel 生命周期。

功能
--

[](#功能)

1. 接入 Laravel Middleware
2. 依赖 Laravel Exception 处理异常流程
3. 完美接入 Eloquent
4. 提炼出 GraphQL 路由
5. 提供 Types 文件夹，并提供强大的 Type 基类
6. 提供 QueryFields 文件夹，提供类似于 Controller 归类的功能
7. 暴露用户请求字段给 QueryField，便于节约资源、并发 RPC 等后续操作
8. 提供 JSON API 语境下的调试函数 `cc()`

用法
--

[](#用法)

### 安装 Composer 包

[](#安装-composer-包)

`composer require johnlui/graphql-laravel`

### 部署开发目录及配置文件到 app 下

[](#部署开发目录及配置文件到-app-下)

`php artisan vendor:publish`

### 快速入门

[](#快速入门)

> 1. `app\GraphApp` 为工作文件夹
> 2. `Routes.php` 为路由文件
> 3. `QueryFields` 目录存放响应代码
> 4. `Types` 目录存放自定义类型
> 5. `config/graphql.php` 为配置文件

demo
----

[](#demo)

#### query：

[](#query)

```
query ($id: Int) {
  foo(id: $id) {
    id
    foo
    bar
  }
}
```

#### variables:

[](#variables)

此处为 JSON 格式描述，开发时应使用 key-value 形式描述 variables，不应该使用 JSON 字符串。

```
{
  "id": 200
}
```

#### 启动 server

[](#启动-server)

`php artisan serve`

#### url

[](#url)

`http://127.0.0.1:8000/graphql`

修改默认路径请编辑`config/graphql.php`中的`apiUri`。

#### curl raw 代码描述

[](#curl-raw-代码描述)

```
curl --location --request POST 'http://127.0.0.1:8000/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query($id: Int) {\n    foo(id: $id) {\n        id\n        foo\n        bar\n    }\n}","variables":{"id":200}}'
```

#### 返回值

[](#返回值)

```
{
  "status": 0,
  "message": "OK",
  "values": {
    "foo": {
      "id": 200,
      "foo": "foo",
      "bar": "bar"
    },
    "queries": []
  }
}
```

License
-------

[](#license)

The `johnlui/GraphQL-Laravel` is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Recently: every ~209 days

Total

10

Last Release

1071d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2127912?v=4)[吕文翰](/maintainers/JohnLui)[@johnlui](https://github.com/johnlui)

---

Top Contributors

[![johnlui](https://avatars.githubusercontent.com/u/2127912?v=4)](https://github.com/johnlui "johnlui (19 commits)")

---

Tags

graphqllaravelphpapilaravelgraphql

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[aimeos/aimeos-laravel

Cloud native, API first Laravel eCommerce package with integrated AI for ultra-fast online shops, marketplaces and complex B2B projects

8.6k214.7k3](/packages/aimeos-aimeos-laravel)[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[alexaandrov/laravel-graphql-client

GraphQL client for laravel/lumen

125.6k](/packages/alexaandrov-laravel-graphql-client)

PHPackages © 2026

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