2017 © Pedro Peláez
 

library graphql-client

A simple client to help execute queries and mutations across GraphQL

image

euautomation/graphql-client

A simple client to help execute queries and mutations across GraphQL

  • Thursday, March 1, 2018
  • by euautomation
  • Repository
  • 5 Watchers
  • 18 Stars
  • 11,979 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 4 Versions
  • 41 % Grown

The README.md

GraphQL Client

A simple package to consume GraphQL APIs., (*1)


Installation

composer require euautomation/graphql-client, (*2)


Usage

Create an instance of EUAutomation\GraphQL\Client:, (*3)

new Client($graphQLURL);

or, (*4)

$client = new Client();
$client->setUrl($graphQLURL);

Response class

Pass in your query, optional variables and headers (eg bearer token), $variables and $headers are optional, (*5)

$response = $client->response($query, $variables, $headers);, (*6)

all()

Use $response->all(); to get all of the data returned in the response, (*7)

errors()

Use $response->errors(); to get all the errors returned in the response, (*8)

hasErrors()

Use $response->hasErrors(); to check if the response contains any errors, (*9)

Specific data from the response class

For example purposes, let's assume you want to get a list of all categories and execute this query., (*10)

{
    allCategories(first:10) {
        category {
            id,
            name,
            slug,
            description
        }
    }
}

Now in order to fetch some meaningful data from the Response class you can do the following:, (*11)

$categories = $response->allCategories->category;

foreach($categories as $category) {
    // Do something with the data?
    $category->id;
    $category->name;
    $category->slug;
    $category->description;
}

You can also set, unset or isset data on the Response class., (*12)


Other responses

Raw guzzle response

Pass in your query, optional variables and headers (eg bearer token), $variables and $headers are optional, (*13)

$client->raw($query, $variables, $headers);, (*14)

Json

Pass in your query, optional variables and headers (eg bearer token), $variables and $headers are optional, (*15)

$client->json($query, $variables, $headers);, (*16)

The Versions

01/03 2018

dev-master

9999999-dev

A simple client to help execute queries and mutations across GraphQL

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carl Knowles
by Rob Wells

php client graphql

19/07 2017

dev-dev

dev-dev

A simple client to help execute queries and mutations across GraphQL

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carl Knowles
by Rob Wells

php client graphql

11/11 2016

0.2

0.2.0.0

A simple client to help execute queries and mutations across GraphQL

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carl Knowles
by Rob Wells

php client graphql

18/10 2016

0.1

0.1.0.0

A simple client to help execute queries and mutations across GraphQL

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carl Knowles
by Rob Wells

php client graphql