kikoseijo / lumen-relay-boilerplate

[OUTDATED] A lumen boilerplate with Auth, GraphQL & Relay Modern, a ready to go API for your React, VueJS applications
http://kikoseijo.com/laravel-lumen-graphql-server-for-react-relay-moder/
MIT License
9 stars 0 forks source link

any instruction how to get this started? #1

Closed codeitlikemiley closed 6 years ago

kikoseijo commented 6 years ago

Just need to adjust the environment and the key, here you have one:

APP_KEY=base64:4aVuW541oT+8kaM8VA/BkdfiuUloIHyihoGsCAY6Yt4=

kikoseijo commented 6 years ago

Check the package.json because im using folklore/graphql local repo right now, original repo comes with couple bugs must correct on the lumen relay version.

configure the repo for now using mine, I put a PR but the owner seems to be on vacation.

## package.json

"repositories": [
    {
      "type": "csv",
      "url": "https://github.com/kikoseijo/laravel-graphql"
    }
  ],

and the "folklore/graphql": "dev-feature/relay", branch.

codeitlikemiley commented 6 years ago

im actully implementing laravel-graphql with lumen also, and its good to see others how they code... thanks bro

kikoseijo commented 6 years ago

Im not sure ill stick to lumen, as the Node time its right here, right now. Backend without coding its posible using Graphcool, its 2.0 version "Prisma" seems to be a kick ass.

PHP its something I know from day 1 and I guess can help, but, not 100% sure its the perfect environment for this React - Relay thing.

Lets see how it goes! You are welcome, BTW im not active on this hacking for helps, but right now its not posible to find good examples, them too spread in different solutions and its hard to get started.

deltace commented 6 years ago

An exception occurred when i launch $php artisan In routes.php line 5: Call to undefined method Laravel\Lumen\Application::group() Thanks for your help.

kikoseijo commented 6 years ago

@deltace this is important, otherwise the lumen-graphql package it depends on its fixed.

"repositories": [
  {
    "type": "csv",
    "url": "https://github.com/kikoseijo/laravel-graphql"
  }
],

The original package has a bug on relay version, thats never been fixed.

kikoseijo commented 6 years ago

@deltace this is the fix:

https://github.com/Folkloreatelier/laravel-graphql/pull/268/files#diff-d1f58c1696a98eb1c587ff174ee2b9c4R12

On LumenServiceProvider

protected function getRouter()
      {
 -        return $this->app; // Replace this line with the following:
 +        return property_exists($this->app, 'router') ? $this->app->router : $this->app;
      }
dirtyredz commented 6 years ago

I dont see any /graphql route in your routes/web.php, how does lumen resolve to /graphql Im stuggling to make heads or tails of this, im new to lumen and graphql

kikoseijo commented 6 years ago

the problem its inside a library, you cant mix it all to start because you dont have a clue what problem you have.

follow readme to install, this problem you have its on the readme.

4levels commented 6 years ago

Hi @kikoseijo,

Thanks for your major example project as this is exactly what I've been trying to achieve as well. This "issue" has quite some interesting info actually, glad I found it! I think I got confused with the readme mentioning to adjust packages.json instead of composer.json, so I skipped composer update alltogether.
I just had a look at your PR and I don't understand why it didn't got merged, the few things I saw were definitely improvements! I'm sure David is very occupied.. I still have some questions, more specifically regarding the use of facades and why you add the schema in the provider and not in the config, is this the right place to ask?

Kind regards,

Erik

dirtyredz commented 6 years ago

im still learning graphql with lumen, but Im getting the hang of it as I move forward. Decided to use this stack (except im not using relay) for my current client. I added my schema's in the config, and im not even using provider at all. this repo has been instrumental in getting me in the right direction. After im finished with my current project I plan on releasing a boiler plate/TODO example of what i managed to stiched together using Lumen. JWT, React, and Graphql

kikoseijo commented 6 years ago

@4levels glad to be helping you, this new technology took me couple weeks to see the full picture, still learning, but deeper I go, the more I like it.

Regarding your question, the project was done during the period I mention, having all declarations in functions had more possibilities to test different approaches, including auth users.

@dirtyredz the relay its for react apps, GraphQL its more generic, but I guess will work with both and won't the other way around.

My next move goes to this 2.0 beta release of graphq relay lighthouse because the people at laravel-graphql are busy or more into the generic GraphQL branch, the relay branch its old and hasn't been updated for long, I bet now its complicated to merge something on an old branch just to repair the lumen route error.

Anyways, ill love to see your contributions if you do, its best way to learn from different approach.

Happy coding!

4levels commented 6 years ago

@codeitlikemiley To get things up and running, here are the steps I found out the hard way ;-). I'm assuming you're doing this in a terminal and have a webserver and mysql configured and running.

When you browse to your project, you should see a JSON response with some framework info. Adding schema.json to the url should present you a json formatted GraphQL schema. If you navigate to /graphiql you should have the very handy GraphiQL tool, ready for use. Test it with this loginMutation to see if you can get a token: query:

mutation loginUser {
  login(email: "foobarfoo@example.org", password: "foobarfoo") {
    token
  }
}

response should be something like

{
  "data": {
    "login": {
      "token": "diMDA5OGJiMWY2Nzk2MDJlODNjYjA2Y.." // truncated
    }
  }
}

Hope this gets you going (if not already ;-) @kikoseijo Maybe add all this to a wiki / the readme?

kikoseijo commented 6 years ago

Try this,

https://github.com/nuwave/lighthouse/issues/66

You going to love it!