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

ActiveLibrary

ggarri/graphql-api
==================

Graphql readonly api for your database.

271PHP

Since Dec 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ggarri/graphql-api)[ Packagist](https://packagist.org/packages/ggarri/graphql-api)[ RSS](/packages/ggarri-graphql-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony-doctrine-graphql-api
============================

[](#symfony-doctrine-graphql-api)

Description
===========

[](#description)

This library provides an single and simple entry point to read all your db using Graphql syntax. To achieve that we will need to export our db model into php entities, which will be represented by doctrine annotations, taking advantage of this doctrine annotations this library will generate the graphql schema to accessed using Graphql query syntax.

Setup
-----

[](#setup)

### Include repository in `composer.json`

[](#include-repository-in-composerjson)

```
"repositories": [
....
    {
        "type": "git",
        "url": "https://github.com/ggarri/symfony-doctrine-graphql"
    },
....

"require": {
    "ggarri/symfony-graphql-api": "^0.6-dev"
}
....

```

### Installing dependencies

[](#installing-dependencies)

```
composer install/update

```

### Loading bundle

[](#loading-bundle)

```
# AppKernel.php

use GraphqlApiBundle\GraphqlApiBundle;
...
public function registerBundles()
    {
        $bundles = array(
            ....
            new GraphqlApiBundle(),
....

```

### Routing

[](#routing)

Including graphql entry point in 'app/config/routing.yml'

```
# Adding graphql routes (127.0.0.1:8000/graphql/api?query={graphql_query}
graphql_routing:
    resource: .
    type: extra

```

#### Setup db connection

[](#setup-db-connection)

If you didn't do it yet you will need to set up doctrine database connection This library will only require an valid doctrine connection as the one above:

```
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8

    orm:
        default_entity_manager: default
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

```

Importing your DB Model
-----------------------

[](#importing-your-db-model)

Once everything is setup you can start converting your db into php entity classes. For that, and as it was mentioned above, your db model will be imported from connection defined under Doctrine.dbal.default.

The above command will do all the work for you.

```
php app/console graphql-api:graphql:generate-schema --namespace "AppBundle\\Entity" annotation ./src/AppBundle/Entity --from-database --force

```

(*) we had use `"AppBundle\\Entity"` as namespace for model to be imported, and `./src/AppBundle/Entity`as location folder to place each of the entity files. (*) Possible problems appear above

Usage
-----

[](#usage)

That is all, it is time to start using start reading your db with your new custimized graphql api.

(We used `127.0.0.1:8000` as server, you might have it on different name)

#### Curl sample

[](#curl-sample)

```
curl -XPOST -H 'Content-Type:application/graphql' -d 'query={  boardtype(id: 2) {  id, name, vatClass { amount }  } }' http://127.0.0.1:8000/graphql/api

```

#### Browser sample

[](#browser-sample)

```
http://127.0.0.1:8000/graphql/api?query={boardtype(id:2){id,name,vatClass{amount}}}

```

If you want to know more about Graphql syntax, go to:

Troubleshooting
===============

[](#troubleshooting)

Using POSTGRES 9.5
------------------

[](#using-postgres-95)

In case your db is Postgres and includes `Blob` or `jsonb` types you might need to patch the postgres driver due to `Blob` or `jsonb` wasn't included in latest version of driver.

#### Patching Postgres driver to include new types

[](#patching-postgres-driver-to-include-new-types)

```
cp -r vendor/ggarri/graphql-api/src/Doctrine src/
patch vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php vendor/ggarri/graphql-api/src/Doctrine/patch/AbstractPostgreSQLDriver.patch

```

(\*) Please, check if patch was applied correctly, because some types it does't. Around line 110 it has to have the following lines:

```
switch(true) {
    case version_compare($version, '9.4', '>='):
        return new PostgreSQL95Platform();  // THIS IS THE IMPORTANT ONE
    case version_compare($version, '9.2', '>='):
        return new PostgreSQL92Platform();
    case version_compare($version, '9.1', '>='):
        return new PostgreSQL91Platform();
    default:
        return new PostgreSqlPlatform();
}

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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/f4bddabc3942f59b834bd6108bd682af5926080c4e5bf3c820cac80200f83432?d=identicon)[ggarri](/maintainers/ggarri)

---

Top Contributors

[![ggarri](https://avatars.githubusercontent.com/u/2728080?v=4)](https://github.com/ggarri "ggarri (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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