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

Abandoned → [api-skeletons/doctrine-orm-graphql](/?search=api-skeletons%2Fdoctrine-orm-graphql)Library

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

GraphQL Type Driver for Doctrine ORM

8.1.3(2y ago)112.3k2[1 issues](https://github.com/API-Skeletons/doctrine-graphql/issues)[1 PRs](https://github.com/API-Skeletons/doctrine-graphql/pulls)MITPHPPHP ^8.0

Since Jul 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/API-Skeletons/doctrine-graphql)[ Packagist](https://packagist.org/packages/api-skeletons/doctrine-graphql)[ RSS](/packages/api-skeletons-doctrine-graphql/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (12)Versions (59)Used By (0)

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

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

This project has been retired in favor of [API-Skeletons/doctrine-orm-graphql](https://github.com/API-Skeletons/doctrine-orm-graphql)
=====================================================================================================================================

[](#this-project-has-been-retired-in-favor-of-api-skeletonsdoctrine-orm-graphql)

See the [upgrade guide](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/upgrade.html) if you're a user of the 8.x branch.

All the original documentation can be found below.

[![Build Status](https://github.com/API-Skeletons/doctrine-graphql/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/API-Skeletons/doctrine-graphql/actions/workflows/continuous-integration.yml?query=branch%3Amain)[![Code Coverage](https://camo.githubusercontent.com/98d05690ce5c2fbd1faa22765767192a65b8a48464da5d0f3c717136a5b70870/68747470733a2f2f636f6465636f762e696f2f67682f4150492d536b656c65746f6e732f646f637472696e652d6772617068716c2f6272616e63682f6d61696e2f6772617068732f62616467652e737667)](https://codecov.io/gh/API-Skeletons/doctrine-graphql/branch/main)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/29d12cd048e038f5d72e78bee48a4ef52e3b7f0a22536f2aa20f7d3e132803e0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4150492d536b656c65746f6e732f646f637472696e652d6772617068716c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/API-Skeletons/doctrine-graphql/?branch=main)[![PHP Version](https://camo.githubusercontent.com/d43f3018edfd35e43d9669f893ce52781d51f11ac9240420a3dce982b6ae8af1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532622d626c7565)](https://img.shields.io/badge/PHP-8.0%2b-blue)[![Total Downloads](https://camo.githubusercontent.com/fbaaa60772c4ce47401dc1686220150b1a88fa312802316737c7855918b83917/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f646f637472696e652d6772617068716c2f646f776e6c6f616473)](//packagist.org/packages/api-skeletons/doctrine-graphql)[![License](https://camo.githubusercontent.com/d1c76f12aba780016685dc520ba743b827735e5c50dccc8846596266ad86646b/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f646f637472696e652d6772617068716c2f6c6963656e7365)](//packagist.org/packages/api-skeletons/doctrine-graphql)

This library provides a framework agnostic GraphQL driver for Doctrine ORM for use with [webonyx/graphql-php](https://github.com/webonyx/graphql-php). Configuration is available from zero to verbose. Multiple configurations for multiple drivers are supported.

[Detailed documentation](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/) is available.

For an example application post to `https://graphql.lcdb.org/`

Library Highlights
------------------

[](#library-highlights)

- Uses [PHP 8 Attributes](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/attributes.html)
- [Multiple independent configurations](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/config.html)
- Support for all default [Doctrine Types](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html) &amp; custom types
- Support for the [GraphQL Complete Connection Model](https://graphql.org/learn/pagination/#complete-connection-model)
- Supports [filtering of sub-collections](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/queries.html)
- [Events](https://github.com/API-Skeletons/doctrine-graphql#events) for modifying queries and entity types
- Uses the [Doctrine Laminas Hydrator](https://www.doctrine-project.org/projects/doctrine-laminas-hydrator/en/3.1/index.html) for extraction
- Conforms to the [Doctrine Coding Standard](https://www.doctrine-project.org/projects/doctrine-coding-standard/en/9.0/index.html)

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

[](#installation)

Run the following to install this library using [Composer](https://getcomposer.org/):

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

Entity Relationship Diagram
---------------------------

[](#entity-relationship-diagram)

[This Entity Relationship Diagram](https://raw.githubusercontent.com/API-Skeletons/doctrine-graphql/master/test/doctrine-graphql.skipper), created with [Skipper](https://skipper18.com), is used for the query examples below and testing this library.

[![Entity Relationship Diagram](https://raw.githubusercontent.com/API-Skeletons/doctrine-graphql/master/test/doctrine-graphql.png)](https://raw.githubusercontent.com/API-Skeletons/doctrine-graphql/master/test/doctrine-graphql.png)

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

[](#quick-start)

Add attributes to your Doctrine entities

```
use ApiSkeletons\Doctrine\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\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' => [
                'type' => $driver->connection($driver->type(Artist::class)),
                'args' => [
                    'filter' => $driver->filter(Artist::class),
                    'pagination' => $driver->pagination(),
                ],
                'resolve' => $driver->resolve(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();
```

Filtering
---------

[](#filtering)

For every attributed field and every attributed association, filters are available in your GraphQL query.

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. Most fields have the following:

- 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 a list of comma-delimited values.
- notin - Does not exist within a list of comma-delimited values.
- 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.

Events
------

[](#events)

### Filter Query Builder

[](#filter-query-builder)

You may modify the query builder used to resolve any connection by subscribing to events. Each connection may have a unique event name. `Entity::class . '.filterQueryBuilder'` is recommended. Pass as the second parameter to `$driver->resolve()`.

```
use ApiSkeletons\Doctrine\GraphQL\Event\FilterQueryBuilder;
use App\ORM\Entity\Artist;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Schema;
use League\Event\EventDispatcher;

$schema = new Schema([
  'query' => new ObjectType([
      'name' => 'query',
      'fields' => [
          'artists' => [
              'type' => $driver->connection($driver->type(Artist::class)),
              'args' => [
                  'filter' => $driver->filter(Artist::class),
                  'pagination' => $driver->pagination(),
              ],
              'resolve' => $driver->resolve(Artist::class, Artist::class . '.filterQueryBuilder'),
          ],
      ],
  ]),
]);

$driver->get(EventDispatcher::class)->subscribeTo(Artist::class . '.filterQueryBuilder',
    function(FilterQueryBuilder $event) {
        $event->getQueryBuilder()
            ->innerJoin('entity.user', 'user')
            ->andWhere($event->getQueryBuilder()->expr()->eq('user.id', ':userId'))
            ->setParameter('userId', currentUser()->getId())
            ;
    }
);
```

### Filter Association Criteria

[](#filter-association-criteria)

You may modify the criteria object used to filter associations. For instance, if you use soft deletes then you would want to filter out deleted rows from an association.

```
use ApiSkeletons\Doctrine\GraphQL\Attribute as GraphQL;
use ApiSkeletons\Doctrine\GraphQL\Event\FilterCriteria;
use App\ORM\Entity\Artist;
use League\Event\EventDispatcher;

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

    #[GraphQL\Field]
    public $name;

    #[GraphQL\Association(filterCriteriaEventName: self::class . '.performances.filterCriteria')]
    public $performances;
}

// Add a listener to your driver
$driver->get(EventDispatcher::class)->subscribeTo(
    Artist::class . '.performances.filterCriteria',
    function (FilterCriteria $event): void {
        $event->getCriteria()->andWhere(
            $event->getCriteria()->expr()->eq('isDeleted', false)
        );
    },
);
```

### Entity ObjectType Definition

[](#entity-objecttype-definition)

You may modify the array used to define an entity type before it is created. This can be used for generated data and the like. You must attach to events before defining your GraphQL schema. See the [detailed documentation](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/events.html#modify-an-entity-definition) for details.

```
use ApiSkeletons\Doctrine\GraphQL\Driver;
use ApiSkeletons\Doctrine\GraphQL\Event\EntityDefinition;
use App\ORM\Entity\Artist;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use League\Event\EventDispatcher;

$driver = new Driver($entityManager);

$driver->get(EventDispatcher::class)->subscribeTo(
    Artist::class . '.definition',
    static function (EntityDefinition $event): void {
        $definition = $event->getDefinition();

        // In order to modify the fields you must resovle the closure
        $fields = $definition['fields']();

        // Add a custom field to show the name without a prefix of 'The'
        $fields['nameUnprefix'] = [
            'type' => Type::string(),
            'description' => 'A computed dynamically added field',
            'resolve' => static function ($objectValue, array $args, $context, ResolveInfo $info): mixed {
                return trim(str_replace('The', '', $objectValue->getName()));
            },
        ];

        $definition['fields'] = $fields;
    }
);
```

Further Reading
---------------

[](#further-reading)

[Detailed documentation](https://apiskeletons-doctrine-graphql.readthedocs.io/en/latest/)is available.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

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 ~21 days

Recently: every ~37 days

Total

57

Last Release

938d ago

Major Versions

3.0.1 → 4.0.02020-07-12

4.0.1 → 5.0.02022-03-03

5.1.1 → 6.0.02022-07-23

6.2.5 → 7.0.02023-01-23

7.2.2 → 8.0.02023-05-18

### 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 (698 commits)")

---

Tags

doctrinegraphql

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

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

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

1.3k1.3M152](/packages/sulu-sulu)[thecodingmachine/graphqlite

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

5723.1M30](/packages/thecodingmachine-graphqlite)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M292](/packages/doctrine-doctrine-orm-module)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[api-skeletons/doctrine-orm-graphql

GraphQL Type Driver for Doctrine ORM

124.9k1](/packages/api-skeletons-doctrine-orm-graphql)

PHPackages © 2026

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