simpod/graphql-request-factory
最新稳定版本:0.1.7
Composer 安装命令:
composer require simpod/graphql-request-factory
包简介
Factory to create PSR-7 compatible request to GraphQL server
README 文档
README
This factory creates PSR-7 GraphQL Request through PSR-17 message factories that you can be passed to PSR-18 client.
Installation
Add as Composer dependency:
composer require simpod/graphql-request-factory
Usage
<?php declare(strict_types=1); namespace YourNs; use SimPod\GraphQLRequestFactory\GraphQLRequestFactory; $requestFactory = new GraphQLRequestFactory(new RequestFactoryInterfaceImpl(), new StreamFactoryInterfaceImpl()); $request = $requestFactory->createRequest( 'https://localhost/graphql', <<<'GRAPHQL' query GetHuman($id: ID!) { human(id: $id) { name appearsIn starships { name } } } GRAPHQL, ['id' => 1] );
You can pass $query either as a string or PSR-7 StreamInterface.
Mkay, but what should I do with the request then?
You can pass it to any HTTP client supporting PSR-7. It's up to you what client you decide to use.
Guzzle
http://docs.guzzlephp.org/en/stable/quickstart.html#sending-requests
$response = $client->send($request);
PSR-18 Client (eg. HTTPPlug)
https://www.php-fig.org/psr/psr-18/#clientinterface
$response = $client->sendRequest($request);
统计信息
- 总下载量: 72.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-03