ncrypthic / doctrine-graphql
Doctrine to GraphQL adapter
2.0.0
2020-07-03 04:23 UTC
Requires
- doctrine/orm: ^2.6
- webonyx/graphql-php: ^0.13.4
Requires (Dev)
- phpunit/phpunit: ^8
- ramsey/uuid-doctrine: ^1.5
This package is auto-updated.
Last update: 2024-12-11 21:15:23 UTC
README
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