Skip to content

Improve guidance on use of projections with Querydsl and Query By Example  #248

Closed
@Thinkenterprise

Description

@Thinkenterprise

Are you planning to support pagination, sorting and maybe also projections for querydsl and query by example? These are topics that also play a role for GraphQL APIs. The implementation of some attributes that go in that direction, but not all of them are supported yet, right?

The Builder for the different DataFetchers are set to default values.

Snippet from QuerysldDataFetcher

@SuppressWarnings("unchecked")
Builder(QuerydslPredicateExecutor<T> executor, Class<R> domainType) {
	this(executor,
	ClassTypeInformation.from((Class<T>) domainType),
		domainType,
		Sort.unsorted(),
		NO_OP_BINDER_CUSTOMIZER);
}

The attributes will be considered, but always have the same default values. Pagination is not supported but part of the QuerydslPredicateExecutor interface. It would be possible if you want to support pagination.

Snippet from QuerysldDataFetcher

@Override
@SuppressWarnings("unchecked")
public Iterable<R> get(DataFetchingEnvironment env) {
	return this.executor.findBy(buildPredicate(env), query -> {
		FetchableFluentQuery<R> queryToUse = (FetchableFluentQuery<R>) query;

		if (this.sort.isSorted()){
			queryToUse = queryToUse.sortBy(this.sort);
		}

		if (requiresProjection(this.resultType)){
			queryToUse = queryToUse.as(this.resultType);
		}
		else {
			queryToUse = queryToUse.project(buildPropertyPaths(env.getSelectionSet(), this.resultType));
		}

		return queryToUse.all();
	});
}

}```

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions