PHPackages                             brausepulver/laravel-eloquent-to-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. brausepulver/laravel-eloquent-to-graphql

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

brausepulver/laravel-eloquent-to-graphql
========================================

Automatically turn Eloquent models into GraphQL

v1.0.3(2y ago)33443[1 PRs](https://github.com/brausepulver/laravel-eloquent-to-graphql/pulls)MITPHP

Since Mar 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/brausepulver/laravel-eloquent-to-graphql)[ Packagist](https://packagist.org/packages/brausepulver/laravel-eloquent-to-graphql)[ RSS](/packages/brausepulver-laravel-eloquent-to-graphql/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

laravel-eloquent-to-graphql
===========================

[](#laravel-eloquent-to-graphql)

[![Tests](https://github.com/brausepulver/laravel-eloquent-to-graphql/actions/workflows/tests.yml/badge.svg)](https://github.com/brausepulver/laravel-eloquent-to-graphql/actions)[![Latest Stable Version](https://camo.githubusercontent.com/94e3005da5347b486a13ed9a6cb257153616cd35a0a4c36b67f74a916a2e51a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62726175736570756c7665722f6c61726176656c2d656c6f7175656e742d746f2d6772617068716c)](https://packagist.org/packages/brausepulver/laravel-eloquent-to-graphql)[![License](https://camo.githubusercontent.com/4dc7c71fd672e8897e1c7d538985e4cd0e189e73dc08d899e3ee13363447588f/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d6c6963656e7365266d6573736167653d4d495426636f6c6f723d396366)](https://packagist.org/packages/brausepulver/laravel-eloquent-to-graphql)

This package generates a static GraphQL schema from your Eloquent models.

It is suggested to be used with [lighthouse](https://lighthouse-php.com/).

Setup
-----

[](#setup)

1. Install the package:

```
composer require --dev brausepulver/laravel-eloquent-to-graphql

```

2. Type-hint your models' relationships:

```
use Illuminate\Database\Eloquent\Relations\HasMany;

class User extends Model
{
    public function cuteCats(): HasMany
    {
        ...
    }
}
```

3. *(Optional)* Publish the configuration file:

```
php artisan vendor:publish --tag="eloquent_to_graphql.config"

```

Usage
-----

[](#usage)

```
php artisan e2gql

```

This will generate a schema for all your models in a single file at `graphql/generated.graphql`.

There are several options for customizing the way the schema is generated. Please have a look at them with
`php artisan e2gql --help`.

Configuration
-------------

[](#configuration)

### Automatic Updates

[](#automatic-updates)

To automatically update the schema every time one of your Eloquent models changes, you can register the command in your IDE of choice with the `--force` option, which disables all prompts.

If you are using VSCode, this can be achieved using the [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) extension. After installing the extension, you can add the following to `.vscode/settings.json`:

```
    "emeraldwalk.runonsave": {
        "commands": [
            {
                "match": "app/Models/.*\\.php",
                "isAsync": true,
                "cmd": "php artisan e2gql --force"
            }
        ]
    }
```

With standard project structure, this will update your schema every time an Eloquent model changes.

### Custom Type Mappings

[](#custom-type-mappings)

If your tables have columns with types unknown to DBAL, the command will let you know. In this case, you have two options:

1. Let the command know which type that is known by DBAL you would like to map the unkown type to. You can do this by adding both to `custom_type_mappings` in `config/eloquent_to_graphql.php`:

```
    'custom_type_mappings' => [
        'from-type' => 'to-type'
    ]
```

2. Ignore the columns entirely using the `--exclude-columns` option. You can then later add them by hand.

TODO
----

[](#todo)

- Option to automatically update the schema after migrations are run
- Way to keep changes made by the user when regenerating a schema
- More customizable type resolution

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~232 days

Total

4

Last Release

806d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/08feff8e8e7a4d399a146757f5ca9f573f8acce1d83b8846eb4d35f9b71ebcae?d=identicon)[brausepulver](/maintainers/brausepulver)

---

Top Contributors

[![brausepulver](https://avatars.githubusercontent.com/u/34420739?v=4)](https://github.com/brausepulver "brausepulver (17 commits)")[![itdecowood](https://avatars.githubusercontent.com/u/23474321?v=4)](https://github.com/itdecowood "itdecowood (2 commits)")

---

Tags

artisan-commandeloquenteloquent-modelseloquent-relationshipsilluminatelaravellaravel-migrations

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brausepulver-laravel-eloquent-to-graphql/health.svg)

```
[![Health](https://phpackages.com/badges/brausepulver-laravel-eloquent-to-graphql/health.svg)](https://phpackages.com/packages/brausepulver-laravel-eloquent-to-graphql)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)

PHPackages © 2026

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