This is an experimental proof of concept to try to automagically generate GraphQL types & queries for Lighthouse PHP from Laravel Eloquent models.
To install this package, you'll have to update the composer.json
to pull from the github repository.
// composer.json
"require": {
"dpwilhelmsen/lighthouse-model-migrator": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/dpwilhelmsen/lighthouse-model-migrator"
}
]
This package will attempt to generate graphql types and queries from existing Eloquent models. It will append the
results to schema.graphql
file created by Lighthouse PHP
To run, use the following artisan command.
$ php artisan lighthouse:migrate
This package uses the models namespaces defined in config/lighthouse.php
. It finds all Eloquent models, figures out
the table names and derives the attributes from the table schema. Then it analyzes the php code and looks for methods
that implement Laravel relationship methods. Then, it generates basic types and queries for the models.
This package is experimental and hasn't been thoroughly tested. There are likely many use cases where this will fail.
- This relies on a database connection. Not all column types are supported or properly mapped to graphQL types
- Doesn't currently support polymorphic relations
- Traits & inheritance has not been tested and likely won't work
Please see the changelog for more information on what has changed recently.
Please see contributing.md for details and a todolist.
license. Please see the license file for more information.