convenia/graphql-client
Composer 安装命令:
composer require convenia/graphql-client
包简介
Client to make graphql requests
README 文档
README
This package allows you to make GraphQL requests using pure PHP.
Implementation
The package has two basic classes, Query and Mutation that needs to be used when implementing a query or a mutation. In both cases you need to pass an instance of GuzzleHttp\Client and the base url. Every query or mutation needs also to set the name and desired output parameters.
Example
use Convenia\GraphQLClient\Mutation; class UpdateUserMutation extends Mutation { protected $queryName = 'createUser'; protected $outputParams = [ 'id', 'name', 'last_name' ]; }
Usage
When calling the mutation's methods you can choose between using the output params setted in the model, or you can also pass the desired params.
Example
class User { protected $client = new GuzzleHttp\Client(); protected $baseUrl = 'http://www.mygraphqlapi/v1/graphql' public static function create($userId, $data, $returnParams = []) { $mutation = new UpdateUserMutation($this->baseUrl); $mutation->update($userId, $data, $returnParams); } }
Responses
This package has a handler that deals with the response. This response class also deals with the possible GraphQL errors.
统计信息
- 总下载量: 1.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-02-14