bug-979 / graphql-demo
构建GraphQL服务
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/bug-979/graphql-demo
Requires
- php: >=7.0
- webonyx/graphql-php: >=0.12.2
This package is auto-updated.
Last update: 2025-10-22 14:00:59 UTC
README
构建GraphQL服务
安装
$ composer require bug-979/graphql-demo:dev-master
注意:由于ThinkPHP 5.1对比5.0有较大改变,所以目前只支持新版5.1。
使用
首先需要在/application/command.php中增加两个指令。
<?php return [ 'tomorrow\think\GraphQLCommand', 'tomorrow\think\SynchFields' ];
然后在项目根目录下使用如下命令初始化框架
$ php think graph init
自动生成Schema(请先建立好数据库)
$ php think SynchFields
运行该命令之后如果提示初始化成功,则可以在/config/graph.php看到生成出的配置文件,以及在/application/http/graph文件夹下生成出的实例项目。
在初始化完毕之后,你可以使用GraphQL的测试工具请求http://localhost/api/gql进行尝试。