camuthig / graphql-client
A GraphQL client for PHP
Installs: 1 933
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^6.4
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-10-29 05:10:39 UTC
README
A simple, dependency-free GraphQL client for PHP 7.1+
Install
composer require camuthig/graphql-client
Usage
<?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" } */