camuthig / graphql-client
PHP 的 GraphQL 客户端
0.3.0
2017-11-30 05:22 UTC
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^6.4
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-09-29 05:01:38 UTC
README
PHP 7.1+ 的简单、无依赖 GraphQL 客户端
安装
composer require camuthig/graphql-client
用法
<?php use Camuthig\Graphql\Client\Client; $headers = [ 'X-From' => 'The Test', ]; $client = new Client('https://9jv9z4w3kr.lp.gql.zone/graphql', $headers); $graphql = <<<'GRAPHQL' query($input: String!) { hello(input: $input) } GRAPHQL; $result = $client->execute($graphql, ['input' => 'everyone']); var_dump($result->hasErrors()); // false var_dump($result->getErrors()); // [] var_dump($result->getData()); /* array(1) { ["hello"]=> string(15) "Hello everyone! From The Test" } */