Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Lighthouse | 3,175 | 46 | 49 | 12 days ago | 281 | September 19, 2022 | 121 | mit | PHP | |
A framework for serving GraphQL from Laravel | ||||||||||
Lighthouse Graphql Passport Auth | 220 | 3 | 22 days ago | 45 | June 17, 2021 | mit | PHP | |||
Add GraphQL mutations to get tokens from passport for https://lighthouse-php.com/ | ||||||||||
Laravel Vue Boilerplate | 37 | a year ago | 18 | mit | PHP | |||||
Laravel Vue SPA Sanctum | ||||||||||
Lighthouse Utils | 26 | 1 | 1 | 4 years ago | 6 | September 19, 2018 | 4 | mit | PHP | |
An add-on to Lighthouse to auto-generate CRUD actions from types https://github.com/nuwave/lighthouse | ||||||||||
Lumen Lighthouse Graphql | 25 | 5 years ago | 4 | mit | PHP | |||||
Lumen example use of a GraphQL PHP server using Lighthouse package | ||||||||||
Lighthouse Graphql Hive | 21 | 2 months ago | mit | PHP | ||||||
Performance monitoring Lighthouse with GraphQL Hive. | ||||||||||
Lighthouse Dashboard | 18 | 4 months ago | 1 | PHP | ||||||
Dashboard for Laravel Lighthouse GraphQL. | ||||||||||
Apollo Lighthouse Subscription Link | 15 | a year ago | 1 | mit | TypeScript | |||||
An apollo link to subscribe to Lighthouse graphql subscriptions using Laravel Echo presence channels. | ||||||||||
Utils | 14 | 22 days ago | mit | PHP | ||||||
Utilities for using GraphQL with Laravel | ||||||||||
Api Core | 14 | 6 months ago | 28 | mit | PHP | |||||
This project is the root component of the "Laravel VPN Admin" project, based on the Laravel framework, interaction with other modules of the system occurs via the GraphQL protocol. |
This package can generate queries for the Lighthouse GraphQL library. This is not a standalone package, so Lighthouse is listed as a dependency.
To generate queries, all you need to do is define a couple of GraphQL Types and run the generate command. Scroll down to 'Schema' to learn more.
We also include a couple of Directives and Scalar types. More about that later on.
Install via composer
composer require deinternetjongens/lighthouse-utils
Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.
Add service provider to config/app.php
in providers
section
deinternetjongens\LighthouseUtils\ServiceProvider::class,
Register package facade in config/app.php
in aliases
section
deinternetjongens\LighthouseUtils\Facades\LighthouseUtils::class,
php artisan vendor:publish --provider="DeInternetJongens\LighthouseUtils\ServiceProvider" --tag="config"
Before committing, please run
./automate.sh
This script will run all code style checks and phpunit tests. Fix all errors before opening a pull request.
This package uses Laravel Auto Discovery to register itself with your application.
It exposes a GraphQL interface interface on the /graphql
route.
To get started, run the following command in your Laravel application:
php artisan vendor:publish --provider="Nuwave\Lighthouse\Providers\LighthouseServiceProvider"
php artisan vendor:publish --provider="DeInternetJongens\LighthouseUtils\ServiceProvider" --tag="migrations"
php artisan migrate
A config file will be generated: config/lighthouse.php
. You can change these values if you want.
Define your GraphQL schema by adding Types, Queries and Mutations in app/GraphQL/Types
, app/GraphQL/Queries
and app/GraphQL/Mutations
directories.
If you want to change these paths, publish the config file for this package and change the paths there.
Currently this package only supports custom Types, Queries and Mutations are ignored. You can define your custom types and run the command below to auto-generate queries and mutations for those types. In the future it will be possible to add custom queries and mutations to the above directories. These will then also be used in the generated schema.
For more information on schemas and basic Lighthouse usage, check the Lighthouse docs
To generate your schema.graphql
file, run the following command:
php artisan lighthouse-utils:generate-schema
The schema will be generated to the path as defined in the Lighthouse config, lighthouse.schema.register
It might happen that you need a custom query or mutation beside the generated schema. In this package you have the ability to add custom queries and mutations by creating .graphql
files in the default directories
app/GraphQL/Queries
and app/GraphQL/Mutations
(These directories are adjustable by editing the config/lighthouse.php
file)
Take for example a custom query to retrieve an instance of a model:
type Query{
customQuery(id: ID! @eq): Model! @find(model: "Model")
}
This query will be parsed after running the schema generation command and will be added to the Query section of the schema.graphql
Currently two scalar types are included. More about scalar type usage can be found here.
A date string with format Y-m-d. Example: "2018-01-01"
scalar Date @scalar(class: "DeInternetJongens\\LighthouseUtils\\Schema\\Scalars\\Date")
A date string with format Y-m-d H:i:s+P. Example: "2018-01-01 13:00:00+00:00"
scalar DateTimeTz @scalar(class: "DeInternetJongens\\LighthouseUtils\\Schema\\Scalars\\DateTimeTz")
A postal code as valid for The Netherlands, format 1111aa. Example: "7311SZ"
To run more advanced queries, a couple of directives are included. These are automatically registered with Lighthouse, so you can use them at your own discretion.
Currently these directives are included:
This package stores the generated schema in the database, so the schema is available outside the schema.graphql
and can be used to sync permission.
Publish the migration and migrate the database.
php artisan vendor:publish --provider="DeInternetJongens\LighthouseUtils\ServiceProvider" --tag="migrations"
php artisan migrate
To protect your queries and migrations from unauthorized users, you can enable the Authorization feature. To enable authorization, make sure you have published the config for this package and add the following line to your .env file:
LIGHTHOUSE_UTILS_AUTHORIZATION=true
When a schema is generated the event DeInternetJongens\LighthouseUtils\Events\GraphQLSchemaGenerated
will be fired.
In your application you can listen for this event to sync the generated permissions with your application.
The event has a schema
variable with the generated schema.
The generated queries and their corresponding permissions will also be persisted to your database to the graphql_schema
table.
An Eloquent model for this table is included with this package.