fox-hound-ltd / mixture-api-client
GraphQL & REST API Client
Installs: 25 702
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.3
This package is not auto-updated.
Last update: 2024-09-21 08:15:52 UTC
README
概要
GraphQLとRESTに対応したClientライブラリ
PHP Client for GraphQL & REST
インストール
Composerを利用
$ composer require fox-hound-ltd/mixture-api-client
利用方法サンプル
シンプルパターン
<?php use MixtureApiClient\ClientBuilder; $client = ClientBuilder::build( 'https://hogehoge.com/graphql' ); $query = <<<'QUERY' query foo(id: 11){ id name } QUERY; $response = $client->query($query);
JsonWebTokenを利用する場合
<?php use MixtureApiClient\ClientBuilder; use MixtureApiClient\JWT; $jwt= new JWT(); $payload['secret_key'] = 'fiwivkbbeec1e958a6c5dd31336242607c0887754b1d43ebf071fb2890533d611a'; $headers = [ 'Authorization' => $jwt->makeToken('secret', $payload), ]; $config = ['headers' => $headers]; $client = ClientBuilder::build( 'https://hogehoge.com/graphql', $config ); $query = <<<'QUERY' query GetHoge($target_id: ID, $member_name: String) { foo(id: $target_id) { id_foo bar (name: $member_name) { id_bar } } } QUERY; $variables = [ 'target_id' => 11, 'member_name' => 'bar', ]; $response = $client->query($query, $variables);
テストについて
$ composer test
ライセンス
The Apache 2.0 license. Please see LICENSE for more information.