doctrine-graphql

Doctrine ORM to PHP GraphQL bridge.

How it works

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.

Installation

composer require ncrypthic/doctrine-graphql

Usage

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);

Queries

See Queries

Mutations

See Mutations