api-generator
api-generator copied to clipboard
Add GraphQL for Laravel support if it is possible to match with OAS
https://github.com/Folkloreatelier/laravel-graphql
curl -X GET http://laravel.loc/v1/article/1 -d '{"query": "query { echo(message: "Hello World") }" }'
I was debating on using Laravel-JSON:API as my JSON:API server implementation until I found this amazing api-generator.
https://github.com/Folkloreatelier/laravel-graphql is no longer maintained
If we are talking about GraphQL and Laravel, I find Lighthouse-PHP as the best GraphQL Server implementation out there for Laravel.
with just a schema.graphql, Lighthouse-PHP will do it magic, just like a oas/openapi.yaml, api-generator will do it magic.
So here is my proposal, let this generator generate the schema.graphql and let Lighthouse do the rest for you.
Hi @Parables I've tried to implement graph-ql format into api-generator, but unfortunately there is no way of making bindings between objects based on graph-ql type model.
PS repo has been archived
@arthurkushman, I have this obsession with generators. I would like to attempt this.
I need two things from you:
- your promise to review, and merge my PRs.
- Help to get started. I have managed to create the
oas/openapi.jsonfile. generated the codes for theModules/V1directory but I can't use the generated codes. How do I add the generated routes to my RouteServiceProvider? The README.md is missing that info and I have tried everything possible
Hi @Parables,
You can't find the answer in README.md, because it is added automatically by Laravel-Modules.
There is no need of caring RouteServiceProvider in any way because it also has been registered for u in Modules/V{K}/Providers/V{K}ServiceProvider
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
All the other registration etc done by generator with special scripts in composer.json
Make sure that u have been added into composer.json:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
}
}
Try to execute command (it have to be executed before, just in case):
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
Run once again:
composer dump-autoload
In my case, the Modules/V{K}/Providers/ directory was empty.
I had already added "Modules\\": "Modules/" to my composer.json file
While dozing out, after countless efforts to understand why this is happening, I think I did run
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
composer dump-autoload
And that did the magic 🪄
Woke up this morning to see these new files:
Modules/V1/Providers/RouteServiceProvider.php
Modules/V1/Providers/V1ServiceProvider.php
About the GraphQL support, I am determined to find a solution to it so be checking your emails for my PRs very soon. Thanks so much for creating this amazing package. Its the best so far among the rest