camuthig/graphql-client

A GraphQL client for PHP

Installs: 1 999

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/camuthig/graphql-client

0.3.0 2017-11-30 05:22 UTC

This package is auto-updated.

Last update: 2025-09-29 02:14:01 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"
}
*/