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
0 answers

How to authenticate a user by its user id in Laravel in a custom middleware

How would you guys go about implementing something like this? I use Laravel as an API only. We have other framework where the login was implemented where it saves an httpOnly cookie (sessionId) after the user logs in. That's the main framework.…
Sylar
  • 11,422
  • 25
  • 93
  • 166
0
votes
1 answer

No directive found for `bcrypt`

I'm following official Lighthouse documentation on how to setup GraphQl into my project. Unfortunately, I'm stacked with the following error: No directive found for `bcrypt` Following schema I have created so far: type Query { users: [User!]!…
Aleksandr Popov
  • 500
  • 5
  • 20
0
votes
1 answer

How to create a GraphQL query that returns data from multiple tables/models within one field using Laravel Lighthouse

Im trying to learn GraphQL with Laravel & Lighthouse and have a question Im hoping someone can help me with. I have the following five database tables which are also defined in my Laravel models: users books user_books book_series book_copies I'd…
Michael J
  • 11
  • 3
0
votes
1 answer

How to put current timestamp in GraphQL mutation schema on server-side?

I need to put current timestamp in mutation query when user cancels the order. It should be on server-side (cause it's not ok to rely on client's data). Here is a simple mutation in my Laravel Lighthouse GraphQL schema: type Mutation { …
Waldor
  • 31
  • 5
0
votes
1 answer

What is the proper way to validate user password confirmed input using Laravel lighthouse

I'm working on a GraphQL schema for my Laravel project using the lighthouse library. But I'm running into a problem when trying to validate the user confirmed their password. The issue occurs when I try to register a user. Consider the following…
MikeSli
  • 927
  • 2
  • 14
  • 32
0
votes
1 answer

two types on same input field grapqhql lighthouse

So how can I do, or is possible to have 2 types on the input fields? For example, I have like: input UpdatePersonInput { first_name: String surname: String age: Int } extend type Mutation { updatePerson(id: ID!, input:…
francisco
  • 1,387
  • 2
  • 12
  • 23
0
votes
0 answers

PHP Lighthouse Laravel - Get resources via the authenticated user

Is there a way to get resources (example: Posts) via the authenticated user? Like this: Auth::user()->posts() Schema: type Query @guard(with: ["api"]) { me_posts: [Post!]! @auth }
degebine
  • 303
  • 2
  • 11
0
votes
2 answers

lighthouse php use eloquent model accessors and mutators

I'm using lighthouse for graphql on top of my laravel application. I know how to define types. But how can I use the model accessor in the type definition of schema? For example, i have type use like this type User { id: ID! name:…
Adil Amanat
  • 70
  • 1
  • 5
0
votes
1 answer

How to implement search functionality with Laravel lighthouse-php and vuejs?

Backend Laravel with scout and algolia search, Lighthouse-php Below laravel grapql: products(search: String @search, orderBy: _ @orderBy(columns: ["created_at"])): [Product!]! @paginate Graphql-playground search work perfectly: products(first: 5,…
German
  • 137
  • 17
0
votes
1 answer

PHP Lighthouse get parameter from root query in FieldResolver

I have the following setup of queries: extend type Query { positionGroups(quoteId: ID): [PositionGroup!]! @all } type PositionGroup { ... positions: [Position!]! } type Position { ... amount: Amount…
Pablo
  • 41
  • 6
0
votes
1 answer

VSCode and Xdebug on a Laravel Lighthouse Windows environment setup

I'm trying to set up Xdebug to work in VSCode on a Windows environment with a Lighthouse / Laravel based server. My VSCode settings look like this { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of…
0
votes
1 answer

Lighthouse GraphQL - how to self-reference User type for @belongsToMany?

I'm attempting to build a very simple Facebook clone to improve my knowledge of GraphQL. I'm using the nuwave/lighthouse package for my Laravel backend. Currently, when I run $user->friends()->get() in tinker, it correctly returns the results (so I…
J. Jackson
  • 3,326
  • 8
  • 34
  • 74
0
votes
1 answer

Is there a way define complex where conditions as variables?

I have created a GraphQL Query that gets complex where conditions but in Apollo GraphQL iOS client there is no way of changing query after compiling the project. Apollo GraphQL iOS client gives chance to change defined variables in the query but not…
Can Atuf Kansu
  • 523
  • 2
  • 7
  • 16
0
votes
1 answer

Lighthouse GraphQL - HasManyThrough on pivot table

I've got a project that I'm converting from Rails REST API to Laravel GraphQL API (I'm new to Laravel), and am working on setting up the models and relationships. I have a categories, category_items, and items table. The category_items table has…
J. Jackson
  • 3,326
  • 8
  • 34
  • 74
0
votes
1 answer

Laravel/ Lighthouse GraphQL - how to find by slug attribute?

I'm creating a Laravel backend for a Nuxt app, and am using Lighthouse-PHP to deliver data via GraphQL. I'm trying to set up a query to do a find by slug instead of the default ID. When I run the query in the graphql playground, it correctly returns…
J. Jackson
  • 3,326
  • 8
  • 34
  • 74