Filtering for return value of a Method in PHP Lighthouse GraphQL

348 Views Asked by At

I have a GraphQL query findRecipe, which returns an array of Eloquent models recipe, which is also defined in the schema. recipe has a field called is_special_recipe which is not a column in the database, but a value calculated by a method. How can I filter for is_special_recipe in my findRecipe query?


    searchRecipe(
        name: String @where(operator: "LIKE")
        cooking_time_min: Int @where(operator: ">=")
        cooking_time_max: Int @where(operator: "<=")
        is_special_recipe: Boolean @where(operator: "eq")
    ): [Recipe] @paginate

type Recipe {
    id: ID!
    name: String!
    image: String
    description: String
    cooking_time_min: Int
    cooking_time_max: Int
    is_special_recipe: Boolean @method(name: "isSpecialRecipe")
}
    public function isSpecialRecipe()
    {
        //some logic
        return false || true;
    }
0

There are 0 best solutions below