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

Laravel Lighthouse PHP Call to undefined relationship - but only on server

I'm developing an app that uses Lighthouse GraphQL server for Laravel. It's generally great, but I've run into some weird behaviour. When I run it locally, using Laravel Valet, it works perfectly. When I run it on staging server, it fails with Call…
Michael Sørensen
  • 395
  • 1
  • 3
  • 14
2
votes
1 answer

How to shuffle results in Lighthouse GraphQL (order by random)?

I see docs for @orderBy but am curious how I could sort my Lighthouse GraphQL results randomly, kind of like inRandomOrder in Laravel: $randomUser = DB::table('users') ->inRandomOrder() ->first(); Or like RAND() in…
Ryan
  • 22,332
  • 31
  • 176
  • 357
2
votes
2 answers

Laravel Lighthouse paginate field result

I have defined a query in lighthouse: extend type Query { products(input: ListInput @spread): [Product] @field(resolver: "App\\GraphQL\\Queries\\ProductComplex@index") } but the result of products is not paginated. I can not use both…
Alireza A2F
  • 519
  • 4
  • 26
2
votes
1 answer

How can I use Laravel Policies to filter list responses from GraphQL?

I want to filter (not prevent access to) list fields returned from my GraphQL API based on the view method in the model policy. I've written the directive below, which I've added to fields in my schema. I have two questions: This isn't the nicest…
user461697
2
votes
0 answers

Lighthouse php laravel - enums and paginator not working

Sorry, i'm fairly new to graphQL and lighthouse. I'm not sure if this is a bug, or if i missed something in the docs. I used the default paginator resolver and queries worked fine. However i needed to add some parameters, so followed the…
aibarra
  • 409
  • 1
  • 7
  • 17
2
votes
1 answer

How can i insert multiple data on same mutation in Laravel Lighthouse?

Can i insert multi on same mutation? I wonder this is exist or not. This is my Schema type Test { id: ID name: String msg: String } input testInput { name: String msg: String } type Mutation { createTest(input:…
Jeongkuk Seo
  • 127
  • 2
  • 15
2
votes
1 answer

Why does the Laravel Lighthouse @rename directive not work for me?

I have this GraphQL query: mutation CreateBudget( $revenue: Float!, $hours: Int!, $projectId: Int!, ) { createBudget( revenue: $revenue, hours: $hours, projectId: $projectId, ) { id } } For best practices, I want to use…
Axel Köhler
  • 911
  • 1
  • 8
  • 34
2
votes
0 answers

Lighthouse auto model detection doesn't work with unit tests

I seem to be facing the general problem that directive driven mutations won't properly work when unit testing them. Using GraphQL Playground everything works as expected and the User model is auto detected. But if unit testing the same functionality…
carsten
  • 191
  • 1
  • 2
  • 7
2
votes
1 answer

Laravel and Lighthouse, it always read the dafault schema

I'm following the tutorial on Lighthouse website for the master version (4.1). https://lighthouse-php.com/4.1/getting-started/tutorial.html#installation I make a fresh intallation of Laravel 5.8, then I execute the commands written in the tutorial…
Luigi Caradonna
  • 1,044
  • 2
  • 12
  • 33
2
votes
1 answer

GraphQL Server Cannot Be Reached Status Code 500

When attempting to use GraphQL Playground, it seemed like a cached version of schema.graphql was being referenced. So, I went ahead and ran php artisan cache:clear, which resulted in an error of "Server cannot be reached" and '"error": "Response not…
MatthewS
  • 455
  • 2
  • 7
  • 22
2
votes
1 answer

How can I have a field that is of type array in GraphQL?

I need to enter multiple Ids to a field in my mutations. How can I achieve that seeing array is not included in the scalar type. I'm using Laravel lighthouse package. I have tried to use [] to pass in the Ids but not working. mutation{ …
obi patrick
  • 73
  • 1
  • 11
2
votes
2 answers

Mocking an uploaded file with content

I'm working on a Laravel project that utilizes GraphQL with Lighthouse for the backend API. For some of the endpoints, we have file upload support. We have successfully tested that. The new endpoint that we are creating right now, will also support…
Mark Walet
  • 1,147
  • 10
  • 21
1
vote
0 answers

lighthouse: I have problems with many-to-many connections

I'm trying to create a post and attach tags to it. I'm also trying to create a post and create a tag that will be associated with the post. I followed the documentation but in the end it doesn't…
Straiker
  • 11
  • 1
1
vote
1 answer

Laravel Lighthouse query doesn't use redis cache

I have a GraphQL request that is very slow (10 seconds for 1700 records) but that I could cache easily with a 10 minutes TTL. Here it is: query GetMapAssets($first: Int, $page: Int) { assets(first: $first, page: $page, where: { …
Radyum
  • 99
  • 2
  • 11
1
vote
0 answers

Hiding fields based on another field and authentication with laravel lighthouse

I have a case where I need to hide field values on a Type based on another field but also show it in some cases based on the context. So for example, I have a Type like such: type Profile { id: ID! @cacheKey "Display name of the profile" …
Edwin Duoo
  • 11
  • 1
1 2
3
18 19