Skip to content

Commit

Permalink
Use fallback default predicate for QuerydslDataFetcher
Browse files Browse the repository at this point in the history
Closes gh-71
  • Loading branch information
rstoyanchev committed Jun 29, 2021
1 parent dfebb6f commit 9a4da36
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.function.Function;

import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Predicate;
import graphql.schema.DataFetcher;
Expand Down Expand Up @@ -153,7 +154,16 @@ protected Predicate buildPredicate(DataFetchingEnvironment environment) {
parameters.put(entry.getKey(), Collections.singletonList(entry.getValue()));
}

return BUILDER.getPredicate(this.domainType, (MultiValueMap) parameters, bindings);
Predicate predicate = BUILDER.getPredicate(this.domainType, (MultiValueMap) parameters, bindings);

// Temporary workaround for this fix in Spring Data:
// https://github.com/spring-projects/spring-data-commons/issues/2396

if (predicate == null) {
predicate = new BooleanBuilder();
}

return predicate;
}

private static <S, T> Function<S, T> createProjection(Class<T> projectionType) {
Expand Down

0 comments on commit 9a4da36

Please sign in to comment.