-
Notifications
You must be signed in to change notification settings - Fork 324
Description
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.