nuwave / lighthouse-example Goto Github PK
View Code? Open in Web Editor NEWAn example project using nuwave/lighthouse
Home Page: https://lighthouse-php.com
An example project using nuwave/lighthouse
Home Page: https://lighthouse-php.com
how can generate the current index from field directive ? need this for get the order from query
`
namespace App\GraphQL\Directives;
use GraphQL\Type\Definition\ResolveInfo;
use Nuwave\Lighthouse\Schema\Directives\BaseDirective;
use Nuwave\Lighthouse\Schema\Values\FieldValue;
use Nuwave\Lighthouse\Support\Contracts\FieldResolver;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
class RankDirective extends BaseDirective implements FieldResolver
{
public function resolveField(FieldValue $fieldValue)
{
return $fieldValue->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) {
return $root->id;
});
}
}
`
Hello, I am just trying out this repo but I am getting an error when I send the login mutation to the GraphQL server. Please help what could be the cause?
I used lighthouse in my own project, but I couldn't get the eloquent relationship directives to work. I am running this example project and I am encountering the same problem.
The only change I made in the lighthouse-example project is that I used the resolver for the jobs list in the schema.graphql file.
I have no issues querying the Models through tinker with their relationships. I can supply more information. I'm going to investigate this, but I wonder if other people have had this issue before.
I did a DB::Listen to log the output of the sql statements, I'll attach the file for a single call to the graphql call pictured above.
laravel.log
Hi,
Many thanks for your great work. I've just started with this great package and trying to follow your tutorial, but I'm having issue with "createJob". Just cloned your repo and didn't change anything except the .env file.
Bellow you can all individual steps to replicate my problem.
git clone https://github.com/nuwave/lighthouse-example.git
cd lighthouse-example
composer install
cp .env.example .env
I've entered login details for my local database into the .env file
I've generated key and started the server
php artisan key:generate
php artisan db:seed
php artisan serve
Called with graphQL client
mutation {
login(username: "[email protected]", password: "secret", client_id: 2, client_secret: "MIW7eh1y61upQPIEfa1nIV1sIls1XIYltxB7Ra5q") {
auth_token {
access_token
}
}
}
got response
{
"data": {
"login": {
"auth_token": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Ijk3Y2ZhMTRmMmE4OGVlNzgwMDFhYTFmMDllZjY5OTQ0MzBhNGJhZmUzZjcxNzAxNGI1ZmFlYjZiNjE1ZDg3YWIxN2I3ZGQ4YThjZmEzM2MwIn0.eyJhdWQiOiIyIiwianRpIjoiOTdjZmExNGYyYTg4ZWU3ODAwMWFhMWYwOWVmNjk5NDQzMGE0YmFmZTNmNzE3MDE0YjVmYWViNmI2MTVkODdhYjE3YjdkZDhhOGNmYTMzYzAiLCJpYXQiOjE1MzQ5MzAyODMsIm5iZiI6MTUzNDkzMDI4MywiZXhwIjoxNTY2NDY2MjgzLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.Tq86azoL1J15Rzlcsfqu2xkqtKu7xstfOcVfynza_8QXerq6lQgEiVhMSJzqWwsqfA8TGbc9zYD6W1iWmwvIPVybYmmKvjqhz3VjRQQS5wQP065rzlVZC6rg6LWE3f5kkcQH8eXa13pwKOhgBeZy0ItTgmygghebmxDTM6zpcRT4IC9Ga8wvaBqu9g2nM-IrwC6mg4ZdLYgpEgyWKErn4Gcs0h3rtPkSvbCTouZIgm1mKULg6n-BFV2wqHqlh2WeqJKgsKnZQ57tpbPHUZk_3sJwSD-NiPJPr2XNzd9vSwqEPkXXND5z0pUIyrdIehTdaL_m5ik-GEdrVdZTfPvBi8YUp6rNwPdvvXzO2dVD0wUVM1i1uZaDxbHPd1LXqA3D93gDpnKcewXPTkRdTl9VlI94XA7z41nvdKiPiM9BT8ERzh8vrpsi-SvqeztEn1ew6GbJAFw2sW9TOqSSrfFcEqg3jGe8cwzYJPcN5y3O_YLbaFccMcYiI4DhpqaIe0mmoF6UninBkSws1DJcgKG85DvyFLs4XRolb09H6VqckcfOrCbudXMm6XX3ABJi60276Uu6jtTv-pY-sk9x2YeL-j304qqrXaCekxhbJ2POK2zpfMr8PV2uLVOCFRJUAziWPa4CiS2d-kqWZz8ZSKqHKpxHV9HEUNEyeYoTVK989wc"
}
}
}
}
Calling following mutation with access_token from previous response:
mutation {
createJob(title: "title") {
title
}
}
but following error is returned
{
"data": {
"createJob": null
},
"errors": [
{
"message": "Class name must be a valid object or a string",
"locations": [
{
"line": 2,
"column": 2
}
]
}
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.