Skip to content

Default ScrollSubrange is not applied correctly for backwards scrolling in QueryDSL and QBE #900

Closed as not planned
@mspiess

Description

@mspiess

Example:
There is a Entity called Document.
Schema:

type Query {
  documents(first: Int, last: Int): DocumentConnection
}

A query for document returns the same data, regardless of whether first or last is provided.

The culprit:
QuerydslDataFetcher#ScrollableEntityFetcher.getResult uses the limit from the subrange that is build out of the arguments. If a cursor is provided using before or after it also uses the built subrange's position, which has the intended direction. However in the case where there is no cursor provided, it uses the default subrange's position, overriding the provided direction.

@SuppressWarnings("OptionalGetWithoutIsPresent")
@Override
protected Iterable<R> getResult(FetchableFluentQuery<R> queryToUse, DataFetchingEnvironment env) {
	ScrollSubrange subrange = buildScrollSubrange(env);
	int limit = subrange.count().orElse(this.defaultSubrange.count().getAsInt());
	ScrollPosition position = subrange.position().orElse(this.defaultSubrange.position().get());
	return queryToUse.limit(limit).scroll(position);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions