Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraphQL for Laravel support if it is possible to match with OAS #113

Open
arthurkushman opened this issue Aug 10, 2018 · 6 comments
Open
Assignees

Comments

@arthurkushman
Copy link
Contributor

https://github.com/Folkloreatelier/laravel-graphql

@arthurkushman
Copy link
Contributor Author

curl -X GET http://laravel.loc/v1/article/1 -d '{"query": "query { echo(message: "Hello World") }" }'

@arthurkushman arthurkushman changed the title Add GraphQL for Laravel support if it is possible to match with RAML Add GraphQL for Laravel support if it is possible to match with OAS Dec 4, 2018
@Parables
Copy link

Parables commented May 5, 2022

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.

@arthurkushman
Copy link
Contributor Author

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

@Parables
Copy link

Parables commented May 10, 2022

@arthurkushman, I have this obsession with generators. I would like to attempt this.

I need two things from you:

  1. your promise to review, and merge my PRs.
  2. Help to get started. I have managed to create the oas/openapi.json file. generated the codes for the Modules/V1 directory 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

@arthurkushman
Copy link
Contributor Author

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

@Parables
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants