nginxsonarrradarrplexorganizrdashboardbookmarkapplication-dashboardmuximuxlandingpagestartpagelandinghtpcserverhomepagesabnzbdheimdallembycouchpotatonzbget
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
962 B
48 lines
962 B
6 years ago
|
<?php
|
||
|
|
||
|
namespace Github\Api;
|
||
|
|
||
|
/**
|
||
|
* GraphQL API.
|
||
|
*
|
||
|
* Part of the Github v4 API
|
||
|
*
|
||
|
* @link https://developer.github.com/v4/
|
||
|
*
|
||
|
* @author Miguel Piedrafita <soy@miguelpiedrafita.com>
|
||
|
*/
|
||
|
class GraphQL extends AbstractApi
|
||
|
{
|
||
|
use AcceptHeaderTrait;
|
||
|
|
||
|
/**
|
||
|
* @param string $query
|
||
|
* @param array $variables
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function execute($query, array $variables = [])
|
||
|
{
|
||
|
$this->acceptHeaderValue = 'application/vnd.github.v4+json';
|
||
|
$params = [
|
||
|
'query' => $query,
|
||
|
];
|
||
|
if (!empty($variables)) {
|
||
|
$params['variables'] = json_encode($variables);
|
||
|
}
|
||
|
|
||
|
return $this->post('/graphql', $params);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param string $file
|
||
|
* @param array $variables
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function fromFile($file, array $variables = [])
|
||
|
{
|
||
|
return $this->execute(file_get_contents($file), $variables);
|
||
|
}
|
||
|
}
|