PHPackages                             ratehub/doctrine-graphql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ratehub/doctrine-graphql

ArchivedLibrary[Database &amp; ORM](/categories/database)

ratehub/doctrine-graphql
========================

A GraphQL Doctrine ORM bridge

91.0k3[3 issues](https://github.com/ratehub/doctrine-graphql/issues)PHP

Since Jul 13Pushed 5y ago16 watchersCompare

[ Source](https://github.com/ratehub/doctrine-graphql)[ Packagist](https://packagist.org/packages/ratehub/doctrine-graphql)[ RSS](/packages/ratehub-doctrine-graphql/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

doctrine-graphql
================

[](#doctrine-graphql)

[![Build Status](https://camo.githubusercontent.com/f9b56d9bb091a485eac004058e8d84ae0cafdc481c262c130063d1063643f3c6/68747470733a2f2f7472617669732d63692e6f72672f726174656875622f646f637472696e652d6772617068716c2e7376673f6272616e63683d6d6173746572 "Build Status")](https://camo.githubusercontent.com/f9b56d9bb091a485eac004058e8d84ae0cafdc481c262c130063d1063643f3c6/68747470733a2f2f7472617669732d63692e6f72672f726174656875622f646f637472696e652d6772617068716c2e7376673f6272616e63683d6d6173746572)[![Total Downloads](https://camo.githubusercontent.com/0e0f0f536bbaa281c97a6b9956d2085fe4f46c73e816524b5d5aa32a3524cf21/68747470733a2f2f706f7365722e707567782e6f72672f726174656875622f646f637472696e652d6772617068716c2f646f776e6c6f616473)](https://packagist.org/packages/ratehub/doctrine-graphql)[![Latest Stable Version](https://camo.githubusercontent.com/0a57f8ca9a0ce6c25ec060c1dd72ccd16903f858c53e20c9e3669bbf007999f7/68747470733a2f2f706f7365722e707567782e6f72672f726174656875622f646f637472696e652d6772617068716c2f762f737461626c65)](https://packagist.org/packages/ratehub/doctrine-graphql)[![License](https://camo.githubusercontent.com/14af38021d7ecb128d82fad2a8f0fb9ed198cb2afae84c3923cb7a8d5d609e6b/68747470733a2f2f706f7365722e707567782e6f72672f726174656875622f646f637472696e652d6772617068716c2f6c6963656e7365)](https://packagist.org/packages/ratehub/doctrine-graphql)

Generates all the necessary types, queries and mutators using the Doctrine model metadata. All standard data fetching uses the doctrine Array Hydrator. This provider will handle the Object hydration once all queries are finished and the data is ready to be returned.

Features
--------

[](#features)

### Whitelist/Blacklist

[](#whitelistblacklist)

The provider can be setup to filter what objects and properties are included in the final graphql api.

- Whitelisting will only include types/properties that are marked for inclusion
- Blacklisting will only include types/properties that are not marked for exclusion

### Authorization

[](#authorization)

An authorization provider can be implemented to limit access to types and fields via cred level permissions

### Naming Overrides

[](#naming-overrides)

Names and descriptions of types and methods can be overwritten via the GraphQLType and GraphQLProperty annotations. Field Names are not yet able to be overwritten.

### Deferred Loading

[](#deferred-loading)

Associations take advantage of deferred loading via the DeferredBuffer. This is used to significantly reduce the number of queries and solves the N+1 problem when loading data ([https://secure.phabricator.com/book/phabcontrib/article/n\_plus\_one/](https://secure.phabricator.com/book/phabcontrib/article/n_plus_one/))

### Custom Resolvers

[](#custom-resolvers)

Any property can have it's own custom resolver instead of the standard one provided by the provider.

### Pagination

[](#pagination)

The provider supports key and offset pagination for top level queries. Also supports limiting results returned in an n-to-Many relationship.

### Sorting

[](#sorting)

A queries results can be sorted by one or more fields in either ascending or descending order.

### Query Filters for Types

[](#query-filters-for-types)

Core types such as Strings, DateTime, Int, and BigInt support filters such as

equals, in, less, greater, lessOrEqual, greaterOrEqual, between

### Polymorphic Entities

[](#polymorphic-entities)

Provider supports querying polymorphic entities and querying unique fields per type using the GraphQL inline fragments.

Getting Started
---------------

[](#getting-started)

After initializing doctrine you'll need to register the graphql annotations:

```
use RateHub\GraphQL\Doctrine\AnnotationLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

AnnotationRegistry::registerLoader(array(new AnnotationLoader(), "load"));
```

The next step is to initialize the graphql schema:

```
use RateHub\GraphQL\Doctrine\DoctrineProvider;
use RateHub\GraphQL\Doctrine\DoctrineProviderOptions;
use RateHub\GraphQL\GraphContext;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Schema;

// Set the options including any extensions
$options = new DoctrineProviderOptions();
$options->em = $em; // EntityManager initialized within your as app as needed
$options->filter = 'blacklist'

// Initialize the Provider. With blacklist filtering, no
// annotations are needed unless something needs to be
// excluded. The provider will generate all queries,
// mutators and types needed.
$provider = new DoctrineProvider('default', $options);

// Initialize top level types
$context = new GraphContext();
$queryType = new ObjectType('query', $provider->getQueries());
$mutatorType = new ObjectType('mutator', $provider->getMutators());

// Initialize the schema
$schema = new Schema([
                      'query' => $queryType,
                      'mutation' => $mutatorType,
                      'types' => $provider->getTypes()
                    ]);
```

From here you can execute a query:

```
   $result = \GraphQL\GraphQL::execute(
       $schema,
       $params['query'], // Request parameter containing the graphql query
       null,
       $context,
       null
   );
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d370bcff830851c988f57eafd911e22d4a3ebe56d4d5e0860906b83d51089ade?d=identicon)[voziv](/maintainers/voziv)

![](https://www.gravatar.com/avatar/449091aaf4b9781deea0b90483887a50b80967979ba51d0c27ecb37049f57053?d=identicon)[nathanael.morrison@ratehub.ca](/maintainers/nathanael.morrison@ratehub.ca)

---

Top Contributors

[![nathanael-morrison](https://avatars.githubusercontent.com/u/27689158?v=4)](https://github.com/nathanael-morrison "nathanael-morrison (50 commits)")

---

Tags

apidoctrinegraphqlgraphql-php

### Embed Badge

![Health badge](/badges/ratehub-doctrine-graphql/health.svg)

```
[![Health](https://phpackages.com/badges/ratehub-doctrine-graphql/health.svg)](https://phpackages.com/packages/ratehub-doctrine-graphql)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M542](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
