kikoseijo / lumen-lighthouse-graphql

Lumen example use of a GraphQL PHP server using Lighthouse package
http://kikoseijo.com/laravel-lumen-graphql-server-for-react-relay-modern/
MIT License
32 stars 3 forks source link

Fresh Boilerplate Install, Cannot get it to work. #2

Open julesmons opened 5 years ago

julesmons commented 5 years ago

When navigated to /graphql, the following error is presented:

Argument 2 passed to Nuwave\Lighthouse\Schema\Extensions\ExtensionRequest::__construct() must be of the type string, null given, called in C:\api\vendor\nuwave\lighthouse\src\Support\Http\Controllers\GraphQLController.php on line 41

Also in GraphQL Playground the following error is presented because it loads the error page:

{
  "error": "Unexpected token < in JSON at position 0"
}

Localhost, Windows 10, PHP 7.2.1, Chrome 69.0.3497.100

kikoseijo commented 5 years ago

Dont use the embedded one, use the GRaphql Playground as its a standalone app and works better. Hope it works for you,

julesmons commented 5 years ago

Dont use the embedded one, use the GRaphql Playground as its a standalone app and works better. Hope it works for you,

I am using the standalone one.

There seems to be an error in the PHP as referenced in my OP. If i navigate to localhost:8000/graphql With Chrome i see that PHP error.

julesmons commented 5 years ago

To clear up further uncertainties, i will share my exact steps:

Localhost, Windows 10, PHP 7.2.1, Chrome 69.0.3497.100

kikoseijo commented 5 years ago

Sorry but Lumen has no user interface, so, that module should be used to send things to, in lumen you cant navigate to things, you have a miss confusion of material. sorry.

julesmons commented 5 years ago

But the fact still stands that GraphQL Playground does not find a scheme. The API boilerplate still doesnt work for me

julesmons commented 5 years ago

A Screenshot of GraphQL Playground

image

kikoseijo commented 5 years ago

Im a bit tight on time right now, you are probably right and due to lighthouse updates i might have something broken. Ill find some time to adjust if you cant figure it out, but if you do please let me know to update the boilerplate.

Thanks @julesmons ,

kikoseijo commented 5 years ago

Just remember that you might need to make an schema, im pretty sure most of the setup its needed from the Readme.md

The commands on the setup like making your user model, Also, what looks strange its that your screenshot says that there is no connection to server. (in red, near url)

julesmons commented 5 years ago

I have made a scheme, in fact it was provided by the boilerplate. I cloned your zipfile so everything should be setup correctly.

Also in GraphQL Playground is says that there is no connection to the server, but in the command line i can see requests to /graphql being made (by GraphQL Playground) so the server can be reached

I dont think i can find a fix for the PHP errors because i dont know anything about Lighthouse. I also think something is broken because of the updates.

If you do find the time to update the boilerplate i would greatly appreciate that.

Thanks in advance,

Jules

kikoseijo commented 5 years ago

What about coors, you can sort of inspect inside the playground app because its an embedded chrome window with cmd + I on apple. See what the error log you reaching out of the server response, thats not the one provided by playground interface.

kikoseijo commented 5 years ago

Have updated composer, and I got it working.

screen shot 2018-10-11 at 15 47 12

kikoseijo commented 5 years ago

screen shot 2018-10-11 at 15 48 14

julesmons commented 5 years ago

I have opened the console window inside GraphQL Playground and got the following errors.

In the network tab image

In the console window image

I have done composer install && composer update. I will try to update composer itself and let you know if it works.

julesmons commented 5 years ago

I have done composer self-update and did composer install && composer update and i am still unable to get the API working.

However, the WEB portion of the API is working:

image

In GraphQL playground i am still getting the following errors, they are diffrent than te ones i mentioned earlier:

image

The problem now seems to be in NodeFactory.php on line 214. The full error is:

(1/1) TypeError 
DateTime::__construct() expects parameter 1 to be string, array given
jaspacheco commented 5 years ago

I believe you missing migrations, database connections, things like this, For me, looks like schema its empty, check config files if the route paths are correct.

julesmons commented 5 years ago

To clear up further uncertainties, i will share my exact steps:

  • git clone https://github.com/kikoseijo/lumen-lighthouse-graphql.git
  • cd lumen-lighthouse-graphql
  • composer install && composer update
  • copy .env.example .env
  • (App key inserted into .env)
  • (MySQL (MariaDB) database created)
  • (MySQL credentials inserted into .env)
  • php artisan migrate --seed
  • php -S localhost:8000 -t public/
  • (Used Chrome to navigate to http://localhost:8000/) Lumen version displayed
  • (Used Chrome to navigate to http://localhost:8000/graphql First PHP error in OP displayed
  • (Used standalone GraphQL Playground, set endpoint to http://localhost:8000/graphql) JSON Error displayed

Localhost, Windows 10, PHP 7.2.1, Chrome 69.0.3497.100

As referenced in the steps above, i did not miss migrations nor database connections in the .env file.

image

image

The schema also isn't empty, these are the contents from app/GraphQL/schema.graphql:

image

kikoseijo commented 5 years ago
<?php

namespace App\GraphQL\Scalars;

use Nuwave\Lighthouse\Schema\Types\Scalars\DateTime as LightDateTime;

class DateTime extends LightDateTime
{

}
kikoseijo commented 5 years ago

Add something like 2018-04-11 00:47:28 to the created_at and updated_at from your db record, ill update the seed if this resolves it.

julesmons commented 5 years ago

The PHP code you just shared already exists in the Boilerplate:

image

julesmons commented 5 years ago

I'll add 2018-04-11 00:47:28 to the created and updated add. Ill let you know it this resolves the issue

julesmons commented 5 years ago

I have changed the dates in my database:

image

In GraphQL Playground the schema still won't load and the following error is displayed:

image