PHPackages                             decowood/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. [API Development](/categories/api)
4. /
5. decowood/laravel-eloquent-to-graphql

ActiveLibrary[API Development](/categories/api)

decowood/laravel-eloquent-to-graphql
====================================

Automatically turn Eloquent models into GraphQL

v1.0.5(1y ago)064MITPHP

Since Jun 18Pushed 1y agoCompare

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

READMEChangelogDependencies (4)Versions (6)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

28

—

LowBetter than 54% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68% 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 ~111 days

Total

4

Last Release

579d ago

### Community

Maintainers

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

---

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 (5 commits)")[![sefirosweb](https://avatars.githubusercontent.com/u/20754836?v=4)](https://github.com/sefirosweb "sefirosweb (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[nikolag/laravel-square

Square API integration with Laravel built on nikolag/core

3827.3k](/packages/nikolag-laravel-square)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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