PHPackages                             always-open/laravel-graphql-schema-generator - 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. always-open/laravel-graphql-schema-generator

ActiveLibrary[API Development](/categories/api)

always-open/laravel-graphql-schema-generator
============================================

Generate GraphQL schema from existing Laravel models/database

v1.0.2(2y ago)22.8k↓66.7%2MITPHPPHP ^8.1.0|^8.2.0

Since Aug 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/always-open/laravel-graphql-schema-generator)[ Packagist](https://packagist.org/packages/always-open/laravel-graphql-schema-generator)[ Docs](https://github.com/always-open/laravel-graphql-schema-generator)[ RSS](/packages/always-open-laravel-graphql-schema-generator/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (3)Dependencies (12)Versions (6)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

Generate GraphQL schema from existing Laravel models/database
=============================================================

[](#generate-graphql-schema-from-existing-laravel-modelsdatabase)

[![Latest Version on Packagist](https://camo.githubusercontent.com/143f22b8806f4072c7d135aab1b6461bcbcb9ca0345ee4f905ad4a07d1e65080/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c776179732d6f70656e2f6c61726176656c2d6772617068716c2d736368656d612d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/always-open/laravel-graphql-schema-generator)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7da384b415f5533d5991f9090c6b7cab2d946c026f74dbcf673e3211bab68595/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616c776179732d6f70656e2f6c61726176656c2d6772617068716c2d736368656d612d67656e657261746f722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/always-open/laravel-graphql-schema-generator/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/bc6050800105317b383f1865a99e47a4ccb93ae546419eda7e90d966031cdd4a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616c776179732d6f70656e2f6c61726176656c2d6772617068716c2d736368656d612d67656e657261746f722f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/always-open/laravel-graphql-schema-generator/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8680f797e58d064cb3726733da4c133b29a526781bf1a7246914083c85a7a445/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c776179732d6f70656e2f6c61726176656c2d6772617068716c2d736368656d612d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/always-open/laravel-graphql-schema-generator)

This package will generate a GraphQL schema from your existing Laravel models and database. It reads through the existing models, relationships, and database to generate a GraphQL schema and optionally queries for each model. You can also specify additional models such as vendor/packages models to be included.

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

[](#installation)

You can install the package via composer:

```
composer require always-open/laravel-graphql-schema-generator
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-graphql-schema-generator-config"
```

This is the contents of the published config file:

```
return [
    'custom_type_mappings' => [
         'timestamp' => 'DateTime',
         'datetime'  => 'DateTime',
         'date'      => 'Date',
    ],

    'custom_scalar_definitions' => [
        'scalar Date @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date")',
        'scalar DateTime @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")',
    ],

    'model_path' => app_path('Models'),

    'model_stub' => __DIR__ . '/../stubs/graphql_schema.stub',

    'schema_path' => app_path('../graphql'),
];
```

Usage
-----

[](#usage)

### Basic/default usage

[](#basicdefault-usage)

This command will output the GraphQL schema to the `schema_path` specified in the config file. It will only generate the schema file and will only parse the models in the `model_path` specified in the config file.

```
php artisan laravel-graphql-generator:create-schema
```

### Outputting queries

[](#outputting-queries)

To also add queries to the schema, pass the `--include-queries` flag. This will generate a GraphQL schema file and query files for each model in the `model_path` specified in the config file.

```
php artisan laravel-graphql-generator:create-schema --include-queries
```

### Adding additional models

[](#adding-additional-models)

If there are additional models that exist outside of the `model_path` that you want to include, you can pass the `--additional-models` flag. This is very useful if you have vendor/package models that you want to include.

```
php artisan laravel-graphql-generator:create-schema --additional-models="\\Spatie\\Tags\\Tag"
```

You can also pass in a comma separated list of models to include.

```
php artisan laravel-graphql-generator:create-schema --additional-models="\\Spatie\\Tags\\Tag","\\Spatie\\Activitylog\\Models\\Activity"
```

### Adding additional query properties

[](#adding-additional-query-properties)

The default queries will be created using primary keys and unique indices. If you want to add additional properties to search you can pass them in using the `--additional-query-properties` flag. It will be applied to every model that has the specified property.

This command could add queries using the properties `key` and `name`. Support for multiple fields isn't supported by the pass in as of this version.

```
php artisan laravel-graphql-generator:create-schema --additional-query-properties=key,name
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/qschmick/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [quentin.schmick](https://github.com/qschmick)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Total

4

Last Release

1036d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

1.x-devPHP ^8.1.0|^8.2.0

### Community

Maintainers

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

---

Top Contributors

[![qschmick](https://avatars.githubusercontent.com/u/5342767?v=4)](https://github.com/qschmick "qschmick (6 commits)")

---

Tags

laravelalways-openlaravel-graphql-schema-generator

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/always-open-laravel-graphql-schema-generator/health.svg)

```
[![Health](https://phpackages.com/badges/always-open-laravel-graphql-schema-generator/health.svg)](https://phpackages.com/packages/always-open-laravel-graphql-schema-generator)
```

###  Alternatives

[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[likeabas/filament-chatgpt-agent

Integrate with OpenAI ChatGPT

235.3k](/packages/likeabas-filament-chatgpt-agent)

PHPackages © 2026

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