Wraps GitHub v4 API (GraphQL API).
$rateLimits = $client->api('graphql')->execute($query);
To use GitHub v4 API (GraphQL API) requests must authenticated.
$client->authenticate($token, null, Github\AuthMethod::ACCESS_TOKEN);
$result = $client->api('graphql')->execute($query);
You can preview upcoming features and changes to the GitHub GraphQL schema before they are added to the GitHub GraphQL API. To access a schema preview, you'll need to provide a custom media type in the Accept header for your requests. Feature documentation for each preview specifies which custom media type to provide. More info about Schema Previews.
To use GitHub v4 API (GraphQL API) with different Accept
header you can pass third argument to execute method.
$result = $client->api('graphql')->execute($query, [], 'application/vnd.github.starfox-preview+json')
default accept header is
application/vnd.github.v4+json
Variables allow specifying of requested data without dynamical change of a query on a client side.
$query = <<<'QUERY'
query showOrganizationInfo (
$organizationLogin: String!
) {
organization(login: $organizationLogin) {
name
url
}
}
QUERY;
$variables = [
'organizationLogin' => 'KnpLabs'
];
$client->authenticate('<your-token>', null, Github\AuthMethod::ACCESS_TOKEN);
$orgInfo = $client->api('graphql')->execute($query, $variables);