Refer to this document: https://lighthouse-php.com/
Setup as the following according to the lighthouse documentation
Option 1
composer create-project laravel/laravel graphql-api
cd graphql-api
Option 2
laravel new laravel-graph
Install Lighthouse via Composer:
composer require nuwave/lighthouse
php artisan vendor:publish --tag=lighthouse-schema
php artisan vendor:publish --tag=lighthouse-config
After that, you’ll have:
- config/lighthouse.php
- graphql/schema.graphql
By default, Lighthouse automatically registers /graphql as the endpoint. You can check or change it in config/lighthouse.php:
'route' => [
'uri' => '/graphql',
],
php artisan about
- The query goes to /graphql
- Lighthouse parses your query
- Lighthouse sees two fields: ads and posts
- It checks schema: ads → AdsQuery@all and posts → PostsQuery@all
- It calls both resolvers: - App\GraphQL\Queries\AdsQuery::all() - App\GraphQL\Queries\PostsQuery::all()
- Each resolver fetches data (Eloquent, controller, repository, etc.)
- Lighthouse merges both results into one JSON response
Doument Link: https://docs.google.com/document/d/1eks0pFBePMDVdYc3KUz96izT_8e4CVs3l_Q-EIDuL1M/edit?usp=sharing