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
0
votes
1 answer

How to mutate list of objects in lighthouse GraphQL

i have schema: input CreateProduct { id_product: Int content: CreateContentHasMany manufacturer: CreateManufacturerHasOne codes: ProductCodesInput } type Mutation { createProduct(product: CreateProduct! @spread): Product @create …
burasuk
  • 162
  • 2
  • 8
0
votes
3 answers

Laravel Lighthouse Graphql multiple guards

I am trying to make my custom guard to work against a GraphQL schema with Lighthouse but its not working. The problem is that my custom guard is not reached by graphql query. The schema.graphql: (removed some code for brevity) extend type Query…
mowses
  • 21
  • 1
  • 1
  • 7
0
votes
2 answers

can I throw custom error in laravel-lighthouse

is the any way that throw an error by GraphQL\Error\Error with no additional data except message. the current return data is { "errors": [ { "message": "Some Errors", "extensions": { "reason": "", "category":…
MrM
  • 11
  • 1
  • 3
0
votes
1 answer

GraphQL - Model(s) belong to specific user field

I'm using Lighthouse package to implement GraphQL, the users in my app belong to an entity and I need to get models that belong to the entity of each user, my schema is like this for the moment "A date string with format `Y-m-d`, e.g.…
LePepe
  • 53
  • 6
0
votes
3 answers

GraphQl LightHouse Where Condition not working

How to add a where condition in query? projects: [Project!]! @all @orderBy(column: "id", direction: DESC) I'd like to have: projects: [Project!]! @all @orderBy(column: "id", direction: DESC) @where('parent_id','=',0)
0
votes
1 answer

Graphql: User Error: expected iterable, but did not find one for field XXX

This is movie schema: type Book { id: ID! title: String author: [Author] @belongsTo(relation: "author") } This is how I related book and author public function author() { return $this->belongsTo('App\Models\Author', 'id',…
oxygen
  • 151
  • 2
  • 3
  • 14
0
votes
2 answers

How to get products of a "main category" if a product is related to only one "subcategory"?

How do I get all products of a “main category” if a product is related to only one “subcategory”? A product is only related to a sub-category, while a sub-category is always part of the main category. So I want to have all products in the main…
0
votes
2 answers

How to use toArray in Laravel Lighthouse Resolver?

When I use first() in query builder I get result. See: public function __invoke($_, array $args) { return MyTable::where('id', 1)->first(); } However, when I change first() with toArray(), I can not get any result. See: public function…
oxygen
  • 151
  • 2
  • 3
  • 14
0
votes
2 answers

How to implement Group By query to Laravel Lighthouse?

How can I make following query in lighthouse eloquent query? select * from mytable group by customer
oxygen
  • 151
  • 2
  • 3
  • 14
0
votes
1 answer

GraphQL - Laravel - OrderBy by default

I'm running lighthouse for laravel and it's not working @orderBy, by default (without pass argument). I follow that guide, https://lighthouse-php.com/master/api-reference/directives.html#orderby Predefined Ordering To predefine a default order for…
Agustin
  • 215
  • 1
  • 2
  • 14
0
votes
1 answer

Laravel lighthouse inject nested mutations

Here are my inputs for nested mutation: input ActivityInput { id: ID user_id: ID goal: String } input ActivityRelationInput { upsert: [ActivityInput] delete: [ID] } input CustomerInput { id: ID name: String activities:…
Alireza A2F
  • 519
  • 4
  • 26
0
votes
2 answers

How can I parse JSON data in Lighthouse?

I have notification table , where data field stored as json : {"data":{"description":"Event Status has been changed to pending","event_id":19}} I get this error "errors": [ { "debugMessage": "Expected a value of type \"String\" but received:…
0
votes
1 answer

Issue with N+1 queries with accessors when using Lighthouse GraphQL and Laravel

I'm having a bit of an issue with the old N+1 problem. I'm running Lighthouse 4.8, Laravel 5.8, and have batched_queries and batchload_relations set to true in my config. I have the hasMany and hasOne set in my schema (anonymised a little): type…
0
votes
2 answers

Lighthouse GraphQL - No directive found for `orderBy`

{ "error": { "message": "No directive found for `orderBy`", "exception": "Nuwave\\Lighthouse\\Exceptions\\DirectiveException", "file":…
0
votes
2 answers

How to use custom Laravel rules with arguments with Lighthouse

I have a doubt about the @rules directive. I have created my own Rule in Laravel but I need to pass an argument in the constructor, so I don't know how I can use the @rules directive properly @rules(apply: ["App\\Rules\\MyCustomRule"]) How can I do…