PHPackages                             yakovenko/laravel-lighthouse-graphql-multi-schema - 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. yakovenko/laravel-lighthouse-graphql-multi-schema

ActiveLibrary[API Development](/categories/api)

yakovenko/laravel-lighthouse-graphql-multi-schema
=================================================

A Laravel package that provides multi-schema support for Lighthouse GraphQL.

v2.3.0(1mo ago)16134.5k↑47.8%4MITPHPPHP ^8

Since Aug 11Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/as-yakovenko/laravel-lighthouse-graphql-multi-schema)[ Packagist](https://packagist.org/packages/yakovenko/laravel-lighthouse-graphql-multi-schema)[ RSS](/packages/yakovenko-laravel-lighthouse-graphql-multi-schema/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (9)Versions (19)Used By (0)

Lighthouse GraphQL Multi-Schema
===============================

[](#lighthouse-graphql-multi-schema)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f848fe26781d66fe041671fabb0af7c720c7ab2ffc273b70bbc82c610e8e94e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79616b6f76656e6b6f2f6c61726176656c2d6c69676874686f7573652d6772617068716c2d6d756c74692d736368656d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yakovenko/laravel-lighthouse-graphql-multi-schema)[![Total Downloads](https://camo.githubusercontent.com/0441076a95b931258d83f1f3a38baee4e0691cd10327a199a755c7cda05d9b8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79616b6f76656e6b6f2f6c61726176656c2d6c69676874686f7573652d6772617068716c2d6d756c74692d736368656d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yakovenko/laravel-lighthouse-graphql-multi-schema)[![PHP Version](https://camo.githubusercontent.com/7ec609ba8b6886dc9c0c0e69d920eaa3a8a66e7fe36881a8a7805b40b97a7af3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f79616b6f76656e6b6f2f6c61726176656c2d6c69676874686f7573652d6772617068716c2d6d756c74692d736368656d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yakovenko/laravel-lighthouse-graphql-multi-schema)[![License](https://camo.githubusercontent.com/e5d287fa4dfa55f87ca8a105b9fc7f5d64c287cf45af39457abaf10dc8e8c8aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f79616b6f76656e6b6f2f6c61726176656c2d6c69676874686f7573652d6772617068716c2d6d756c74692d736368656d612e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

Run multiple independent GraphQL schemas in a single Laravel application. Each schema gets its own route, middleware, cache, and developer tooling - with full support for Laravel Octane.

**Typical use cases:** admin vs public API, API versioning (v1/v2/v3), domain-driven or modular architectures.

---

🚀 Key Features
--------------

[](#-key-features)

- **Schema Isolation** - separate endpoints for Admin, Public, Mobile, or any other API surface
- **Independent Caching** - each schema has its own cache file, critical for production performance
- **Per-schema Middleware** - apply auth or any custom middleware independently per schema
- **Developer Tooling** - dedicated IDE helpers and validation commands for each schema
- **Octane Ready** - full support for Laravel Octane, Swoole, RoadRunner, and FrankenPHP

---

📦 Requirements
--------------

[](#-requirements)

DependencyVersionPHP`^8`Laravel`^9.0` | `^10.0` | `^11.0` | `^12.0` | `^13.0`Nuwave Lighthouse`^6.0`---

⚙️ Installation
---------------

[](#️-installation)

**1. Install via Composer**

```
composer require yakovenko/laravel-lighthouse-graphql-multi-schema
```

**2. Publish the configuration**

```
php artisan lighthouse-multi-schema:publish-config
```

This creates `config/lighthouse-multi-schema.php` where you define your schemas.

---

🔧 Configuration
---------------

[](#-configuration)

Each schema entry requires a route URI, a schema file path, and optionally cache settings and middleware.

```
// config/lighthouse-multi-schema.php

return [
    'multi_schemas' => [

        'admin' => [
            'route_uri'           => '/admin-graphql',
            'route_name'          => 'admin-graphql',
            'schema_path'         => base_path('graphql/admin.graphql'),
            'schema_cache_path'   => base_path('bootstrap/cache/admin-schema.php'),
            'schema_cache_enable' => env('LIGHTHOUSE_ADMIN_CACHE_ENABLE', false),
            'middleware' => [
                \Nuwave\Lighthouse\Http\Middleware\AcceptJson::class,
                \Nuwave\Lighthouse\Http\Middleware\AttemptAuthentication::class,
                'auth:sanctum',
            ],
        ],

        'public' => [
            'route_uri'           => '/graphql',
            'route_name'          => 'public-graphql',
            'schema_path'         => base_path('graphql/schema.graphql'),
            'schema_cache_path'   => base_path('bootstrap/cache/public-schema.php'),
            'schema_cache_enable' => env('LIGHTHOUSE_PUBLIC_CACHE_ENABLE', false),
            'middleware' => [
                \Nuwave\Lighthouse\Http\Middleware\AcceptJson::class,
                \Nuwave\Lighthouse\Http\Middleware\AttemptAuthentication::class,
            ],
        ],

    ],
];
```

> The `default` Lighthouse schema (configured via `lighthouse.schema_path`) continues to work as before - this package only extends it.

---

🛡️ CSRF Protection
------------------

[](#️-csrf-protection)

GraphQL routes use `POST` and should be excluded from CSRF verification.

**Laravel 11+ - `bootstrap/app.php`**

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        '/admin-graphql',
        '/graphql',
    ]);
})
```

**Laravel 9 / 10 - `app/Http/Middleware/VerifyCsrfToken.php`**

```
protected $except = [
    '/admin-graphql',
    '/graphql',
];
```

---

💻 Artisan Commands
------------------

[](#-artisan-commands)

### Quick Reference

[](#quick-reference)

CommandDescription`lighthouse:multi-cache [schema]`Compile and cache schemas`lighthouse:multi-clear [schema]`Clear cached schemas`lighthouse:multi-validate [schema]`Validate schemas`lighthouse:multi-ide-helper [schema]`Generate IDE helper filesAll commands operate on **all schemas** when called without an argument, or on a **specific schema** when a name is provided.

---

### Cache Management

[](#cache-management)

Warm the schema cache before deployment to avoid cold-start latency in production.

```
# Cache all schemas
php artisan lighthouse:multi-cache

# Cache a specific schema
php artisan lighthouse:multi-cache admin

# Clear all caches
php artisan lighthouse:multi-clear

# Clear a specific schema cache
php artisan lighthouse:multi-clear admin
```

### Schema Validation

[](#schema-validation)

Catch syntax, type, and directive errors before they reach production.

```
# Validate all schemas
php artisan lighthouse:multi-validate

# Validate a specific schema
php artisan lighthouse:multi-validate admin
```

### IDE Helper Generation

[](#ide-helper-generation)

Generate per-schema autocompletion files for your IDE.

```
# Generate for all schemas
php artisan lighthouse:multi-ide-helper

# Generate for a specific schema
php artisan lighthouse:multi-ide-helper admin
```

Generated files per schema:

- `schema-directives-{schema}.graphql`
- `programmatic-types-{schema}.graphql`
- `_lighthouse_ide_helper.php` (default schema only)

Add these to `.gitignore`:

```
schema-directives*.graphql
programmatic-types*.graphql
_lighthouse_ide_helper.php
```

### CI/CD Integration

[](#cicd-integration)

```
# .github/workflows/deploy.yml
- name: Validate GraphQL schemas
  run: php artisan lighthouse:multi-validate

- name: Warm schema cache
  run: php artisan lighthouse:multi-cache
```

---

⚡ Octane / Long-lived Workers
-----------------------------

[](#-octane--long-lived-workers)

The package is designed for use with **Laravel Octane** (Swoole, RoadRunner, FrankenPHP). Schema services are cached per-schema per-worker using `SchemaKeyedContainer`, so each schema is built exactly once per worker lifetime - eliminating redundant AST parsing on every request without state pollution between schemas.

---

🔄 Upgrading from v2.2
---------------------

[](#-upgrading-from-v22)

**Deprecated flag syntax** — the `--schema=` flag is replaced by a positional argument. It remains supported with a deprecation warning.

Old syntax (still works)New syntax`lighthouse:multi-validate-schema --schema=admin``lighthouse:multi-validate admin``lighthouse:multi-ide-helper --schema=admin``lighthouse:multi-ide-helper admin``lighthouse:clear-cache all``lighthouse:multi-clear`**New commands in v2.3**

CommandNotes`lighthouse:multi-cache`No equivalent in previous versions`lighthouse:multi-clear`Standalone command. No argument = clears **all** schemas> `lighthouse:clear-cache` is unchanged — without an argument it still clears only the default schema. Use `lighthouse:multi-clear` to clear all schemas at once.

---

📂 Directory Structure
---------------------

[](#-directory-structure)

There is no required structure - organize schema files however fits your project.

**Simple** (small projects or API versioning)

```
graphql/
├── schema.graphql      # default Lighthouse schema
├── v1.graphql          # #import models/*.graphql, #import v1/request/*.graphql
├── v2.graphql          # #import models/*.graphql, #import v2/request/*.graphql
├── models/             # shared Types, Enums, Inputs across all schemas
│   ├── User.graphql
│   ├── Order.graphql
│   └── Product.graphql
├── v1/
│   └── request/
│       ├── user_request.graphql
│       └── order_request.graphql
└── v2/
    └── request/
        ├── user_request.graphql
        └── order_request.graphql

```

**By API surface** (recommended - admin, app, public, etc.)

```
graphql/
├── models/                     # shared Types, Enums, Inputs for all schemas
│   ├── User.graphql
│   ├── Order.graphql
│   └── Product.graphql
│
├── admin/
│   ├── api_admin.graphql       # entry point: #import ../models/*.graphql
│   └── request/                #              #import admin/request/*.graphql
│       ├── user_admin.graphql
│       └── order_admin.graphql
│
├── app/
│   ├── api_app.graphql         # entry point: #import ../models/*.graphql
│   └── request/                #              #import app/request/*.graphql
│       ├── user_app.graphql
│       └── order_app.graphql
│
└── public/
    ├── api_public.graphql
    └── request/
        └── product_public.graphql

```

Each schema folder has a single entry point file that stitches together shared models and its own requests via `#import`. This keeps schemas fully isolated while sharing common type definitions.

---

📄 Changelog
-----------

[](#-changelog)

See [Releases](https://github.com/as-yakovenko/laravel-lighthouse-graphql-multi-schema/releases) for the full release history.

---

🤝 Contributing
--------------

[](#-contributing)

Bug reports and pull requests are welcome on [GitHub](https://github.com/as-yakovenko/laravel-lighthouse-graphql-multi-schema). Please open an issue before submitting large changes.

---

License
-------

[](#license)

MIT. See [LICENSE](LICENSE) for details.

---

**Author:** [Alexander Yakovenko](https://github.com/as-yakovenko) - Senior Software Engineer specializing in Laravel, GraphQL, and high-load systems.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~39 days

Recently: every ~14 days

Total

17

Last Release

57d ago

Major Versions

v1.5.1 → v2.0.02025-06-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5a8b946fa8eed03ce82193877a7e2565cee0f440704b7d6c095370f85b95b72?d=identicon)[as-yakovenko](/maintainers/as-yakovenko)

---

Top Contributors

[![as-yakovenko](https://avatars.githubusercontent.com/u/15609910?v=4)](https://github.com/as-yakovenko "as-yakovenko (21 commits)")[![kaioken](https://avatars.githubusercontent.com/u/118385?v=4)](https://github.com/kaioken "kaioken (4 commits)")[![cradigan](https://avatars.githubusercontent.com/u/4312288?v=4)](https://github.com/cradigan "cradigan (1 commits)")[![nielseulink](https://avatars.githubusercontent.com/u/10588067?v=4)](https://github.com/nielseulink "nielseulink (1 commits)")

---

Tags

graphqllaravellaravel-graphqllighthousemulti-schemalaravelgraphqllaravel-graphqllighthousemulti-schema

### Embed Badge

![Health badge](/badges/yakovenko-laravel-lighthouse-graphql-multi-schema/health.svg)

```
[![Health](https://phpackages.com/badges/yakovenko-laravel-lighthouse-graphql-multi-schema/health.svg)](https://phpackages.com/packages/yakovenko-laravel-lighthouse-graphql-multi-schema)
```

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k11.8M117](/packages/nuwave-lighthouse)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M986](/packages/statamic-cms)[joselfonseca/lighthouse-graphql-passport-auth

Add GraphQL types and mutations for login and recover password functionalities

233804.5k1](/packages/joselfonseca-lighthouse-graphql-passport-auth)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[stayallive/lighthouse-graphql-hive

Performance monitoring Lighthouse with GraphQL Hive.

2234.0k](/packages/stayallive-lighthouse-graphql-hive)

PHPackages © 2026

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