Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Lighthouse Laravel Package

nuwave/lighthouse

Lighthouse is a Laravel-first GraphQL server framework. Define schemas, resolve data with Eloquent, and handle common GraphQL tasks with built-in directives and extensibility. Docs at lighthouse-php.com. Note: repo planned to move to spawnia/lighthouse.

View on GitHub
Deep Wiki
Context7

A framework for serving GraphQL from Laravel

Frequently asked questions about Lighthouse
How do I install Lighthouse in a Laravel project?
Run `composer require nuwave/lighthouse` in your project directory. Then publish the configuration with `php artisan lighthouse:install` and configure your GraphQL endpoint in `routes/web.php` or `routes/api.php`. The package integrates seamlessly with Laravel’s service container and middleware.
Does Lighthouse work with Laravel 10+?
Yes, Lighthouse is fully compatible with Laravel 10 and later. The package follows Laravel’s release cycle and maintains backward compatibility for minor updates. Check the [official documentation](https://lighthouse-php.com) for version-specific requirements.
Can I use Lighthouse alongside existing REST APIs?
Absolutely. Lighthouse is designed to coexist with REST endpoints. You can incrementally adopt GraphQL by exposing specific models or domains via GraphQL while keeping REST for other use cases. Laravel’s middleware makes it easy to route requests appropriately.
How does Lighthouse handle authentication?
Lighthouse integrates with Laravel’s authentication systems (e.g., Sanctum, Passport) via middleware. You can protect GraphQL endpoints using standard Laravel auth guards, and field-level permissions can be enforced using Laravel policies or custom directives.
What are Lighthouse directives, and how do they reduce boilerplate?
Directives like `@all`, `@morphOne`, and `@paginated` map Laravel models and relationships to GraphQL types automatically. For example, `@all` exposes all Eloquent model fields, while `@paginated` handles pagination without writing custom resolvers. This aligns with Laravel conventions and minimizes repetitive code.
How do I test GraphQL queries and mutations in Laravel?
Use Laravel’s testing tools like Pest or PHPUnit to test GraphQL endpoints. Lighthouse provides helpers like `GraphQL::assertNoErrors()` and `GraphQL::assertResponseMatches()`, and you can mock resolvers or test schema validation. For frontend integration, tools like GraphQL Playground or Apollo Client work seamlessly.
Is Lighthouse suitable for high-traffic APIs?
Lighthouse is optimized for performance with features like `@batch` (for DataLoader-like behavior) and integration with Laravel’s query caching. For high-traffic APIs, monitor query complexity, use Laravel’s caching (e.g., `Schema::cache()`), and consider rate-limiting or query depth limits via middleware.
How do I upgrade from Lighthouse v4 to v5?
Major upgrades require reviewing the [UPGRADE.md guide](https://github.com/nuwave/lighthouse/blob/master/UPGRADE.md) for breaking changes. Minor updates are backward-compatible, but always test thoroughly. The changelog and documentation provide detailed migration steps, including schema adjustments if needed.
Can I customize the GraphQL schema beyond built-in directives?
Yes, Lighthouse supports custom directives, resolvers, and schema extensions. For advanced use cases, you can define custom directives using PHP classes or extend the schema with additional types. The framework provides hooks and events for deep customization while maintaining Laravel’s conventions.
What alternatives to Lighthouse exist for Laravel GraphQL?
Alternatives include `graphql-php/graphql` (a pure PHP GraphQL server) or `rebing/graphql-laravel` (a more opinionated framework). Lighthouse stands out for its Laravel-native integration, schema-first approach, and minimal boilerplate. Choose based on your need for convention-over-configuration or flexibility.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope