evilfreelancer / simplegqlient
用PHP编写的最简单的GraphQL客户端
1.0.0
2022-11-02 06:00 UTC
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- larapack/dd: ^1.1
This package is auto-updated.
Last update: 2024-09-19 12:11:14 UTC
README
用PHP编写的最简单的GraphQL客户端。受到Lighthouse PHP项目启发,特别是由内嵌客户端,可以用于测试基于Laravel的GraphQL服务器的实现。
composer require evilfreelancer/simplegqlient
小型示例
require_once __DIR__ . '/../vendor/autoload.php'; $githubToken = 'xxx'; $client = new \SimpleGQLient\Client('https://api.github.com/graphql', [ 'Authorization' => 'Bearer ' . $githubToken, 'Accept' => 'application/vnd.github.hawkgirl-preview+json,', ]); $response = $client->graphQL(/** @lang GraphQL */ ' { user(login: "evilfreelancer") { repositories(ownerAffiliations: OWNER, isFork: false, first: 100) { nodes { name languages(first: 10, orderBy: { field: SIZE, direction: DESC }) { edges { size node { color name } } } } } } } '); // \Psr\Http\Message\ResponseInterface in response $output = $response->getBody()->getContents(); var_dump($output);
路线图
- 基本客户端
- 多部分支持