https://github.com/ncrypthic/doctrine-graphql
Doctrine ORM to GraphQL bridge
https://github.com/ncrypthic/doctrine-graphql
doctrine-orm graphql php7
Last synced: about 1 year ago
JSON representation
Doctrine ORM to GraphQL bridge
- Host: GitHub
- URL: https://github.com/ncrypthic/doctrine-graphql
- Owner: ncrypthic
- License: mit
- Created: 2019-05-26T16:45:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-11T10:34:08.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T21:48:25.893Z (over 1 year ago)
- Topics: doctrine-orm, graphql, php7
- Language: PHP
- Size: 66.4 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# doctrine-graphql
[](https://travis-ci.com/ncrypthic/doctrine-graphql)
[](https://doctrine-graphql.readthedocs.io/en/latest/?badge=latest)
[Doctrine ORM](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/) to [PHP GraphQL](https://webonyx.github.io/graphql-php/) bridge.
## How it works
This library provides a [DoctrineGraphQL](https://github.com/ncrypthic/doctrine-graphql/blob/master/src/DoctrineGraphQL.php) builder class to build all Doctrine entities as GraphQL types by following a [naming convention](docs/types.md#naming-conventions).
For every entity class mapped to GraphQL object type it will create basic GraphQL Query and Mutations.
## Installation
```
composer require ncrypthic/doctrine-graphql
```
## Usage
```php
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](docs/queries.md)
## Mutations
See [Mutations](docs/mutations.md)