Questions tagged [laravel-lighthouse]

Lighthouse is a PHP package that allows you to serve a GraphQL endpoint from your Laravel application.

Lighthouse is a PHP package that allows you to serve a GraphQL endpoint from your Laravel application. It greatly reduces the boilerplate required to create a schema, it integrates well with any Laravel project, and it's highly customizable giving you full control over your data.

276 questions
1
vote
2 answers

Problem with graphql resolvers using Lighthouse Graphql with Laravel

:) I am starting a new Laravel project with Lighthouse and have been problems with resolving non root fields. According to the documentation here for each of the fields that have complex types, there should be a model and a query provided for the…
Aryo
  • 31
  • 3
1
vote
2 answers

How to use dynamically created enum type in Lighthouse?

I have custom dynamically created Enum type MyCustomEnum witch I need to use in my ServiceProvider. For example I call Type string now Type::string():
Vyacheslav
  • 59
  • 5
1
vote
2 answers

Is it possible run a middleware for all query/mutation except any one?

I want to call a http middleware for all mutation/query call in GraphQL, but do not want to call for one query ? Is that possible ? Edit : I want to send user deactivated response, for all api which needs user to be logged-in, if user is soft…
Gaurav
  • 28,447
  • 8
  • 50
  • 80
1
vote
1 answer

Log Laravel Lighthouse GraphQL errors

I currently have a Laravel 8.49.0 project with a GraphQL api made with Lighthouse The thing is that I want to log all the errors that it can throw. I've found this section of the docs: Error Handling I've modified the lighthouse.php config file to…
jm19
  • 35
  • 8
1
vote
0 answers

Error calling @first and @method together on mutation

I need a mutation to call Article.doSomething() : Article I tried: type Mutation { doSomething(id: ID! @eq): Article! @find @method(name: "doSomething") } But I'm getting this error: Node doSomething can only have one directive of type…
Daniel Loureiro
  • 4,595
  • 34
  • 48
1
vote
2 answers

Laravel lighthouse Graphql filter by method on model

I want to filter my data, base on a method on my model: method in my model: // . . . public function isBatched(): bool { return $this->rows()->count() > 1; } and my qraphql: type Invoice { globalId: ID! @globalId…
Alireza Rahmani Khalili
  • 2,727
  • 2
  • 32
  • 33
1
vote
1 answer

Subscriptions do not work, the code in the subscription field class doesn't run

The mutation does not broadcast even though it is defined in the schema, I also added some log messages into the Subscription field class but if I trigger the subscription through the mutation or from artisan tinker like this: >>>…
1
vote
1 answer

Implementing laravel lighthouse pagination on the front-end

I'm trying to implement pagination on my site using a nuxt frontend and a laravel backend serving a graphql endpoint using lighthouse. reading the docs about the pagination directive has me asking lots of questions about how this works. Unlike the…
niels van hoof
  • 469
  • 4
  • 19
1
vote
1 answer

Insert data type JSON in lighthouse php

I´m working in back graphql API with Laravel and Lighthouse. I have a table with a column named "config" that stores json data. I´m trying to create a new register to that table. I have a mutation: createOrderTemplate(name: String!, config: JSON!):…
Jana
  • 11
  • 2
1
vote
0 answers

Can I create a single validation error bag for Lighthouse PHP, include GraphQL validation issues

Is there a way when using Lighthouse PHP to get the GraphQL validation error to appear side by side with the Laravel validation errors? Currently the graph QL validations cause a different type of error, before the Laravel error are run. For…
cfkane
  • 643
  • 1
  • 6
  • 16
1
vote
3 answers

mutation doesn't save ralation id

I have a problem with lighthouse graphql on laravel. Everything works great with queries or simple create/update, but when it comes to relations it becomes hard. It doesn't save relation. My example: Models class Product extends Model { public…
burasuk
  • 162
  • 2
  • 8
1
vote
0 answers

Laravel lighthouse graphql directory structure with a nuxtjs front-end

having some issues getting lighthouse and nuxtjs to work together properly. lighthouse requires a schema.graphql file inside the graphql directory, inside of this schema.graphql file you have the option to either place all of your code inside of…
niels van hoof
  • 469
  • 4
  • 19
1
vote
2 answers

How to get pivot data in laravel lighthouse?

I use lighthouse package for making my graphql schema (https://github.com/nuwave/lighthouse) But how to get data from @belongsToMany relationship that is stored in pivot table? E.g. the Document entity connected N-N to Person entity. And each Person…
Victor
  • 5,073
  • 15
  • 68
  • 120
1
vote
1 answer

How to phpunit subscriptions in laravel-lighthouse?

How one can phpunit subscriptions using only PHP/phpunit/Laravel and laravel-lighthouse GraphQL library? I am trying to create a unit test for my app that will subscribe to a "hello world" subscription. The purpose of such test is to assert the…
mowses
  • 21
  • 1
  • 1
  • 7
1
vote
1 answer

Laravel lighthouse inject now datetime

Is there a way to inject now datetime into a mutation? Something like this: customerUpsert(input: CustomerInput! @spread): Customer @upsert(model: "App\\Models\\Customer") @inject(context: ???, name: "customer_since")
Alireza A2F
  • 519
  • 4
  • 26