-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filters in sort #11
Comments
Seems each category has multiple translations? This case, unfortunately, is not yet supported. But I'm not sure that fully understand what are you trying to achieve... So maybe you can provide minimal db structure, graphql schema, and expected results? |
Yes, each category has multiple translations. First query from post above generates this SQL query: select
*
from
`categories`
where
(
exists (
select
*
from
`category_translations`
where
`categories`.`id` = `category_translations`.`category_id`
and `category_translations`.`language_id` = 'en-GB'
)
)
order by
(
select
`category_translations`.`name`
from
`category_translations`
where
`categories`.`id` = `category_translations`.`category_id`
limit
1
) desc
limit
100 offset 0 As you can see, in WHERE clause are conditions to fetch only en-gb translations, but in ORDER clause there is only joining translations by id, default ordered by primary key. So, if language "en-gb" is not created firstly, there is sorting by first matched row (eg. pl language, or any other). |
In the |
Nope, I meant something like 'sort_by' => [
/**
* Operators
* ---------------------------------------------------------------------
*
* You can (re)define types and supported operators here.
*
* @see Operator
*/
'operators' => [
SortByOperators::Extra => [
\LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\Operator\Condition::class,
],
],
], but, as I realized now, it unfortunately will not work :( So you need to create a custom operator that will create a custom type, you can check |
It is possible to achieve by custom types/operators, but I'm not sure the package should support it out of the box. Sorry. So I will close it for now. |
Hi,
look at this query:
As you see, I filter product that have language "en-GB" in translations, and sort them by language.name. But my first language in table is "pl", so results are sorted by first language in table.
One of proposal is extend @sortby directive to accept simple "where" condition:
or make search in @searchby directive:
What do you think?
The text was updated successfully, but these errors were encountered: