Closed codeitlikemiley closed 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.
im actully implementing laravel-graphql with lumen also, and its good to see others how they code... thanks bro
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.
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.
@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.
@deltace this is the fix:
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;
}
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
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.
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
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
@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!
@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.
git clone https://github.com/kikoseijo/lumen-relay-boilerplate.git
cd lumen-relay-boilerplate
composer.json
"repositories" section to the following (see above)
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kikoseijo/laravel-graphql"
}
],
composer install
.env.example
to .env
APP_KEY
with any key, eg. the one from @kikoseijo base64:4aVuW541oT+8kaM8VA/BkdfiuUloIHyihoGsCAY6Yt4=
more info in this SO question
TL;DR; php -r "require 'vendor/autoload.php'; echo base64_encode(str_random(32)).PHP_EOL;"
DB_*
variables are correct in .envconfig/jwt.php
php artisan migrate
php artisan db:seed
php artisan passport:install
introspectionQuery.txt
to introspection.txt
in the resources directory
mv resources/graphql/introspectionQuery.txt resources/graphql/introspection.txt
${descriptions ? 'description' : ''}
to description
php artisan graphql:publish
php artisan graphql:schema
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?
Just need to adjust the environment and the key, here you have one:
APP_KEY=base64:4aVuW541oT+8kaM8VA/BkdfiuUloIHyihoGsCAY6Yt4=