Repositories and query builder
find(), findBy(), count() and a query builder with filters, ordering, pagination and array results.
Map PHP objects to a GraphQL API with attributes, query it with repositories and a query builder, the way Doctrine does with SQL.
composer require hecht-a/graphql-ormRequirements: PHP 8.4+ and Symfony 7.4 or 8.x. The bundle relies on the HTTP client service provided by FrameworkBundle (framework.http_client, enabled by default when symfony/http-client is installed).
# config/packages/graphql_orm.yaml
graphql_orm:
endpoint: 'http://localhost:4000/graphql'
mapping:
entity:
dir: '%kernel.project_dir%/src/GraphQL/Entity'
namespace: App\GraphQL\Entity
repository:
dir: '%kernel.project_dir%/src/GraphQL/Repository'
namespace: App\GraphQL\Repositoryphp bin/console graphqlorm:make:entity Task --from-schema$tasks = $taskRepository->findBy(['status' => 'active'], ['createdAt' => Direction::Desc], 10);
$qb = $taskRepository->createQueryBuilder();
$tasks = $qb
->select('id', 'title', 'user.name')
->where($qb->expr()->eq('status', 'active'))
->limit(10)
->getQuery()
->getResult();Next: configure the bundle, then map your entities.