-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
33 lines (25 loc) · 981 Bytes
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php declare(strict_types=1);
namespace App;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use MongoDB\Client;
use Symfony\Component\Dotenv\Dotenv;
use function Siler\GraphQL\annotated;
require_once __DIR__ . '/vendor/autoload.php';
(new Dotenv())->loadEnv(__DIR__ . '/.env');
$mongodb = new Client($_ENV['MONGODB_CONN_STR'], [], ['typeMap' => DocumentManager::CLIENT_TYPEMAP]);
$dm_config = new Configuration();
$dm_config->setDefaultDB($_ENV['MONGODB_DEFAULT_DB']);
$dm_config->setMetadataDriverImpl(AnnotationDriver::create(__DIR__ . '/src'));
$dm_config->setHydratorDir(__DIR__ . '/src/generated');
$dm_config->setHydratorNamespace('App\Hydrator');
$context = new Context();
$context->dm = DocumentManager::create($mongodb, $dm_config);
$root_value = new RootValue();
$schema = annotated([
GreetInput::class,
Greet::class,
Mutation::class,
Query::class,
]);