Lighthouse: How to make a wildcard search with like operator?

Created on 7 Feb 2019  路  3Comments  路  Source: nuwave/lighthouse

My previous query before using LightHouse:

$locations = Location::where('name', 'LIKE', "%$query%")->get();

Current Query with LightHouse

searchLocation(name: String! @where(operator: "like")): [Location] @all

Problem: This only gives me the result when the full name is matching. How can I do a wild card search as I did with the eloquent example?

Most helpful comment

I think that you you have to pass %SEARCHTEXT% as name arg. It will not do it for you. Otherwise, just use @field and do what you are used to do "before using lighthouse" (you can manipulate the query builder as you want)...

All 3 comments

I think that you you have to pass %SEARCHTEXT% as name arg. It will not do it for you. Otherwise, just use @field and do what you are used to do "before using lighthouse" (you can manipulate the query builder as you want)...

Passing %SEARCHTEXT% as name arg solved my issue. Thanks.

%SEARCHTEXT% it is working Thanks, on Lighthouse v4.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wimski picture wimski  路  3Comments

basudebpalfreelancer picture basudebpalfreelancer  路  4Comments

m1guelpf picture m1guelpf  路  3Comments

mehranabi picture mehranabi  路  3Comments

spawnia picture spawnia  路  4Comments