You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a UsefulThingRepository which implements QuerydslPredicateExecutor<UsefulThing>.
The UsefulThing entity has an owner field.
When a user executes the query { usefulThing { name } } query, they should only get the items they own.
This works when owner is provided as a query argument.
However, in this case it makes sense to add the WHERE clause by default instead of relying on a query argument.
I would expect something like this work to add a default WHERE clause on the owner field.
var many = QuerydslDataFetcher.builder(repository)
.customizer((bindings, root) -> bindings.bind(QUsefulThing.usefulThing.owner)
.first((path, value) -> path.eq(ssoCallerResolver.get().username).many();
Note that in this example the ssoCallerResolver.get().username is just an example of something that would give the current user form the request.
In QuerydslPredicateBuilder on line 92 there is a check on values. Since the value is not user provided, this will be empty, and it won't build a predicate.
The text was updated successfully, but these errors were encountered:
QuerydslBindings are designed to be fed with request parameters and all operations following bindings.bind(…) expect request values to be consumed by the following methods.
What you're looking for is providing a default value that is either provided by a supplier function or held statically and then applied to the Querydsl binding.
Given a
UsefulThingRepository
which implementsQuerydslPredicateExecutor<UsefulThing>
.The
UsefulThing
entity has anowner
field.When a user executes the
query { usefulThing { name } }
query, they should only get the items they own.This works when
owner
is provided as a query argument.However, in this case it makes sense to add the WHERE clause by default instead of relying on a query argument.
I would expect something like this work to add a default
WHERE
clause on theowner
field.Note that in this example the
ssoCallerResolver.get().username
is just an example of something that would give the current user form the request.In
QuerydslPredicateBuilder
on line 92 there is a check onvalues
. Since the value is not user provided, this will be empty, and it won't build a predicate.The text was updated successfully, but these errors were encountered: