refactor(github): build GraphQL query without the client bundle

The eightpoints/guzzle-bundle and idci/graphql-client-bundle only
existed to build one near-static query string, and the bundle's own
HTTP transport was already bypassed in favor of Symfony HttpClient.
Build the query with sprintf/json_encode instead, drop both bundles
from config/bundles.php, and update the test double accordingly.
This commit is contained in:
2026-07-11 16:46:11 +02:00
parent 78e7a72ee9
commit 885dec357e
4 changed files with 9 additions and 98 deletions
+7 -21
View File
@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace App\Service\Provider;
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClient;
use IDCI\Bundle\GraphQLClientBundle\Client\GraphQLApiClientRegistryInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -24,7 +22,6 @@ final class GitHubProvider implements ProviderInterface
public function __construct(
private readonly HttpClientInterface $client,
private readonly GraphQLApiClientRegistryInterface $registry,
private readonly string $username,
private readonly string $token,
private readonly LoggerInterface $logger,
@@ -54,25 +51,14 @@ final class GitHubProvider implements ProviderInterface
$from = (new \DateTimeImmutable('-365 days'))->format('Y-m-d\T00:00:00\Z');
$to = (new \DateTimeImmutable())->format('Y-m-d\T23:59:59\Z');
/** @var GraphQLApiClient $graphqlClient */
$graphqlClient = $this->registry->get('github');
$query = sprintf(
'query { user(login: %s) { contributionsCollection(from: %s, to: %s) { contributionCalendar { weeks { contributionDays { date contributionCount } } } } } }',
json_encode($this->username),
json_encode($from),
json_encode($to),
);
$query = $graphqlClient->buildQuery(
['user' => ['login' => $this->username]],
[
'contributionsCollection' => [
'_parameters' => ['from' => $from, 'to' => $to],
'contributionCalendar' => [
'weeks' => [
'contributionDays' => ['date', 'contributionCount'],
],
],
],
]
)->getGraphQLQuery();
// GitHub's GraphQL API requires application/json — the bundle's built-in
// transport sends form_params, so we use Symfony HttpClient here instead.
// GitHub's GraphQL API requires application/json.
// request() doesn't block; the response is read in resolveFetch() so
// multiple providers' requests can be in flight at once.
return $this->client->request('POST', self::GRAPHQL_URL, [