PHPackages                             api-skeletons/doctrine-orm-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. api-skeletons/doctrine-orm-graphql

ActiveLibrary

api-skeletons/doctrine-orm-graphql
==================================

GraphQL Type Driver for Doctrine ORM

13.0.2(2mo ago)124.9k↓38.5%2[2 PRs](https://github.com/API-Skeletons/doctrine-orm-graphql/pulls)1MITPHPPHP ^8.4CI passing

Since Oct 17Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/API-Skeletons/doctrine-orm-graphql)[ Packagist](https://packagist.org/packages/api-skeletons/doctrine-orm-graphql)[ RSS](/packages/api-skeletons-doctrine-orm-graphql/feed)WikiDiscussions 13.0.x Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (74)Used By (1)

 [![](https://camo.githubusercontent.com/4d1632649c62e3fdbdcaaf9c4c0ead755c6131859431f19b41e6dcf81ef51d97/68747470733a2f2f706c616365686f6c642e636f2f31307831302f3333376162372f3333376162372e706e67)](https://camo.githubusercontent.com/4d1632649c62e3fdbdcaaf9c4c0ead755c6131859431f19b41e6dcf81ef51d97/68747470733a2f2f706c616365686f6c642e636f2f31307831302f3333376162372f3333376162372e706e67) [![](https://raw.githubusercontent.com/api-skeletons/doctrine-orm-graphql/master/docs/banner.png)](https://raw.githubusercontent.com/api-skeletons/doctrine-orm-graphql/master/docs/banner.png)

GraphQL Type Driver for Doctrine ORM
====================================

[](#graphql-type-driver-for-doctrine-orm)

[![Build Status](https://github.com/API-Skeletons/doctrine-orm-graphql/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/API-Skeletons/doctrine-orm-graphql/actions/workflows/continuous-integration.yml?query=branch%3Amain)[![Code Coverage](https://camo.githubusercontent.com/611ddc07bda85e5f47315efefc29143addcc9025671c4380321e3b9b73ff9ce9/68747470733a2f2f636f6465636f762e696f2f67682f4150492d536b656c65746f6e732f646f637472696e652d6f726d2d6772617068716c2f6272616e63682f6d61696e2f6772617068732f62616467652e737667)](https://codecov.io/gh/API-Skeletons/doctrine-orm-graphql/branch/main)[![PHPStan](https://camo.githubusercontent.com/d117944b58da8146f96b4ef7403807610a20eeb3fbcaaaf95157bbcdad1686eb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e737667)](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg)[![psalm](https://camo.githubusercontent.com/d4431cec0af8da4041de0da69cb9caa8984d8d4080666e137e4fcd506ecaba0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7073616c6d2d6c6576656c253230312d627269676874677265656e2e737667)](https://img.shields.io/badge/psalm-level%201-brightgreen.svg)[![License](https://camo.githubusercontent.com/e6864d354cfec2f76b4449cbf43d748632b922fc8bf651795da2f22716a3bc99/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f646f637472696e652d6f726d2d6772617068716c2f6c6963656e7365)](//packagist.org/packages/api-skeletons/doctrine-orm-graphql)

```
GraphQL, with types so neat,
Felt a longing, a database heat.
"I'd love," it would sigh,
"To be SQL, oh my!
With relations and joins, oh so sweet!"

```

This library provides a GraphQL driver for Doctrine ORM for use with the [webonyx/graphql-php](https://github.com/webonyx/graphql-php) library.
It **does not** try to redefine how that excellent library operates. Instead, it creates types to be used within the framework that library provides.

Many other GraphQL libraries for Doctrine ORM are available.
Some of these such as [overblog/graphql-bundle](https://github.com/overblog/GraphQLBundle/tree/master)and [API Platform](https://api-platform.com/) are integrations into frameworks. But all of these libraries use the same underlying library, [webonyx/graphql-php](https://github.com/webonyx/graphql-php) and that library has its own way of doing things. This library is a driver for that library and together they are framework agnostic.

Installation
------------

[](#installation)

Via composer:

```
composer require api-skeletons/doctrine-orm-graphql
```

Documentation
-------------

[](#documentation)

Full documentation is available at  or in the [docs](https://github.com/api-skeletons/doctrine-orm-graphql/blob/master/docs) directory.

Features
--------

[](#features)

- Supports all [Doctrine Types](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/types.html#data-type-mappings) and allows custom types
- Pagination with the [GraphQL Complete Connection Model](https://graphql.org/learn/pagination/#complete-connection-model)
- [Filtering of sub-collections](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/queries.html)
- [Events](https://github.com/API-Skeletons/doctrine-orm-graphql#events) for modifying queries, entity types and more
- [Multiple configuration group support](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/driver.html#group)

Technical Features
------------------

[](#technical-features)

- Attribute-based metadata
- PHP 8.4 Lazy Ghost Objects for deferred type initialization
- PSR-14 Event-Driven Architecture for query and type customization
- Custom PSR-11 Container with lazy initialization and buildable types
- Advanced hydration system with Doctrine Laminas Hydrator and extraction strategies
- Dynamic QueryBuilder generation with filter translation and event-driven query modification to solve N+1 query problems

Examples
--------

[](#examples)

The **LDOG Stack**: Laravel, Doctrine ORM, and GraphQL uses this library:

For an working implementation see

Quick Start
-----------

[](#quick-start)

Add attributes to your Doctrine entities or see [globalEnable](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/driver.html#globalenable) for all entities in your schema without attribute configuration.

```
use ApiSkeletons\Doctrine\ORM\GraphQL\Attribute as GraphQL;

#[GraphQL\Entity]
class Artist
{
    #[GraphQL\Field]
    public $id;

    #[GraphQL\Field]
    public $name;

    #[GraphQL\Association]
    public $performances;
}

#[GraphQL\Entity]
class Performance
{
    #[GraphQL\Field]
    public $id;

    #[GraphQL\Field]
    public $venue;

    /**
     * Not all fields need attributes.
     * Only add attribues to fields you want available in GraphQL
     */
    public $city;
}
```

Create the driver and GraphQL schema

```
use ApiSkeletons\Doctrine\ORM\GraphQL\Driver;
use Doctrine\ORM\EntityManager;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;

$driver = new Driver($entityManager);

$schema = new Schema([
    'query' => new ObjectType([
        'name' => 'query',
        'fields' => [
            'artists' => $driver->completeConnection(Artist::class),
        ],
    ]),
    'mutation' => new ObjectType([
        'name' => 'mutation',
        'fields' => [
            'artistUpdateName' => [
                'type' => $driver->type(Artist::class),
                'args' => [
                    'id' => Type::nonNull(Type::id()),
                    'input' => Type::nonNull($driver->input(Artist::class, ['name'])),
                ],
                'resolve' => function ($root, $args) use ($driver): Artist {
                    $artist = $driver->get(EntityManager::class)
                        ->getRepository(Artist::class)
                        ->find($args['id']);

                    $artist->setName($args['input']['name']);
                    $driver->get(EntityManager::class)->flush();

                    return $artist;
                },
            ],
        ],
    ]),
]);
```

Run GraphQL queries

```
use GraphQL\GraphQL;

$query = '{
  artists {
    edges {
      node {
        id
        name
        performances {
          edges {
            node {
              venue
            }
          }
        }
      }
    }
  }
}';

$result = GraphQL::executeQuery(
    schema: $schema,
    source: $query,
    variableValues: null,
    operationName: null
);

$output = $result->toArray();
```

Run GraphQL mutations

```
use GraphQL\GraphQL;

$query = '
  mutation ArtistUpdateName($id: Int!, $name: String!) {
    artistUpdateName(id: $id, input: { name: $name }) {
      id
      name
    }
  }
';

$result = GraphQL::executeQuery(
    schema: $schema,
    source: $query,
    variableValues: [
        'id' => 1,
        'name' => 'newName',
    ],
    operationName: 'ArtistUpdateName'
);

$output = $result->toArray();
```

Filters
-------

[](#filters)

For every enabled field and association, filters are available for querying.

Example

```
{
  artists (
    filter: {
      name: {
        contains: "Dead"
      }
    }
  ) {
    edges {
      node {
        id
        name
        performances (
          filter: {
            venue: {
              eq: "The Fillmore"
            }
          }
        ) {
          edges {
            node {
              venue
            }
          }
        }
      }
    }
  }
}
```

Each field has their own set of filters. Based on the field type, some or all of the following filters are available:

- eq - Equals.
- neq - Not equals.
- lt - Less than.
- lte - Less than or equal to.
- gt - Greater than.
- gte - Greater than or equal to.
- isnull - Is null. If value is true, the field must be null. If value is false, the field must not be null.
- between - Between. Identical to using gte &amp; lte on the same field. Give values as `low, high`.
- in - Exists within an array.
- notin - Does not exist within an array.
- startwith - A like query with a wildcard on the right side of the value.
- endswith - A like query with a wildcard on the left side of the value.
- contains - A like query.
- sort &amp; sortPriority - Sort the results by a field. Use sortPriority to sort by multiple fields.

You may [exclude any filter](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/attributes.html#entity) from any entity, association, or globally.

History
-------

[](#history)

The roots of this project go back to May 2018 with ; written for Zend Framework 2. It was migrated to the framework agnostic  but the name of that repository was incorrect because it did not specify ORM only. So this repository was created and the others were abandoned.

This was written for the [Live Concert Database](https://lcdb.org)

License
-------

[](#license)

See [LICENSE](https://github.com/api-skeletons/doctrine-orm-graphql/blob/master/LICENSE).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity75

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~12 days

Total

69

Last Release

78d ago

Major Versions

9.1.1 → 10.0.02024-03-21

9.1.x-dev → 10.0.22024-03-27

10.2.1 → 11.0.02024-04-15

10.2.3 → 12.0.02024-08-12

12.5.3 → 13.0.0a2026-01-22

PHP version history (4 changes)8.1.4PHP ^8.0

9.0.0PHP ^8.1

12.4.0PHP ^8.3

12.5.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/49dd7d9dba889ac674b0da447d9c1e69d1128dc3ccbaef98ba83d6ee519fc2d6?d=identicon)[tom\_anderson](/maintainers/tom_anderson)

---

Top Contributors

[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (1092 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/api-skeletons-doctrine-orm-graphql/health.svg)

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k431.1M7.5k](/packages/symfony-dependency-injection)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)

PHPackages © 2026

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