{"id":19039833,"url":"https://github.com/johnlui/graphql-laravel","last_synced_at":"2025-10-13T20:41:54.728Z","repository":{"id":57001000,"uuid":"312952744","full_name":"johnlui/GraphQL-Laravel","owner":"johnlui","description":"A Laravel GraphQL reference implementation forked from webonyx/graphql-php","archived":false,"fork":false,"pushed_at":"2023-06-11T15:17:50.000Z","size":618,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-31T12:44:21.197Z","etag":null,"topics":["graphql","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnlui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-15T03:49:13.000Z","updated_at":"2023-06-07T10:30:58.000Z","dependencies_parsed_at":"2025-04-17T17:13:28.162Z","dependency_job_id":"d86a52df-065e-45b7-87d0-140019213efb","html_url":"https://github.com/johnlui/GraphQL-Laravel","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/johnlui/GraphQL-Laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlui%2FGraphQL-Laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlui%2FGraphQL-Laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlui%2FGraphQL-Laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlui%2FGraphQL-Laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnlui","download_url":"https://codeload.github.com/johnlui/GraphQL-Laravel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnlui%2FGraphQL-Laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016930,"owners_count":26085911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","laravel","php"],"created_at":"2024-11-08T22:19:01.710Z","updated_at":"2025-10-13T20:41:54.707Z","avatar_url":"https://github.com/johnlui.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/johnlui/GraphQL-Laravel\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/2127912/99667011-b71cfc80-2aa6-11eb-95d2-b2e1bbfa73f4.png\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://packagist.org/packages/johnlui/GraphQL-Laravel\"\u003e\u003cimg src=\"https://poser.pugx.org/johnlui/GraphQL-Laravel/v/stable\" alt=\"GitHub version\" height=\"18\"\u003e\u003c/a\u003e\n  \u003c!-- \u003ca href=\"https://github.com/Pinatra/Pinatra\"\u003e\u003cimg src=\"https://img.shields.io/badge/Code_Coverage-100%25-brightgreen.svg\" alt=\"code-coverage\"\u003e\u003c/a\u003e --\u003e\n  \u003ca href=\"https://github.com/Pinatra/Pinatra\"\u003e\u003cimg src=\"https://img.shields.io/badge/PHP-7.1%2B-orange.svg\" alt=\"php-version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/johnlui/GraphQL-Laravel\"\u003e\u003cimg src=\"https://poser.pugx.org/johnlui/GraphQL-Laravel/license.svg\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/johnlui/GraphQL-Laravel\"\u003e\u003cimg src=\"https://travis-ci.org/johnlui/GraphQL-Laravel.svg?branch=master\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n[`webonyx/graphql-php`](https://github.com/webonyx/graphql-php) 的 Laravel 适配，魔改原库，将其彻底融入 Laravel 生命周期。\n\n## 功能\n\n1. 接入 Laravel Middleware\n2. 依赖 Laravel Exception 处理异常流程\n3. 完美接入 Eloquent\n4. 提炼出 GraphQL 路由\n5. 提供 Types 文件夹，并提供强大的 Type 基类\n6. 提供 QueryFields 文件夹，提供类似于 Controller 归类的功能\n7. 暴露用户请求字段给 QueryField，便于节约资源、并发 RPC 等后续操作\n8. 提供 JSON API 语境下的调试函数 `cc()`\n\n\u003cbr\u003e\n\n## 用法\n\n### 安装 Composer 包\n\n`composer require johnlui/graphql-laravel`\n\n\n### 部署开发目录及配置文件到 app 下\n\n`php artisan vendor:publish`\n\n### 快速入门\n\n\u003e 1. `app\\GraphApp` 为工作文件夹\n\u003e 2. `Routes.php` 为路由文件\n\u003e 3. `QueryFields` 目录存放响应代码\n\u003e 4. `Types` 目录存放自定义类型\n\u003e 5. `config/graphql.php` 为配置文件\n\n## demo\n\n#### query：\n\n```graphql\nquery ($id: Int) {\n  foo(id: $id) {\n    id\n    foo\n    bar\n  }\n}\n```\n\n#### variables:\n\n此处为 JSON 格式描述，开发时应使用 key-value 形式描述 variables，不应该使用 JSON 字符串。\n\n```json\n{\n  \"id\": 200\n}\n```\n\n#### 启动 server\n\n`php artisan serve`\n\n#### url\n\n`http://127.0.0.1:8000/graphql`\n\n修改默认路径请编辑`config/graphql.php`中的`apiUri`。\n\n#### curl raw 代码描述\n\n```bash\ncurl --location --request POST 'http://127.0.0.1:8000/graphql' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\"query\":\"query($id: Int) {\\n    foo(id: $id) {\\n        id\\n        foo\\n        bar\\n    }\\n}\",\"variables\":{\"id\":200}}'\n```\n\n#### 返回值\n\n```json\n{\n  \"status\": 0,\n  \"message\": \"OK\",\n  \"values\": {\n    \"foo\": {\n      \"id\": 200,\n      \"foo\": \"foo\",\n      \"bar\": \"bar\"\n    },\n    \"queries\": []\n  }\n}\n```\n\n## License\n\nThe `johnlui/GraphQL-Laravel` is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnlui%2Fgraphql-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnlui%2Fgraphql-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnlui%2Fgraphql-laravel/lists"}