Doctrine ORM to PHP GraphQL bridge.
This library provides a DoctrineGraphQL builder class to build all Doctrine entities as GraphQL types by following a naming convention.
For every entity class mapped to GraphQL object type it will create basic GraphQL Query and Mutations.
composer require ncrypthic/doctrine-graphql
use LLA\DoctrineGraphQL\DoctrineGraphQL;
use GraphQL\Server\Helper;
use GraphQL\Server\ServerConfig;
/* @var EntityManager $em */
// Get Doctrine's entity manager
$builder = new DoctrineGraphQL();
$builder
->buildTypes($em)
->buildQueries($em)
->buildMutations($em);
$schema = $builder->toGraphQLSchema();
$config = ServerConfig::create(['schema'=>$schema]);
$helper = new Helper();
$req = $helper->parseHttpRequest();
$res = is_array($req)
? $helper->executeBatch($config, $req)
: $helper->executeOperation($config, $req);
See Queries
See Mutations