PHP code example of ncrypthic / doctrine-graphql
1. Go to this page and download the library: Download ncrypthic/doctrine-graphql library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ncrypthic / doctrine-graphql example snippets
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);