From a0d7cc1c8cb5aaa1614fde0a83d74a44995d4a15 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Wed, 12 Apr 2023 11:18:40 +0100 Subject: [PATCH] Expose CursorsStrategy and Subrange as builder options This makes it possible to customize these settings individually, optionally, and via QuerydslBuilderCustomizer. See gh-597 --- .../src/docs/asciidoc/index.adoc | 10 +- .../data/query/QueryByExampleDataFetcher.java | 132 ++++++++++++--- .../data/query/QuerydslDataFetcher.java | 154 +++++++++++++----- .../data/query/QuerydslDataFetcherTests.java | 5 +- .../QueryByExampleDataFetcherJpaTests.java | 4 +- ...QueryByExampleDataFetcherMongoDbTests.java | 4 +- 6 files changed, 236 insertions(+), 73 deletions(-) diff --git a/spring-graphql-docs/src/docs/asciidoc/index.adoc b/spring-graphql-docs/src/docs/asciidoc/index.adoc index 0da1230c..5f60a121 100644 --- a/spring-graphql-docs/src/docs/asciidoc/index.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/index.adoc @@ -863,11 +863,8 @@ Then use it to create a `DataFetcher`: QuerydslDataFetcher.builder(repository).many(); // For paginated queries - CursorStrategy cursorStrategy = ... ; - ScrollSubrange defaultSubrange = ... ; - DataFetcher> dataFetcher = - QuerydslDataFetcher.builder(repository).scrollable(cursorStrategy, defaultSubrange); + QuerydslDataFetcher.builder(repository).scrollable(); ---- You can now register the above `DataFetcher` through a @@ -1066,11 +1063,8 @@ Use `QueryByExampleDataFetcher` to turn the repository into a `DataFetcher`: QueryByExampleDataFetcher.builder(repository).many(); // For paginated queries - CursorStrategy cursorStrategy = ... ; - ScrollSubrange defaultSubrange = ... ; - DataFetcher> dataFetcher = - QueryByExampleDataFetcher.builder(repository).scrollable(cursorStrategy, defaultSubrange); + QueryByExampleDataFetcher.builder(repository).scrollable(); ---- You can now register the above `DataFetcher` through a diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java index 1a2817f6..609ba085 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QueryByExampleDataFetcher.java @@ -45,6 +45,7 @@ import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor; import org.springframework.data.util.TypeInformation; import org.springframework.graphql.data.GraphQlArgumentBinder; import org.springframework.graphql.data.GraphQlRepository; +import org.springframework.graphql.data.pagination.CursorEncoder; import org.springframework.graphql.data.pagination.CursorStrategy; import org.springframework.graphql.data.query.AutoRegistrationRuntimeWiringConfigurer.DataFetcherFactory; import org.springframework.graphql.execution.RuntimeWiringConfigurer; @@ -165,6 +166,7 @@ public abstract class QueryByExampleDataFetcher { } protected ScrollSubrange buildScrollSubrange(DataFetchingEnvironment environment) { + Assert.state(this.cursorStrategy != null, "Expected CursorStrategy"); return RepositoryUtils.buildScrollSubrange(environment, this.cursorStrategy); } @@ -234,7 +236,10 @@ public abstract class QueryByExampleDataFetcher { for (QueryByExampleExecutor executor : executors) { String typeName = RepositoryUtils.getGraphQlTypeName(executor); if (typeName != null) { - Builder builder = customize(executor, builder(executor)); + Builder builder = customize(executor, builder(executor) + .cursorStrategy(cursorStrategy) + .defaultScrollSubrange(defaultScrollSubrange)); + factories.put(typeName, new DataFetcherFactory() { @Override public DataFetcher single() { @@ -248,7 +253,7 @@ public abstract class QueryByExampleDataFetcher { @Override public DataFetcher scrollable() { - return builder.scrollable(cursorStrategy, defaultScrollSubrange); + return builder.scrollable(); } }); } @@ -257,7 +262,10 @@ public abstract class QueryByExampleDataFetcher { for (ReactiveQueryByExampleExecutor executor : reactiveExecutors) { String typeName = RepositoryUtils.getGraphQlTypeName(executor); if (typeName != null) { - ReactiveBuilder builder = customize(executor, builder(executor)); + ReactiveBuilder builder = customize(executor, builder(executor) + .cursorStrategy(cursorStrategy) + .defaultScrollSubrange(defaultScrollSubrange)); + factories.put(typeName, new DataFetcherFactory() { @Override public DataFetcher single() { @@ -271,7 +279,7 @@ public abstract class QueryByExampleDataFetcher { @Override public DataFetcher scrollable() { - return builder.scrollable(cursorStrategy, defaultScrollSubrange); + return builder.scrollable(); } }); } @@ -356,17 +364,28 @@ public abstract class QueryByExampleDataFetcher { private final Class resultType; + @Nullable + private final CursorStrategy cursorStrategy; + + @Nullable + private final ScrollSubrange defaultSubrange; + private final Sort sort; @SuppressWarnings("unchecked") Builder(QueryByExampleExecutor executor, Class domainType) { - this(executor, TypeInformation.of((Class) domainType), domainType, Sort.unsorted()); + this(executor, TypeInformation.of((Class) domainType), domainType, null, null, Sort.unsorted()); } - Builder(QueryByExampleExecutor executor, TypeInformation domainType, Class resultType, Sort sort) { + Builder(QueryByExampleExecutor executor, TypeInformation domainType, Class resultType, + @Nullable CursorStrategy cursorStrategy, @Nullable ScrollSubrange defaultSubrange, + Sort sort) { + this.executor = executor; this.domainType = domainType; this.resultType = resultType; + this.cursorStrategy = cursorStrategy; + this.defaultSubrange = defaultSubrange; this.sort = sort; } @@ -381,7 +400,36 @@ public abstract class QueryByExampleDataFetcher { */ public

Builder projectAs(Class

projectionType) { Assert.notNull(projectionType, "Projection type must not be null"); - return new Builder<>(this.executor, this.domainType, projectionType, this.sort); + return new Builder<>(this.executor, this.domainType, + projectionType, this.cursorStrategy, this.defaultSubrange, this.sort); + } + + /** + * Configure strategy for decoding a cursor from a paginated request. + *

By default, this is {@link ScrollPositionCursorStrategy} with + * {@link CursorEncoder#base64()} encoding. + * @param cursorStrategy the strategy to use + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public Builder cursorStrategy(@Nullable CursorStrategy cursorStrategy) { + return new Builder<>(this.executor, this.domainType, + this.resultType, cursorStrategy, this.defaultSubrange, this.sort); + } + + /** + * Configure a {@link ScrollSubrange} to use when a paginated request does + * not specify a cursor and/or a count of items. + *

By default, this is {@link OffsetScrollPosition#initial()} with a + * count of 20. + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public Builder defaultScrollSubrange(@Nullable ScrollSubrange defaultSubrange) { + return new Builder<>(this.executor, this.domainType, + this.resultType, this.cursorStrategy, defaultSubrange, this.sort); } /** @@ -392,7 +440,8 @@ public abstract class QueryByExampleDataFetcher { */ public Builder sortBy(Sort sort) { Assert.notNull(sort, "Sort must not be null"); - return new Builder<>(this.executor, this.domainType, this.resultType, sort); + return new Builder<>(this.executor, this.domainType, + this.resultType, this.cursorStrategy, this.defaultSubrange, sort); } /** @@ -414,11 +463,12 @@ public abstract class QueryByExampleDataFetcher { * {@link org.springframework.data.domain.Window}. * @since 1.2 */ - public DataFetcher> scrollable( - CursorStrategy cursorStrategy, ScrollSubrange defaultScrollSubrange) { - + public DataFetcher> scrollable() { return new ScrollableEntityFetcher<>( - this.executor, this.domainType, this.resultType, cursorStrategy, defaultScrollSubrange, this.sort); + this.executor, this.domainType, this.resultType, + (this.cursorStrategy != null ? this.cursorStrategy : RepositoryUtils.defaultCursorStrategy()), + (this.defaultSubrange != null ? this.defaultSubrange : RepositoryUtils.defaultScrollSubrange()), + this.sort); } } @@ -460,20 +510,29 @@ public abstract class QueryByExampleDataFetcher { private final Class resultType; + @Nullable + private final CursorStrategy cursorStrategy; + + @Nullable + private final ScrollSubrange defaultSubrange; + private final Sort sort; @SuppressWarnings("unchecked") ReactiveBuilder(ReactiveQueryByExampleExecutor executor, Class domainType) { - this(executor, TypeInformation.of((Class) domainType), domainType, Sort.unsorted()); + this(executor, TypeInformation.of((Class) domainType), domainType, null, null, Sort.unsorted()); } ReactiveBuilder( - ReactiveQueryByExampleExecutor executor, TypeInformation domainType, - Class resultType, Sort sort) { + ReactiveQueryByExampleExecutor executor, TypeInformation domainType, Class resultType, + @Nullable CursorStrategy cursorStrategy, @Nullable ScrollSubrange defaultSubrange, + Sort sort) { this.executor = executor; this.domainType = domainType; this.resultType = resultType; + this.cursorStrategy = cursorStrategy; + this.defaultSubrange = defaultSubrange; this.sort = sort; } @@ -488,7 +547,36 @@ public abstract class QueryByExampleDataFetcher { */ public

ReactiveBuilder projectAs(Class

projectionType) { Assert.notNull(projectionType, "Projection type must not be null"); - return new ReactiveBuilder<>(this.executor, this.domainType, projectionType, this.sort); + return new ReactiveBuilder<>(this.executor, this.domainType, + projectionType, this.cursorStrategy, this.defaultSubrange, this.sort); + } + + /** + * Configure strategy for decoding a cursor from a paginated request. + *

By default, this is {@link ScrollPositionCursorStrategy} with + * {@link CursorEncoder#base64()} encoding. + * @param cursorStrategy the strategy to use + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public ReactiveBuilder cursorStrategy(@Nullable CursorStrategy cursorStrategy) { + return new ReactiveBuilder<>(this.executor, this.domainType, + this.resultType, cursorStrategy, this.defaultSubrange, this.sort); + } + + /** + * Configure a {@link ScrollSubrange} to use when a paginated request does + * not specify a cursor and/or a count of items. + *

By default, this is {@link OffsetScrollPosition#initial()} with a + * count of 20. + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public ReactiveBuilder defaultScrollSubrange(@Nullable ScrollSubrange defaultSubrange) { + return new ReactiveBuilder<>(this.executor, this.domainType, + this.resultType, this.cursorStrategy, defaultSubrange, this.sort); } /** @@ -499,7 +587,8 @@ public abstract class QueryByExampleDataFetcher { */ public ReactiveBuilder sortBy(Sort sort) { Assert.notNull(sort, "Sort must not be null"); - return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, sort); + return new ReactiveBuilder<>(this.executor, this.domainType, + this.resultType, this.cursorStrategy, this.defaultSubrange, sort); } /** @@ -521,11 +610,12 @@ public abstract class QueryByExampleDataFetcher { * {@link org.springframework.data.domain.Window}. * @since 1.2 */ - public DataFetcher>> scrollable( - CursorStrategy cursorStrategy, ScrollSubrange defaultScrollSubrange) { - + public DataFetcher>> scrollable() { return new ReactiveScrollableEntityFetcher<>( - this.executor, this.domainType, this.resultType, cursorStrategy, defaultScrollSubrange, this.sort); + this.executor, this.domainType, this.resultType, + (this.cursorStrategy != null ? this.cursorStrategy : RepositoryUtils.defaultCursorStrategy()), + (this.defaultSubrange != null ? this.defaultSubrange : RepositoryUtils.defaultScrollSubrange()), + this.sort); } } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QuerydslDataFetcher.java b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QuerydslDataFetcher.java index ceaf5577..eeec58ce 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/query/QuerydslDataFetcher.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/query/QuerydslDataFetcher.java @@ -49,6 +49,7 @@ import org.springframework.data.repository.query.FluentQuery; import org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery; import org.springframework.data.util.TypeInformation; import org.springframework.graphql.data.GraphQlRepository; +import org.springframework.graphql.data.pagination.CursorEncoder; import org.springframework.graphql.data.pagination.CursorStrategy; import org.springframework.graphql.data.query.AutoRegistrationRuntimeWiringConfigurer.DataFetcherFactory; import org.springframework.graphql.execution.RuntimeWiringConfigurer; @@ -189,6 +190,7 @@ public abstract class QuerydslDataFetcher { } protected ScrollSubrange buildScrollSubrange(DataFetchingEnvironment environment) { + Assert.state(this.cursorStrategy != null, "Expected CursorStrategy"); return RepositoryUtils.buildScrollSubrange(environment, this.cursorStrategy); } @@ -260,8 +262,11 @@ public abstract class QuerydslDataFetcher { for (QuerydslPredicateExecutor executor : executors) { String typeName = RepositoryUtils.getGraphQlTypeName(executor); if (typeName != null) { - Builder builder = customize( - executor, QuerydslDataFetcher.builder(executor).customizer(customizer(executor))); + Builder builder = customize(executor, + QuerydslDataFetcher.builder(executor) + .cursorStrategy(cursorStrategy) + .defaultScrollSubrange(defaultScrollSubrange) + .customizer(customizer(executor))); factories.put(typeName, new DataFetcherFactory() { @Override @@ -276,7 +281,7 @@ public abstract class QuerydslDataFetcher { @Override public DataFetcher scrollable() { - return builder.scrollable(cursorStrategy, defaultScrollSubrange); + return builder.scrollable(); } }); } @@ -285,8 +290,11 @@ public abstract class QuerydslDataFetcher { for (ReactiveQuerydslPredicateExecutor executor : reactiveExecutors) { String typeName = RepositoryUtils.getGraphQlTypeName(executor); if (typeName != null) { - ReactiveBuilder builder = customize( - executor, QuerydslDataFetcher.builder(executor).customizer(customizer(executor))); + ReactiveBuilder builder = customize(executor, + QuerydslDataFetcher.builder(executor) + .cursorStrategy(cursorStrategy) + .defaultScrollSubrange(defaultScrollSubrange) + .customizer(customizer(executor))); factories.put(typeName, new DataFetcherFactory() { @Override @@ -301,7 +309,7 @@ public abstract class QuerydslDataFetcher { @Override public DataFetcher scrollable() { - return builder.scrollable(cursorStrategy, defaultScrollSubrange); + return builder.scrollable(); } }); } @@ -397,25 +405,31 @@ public abstract class QuerydslDataFetcher { private final Class resultType; + @Nullable + private final CursorStrategy cursorStrategy; + + @Nullable + private final ScrollSubrange defaultSubrange; + private final Sort sort; private final QuerydslBinderCustomizer> customizer; @SuppressWarnings("unchecked") Builder(QuerydslPredicateExecutor executor, Class domainType) { - this(executor, - TypeInformation.of((Class) domainType), - domainType, - Sort.unsorted(), - NO_OP_BINDER_CUSTOMIZER); + this(executor, TypeInformation.of((Class) domainType), + domainType, null, null, Sort.unsorted(), NO_OP_BINDER_CUSTOMIZER); } - Builder(QuerydslPredicateExecutor executor, TypeInformation domainType, - Class resultType, Sort sort, QuerydslBinderCustomizer> customizer) { + Builder(QuerydslPredicateExecutor executor, TypeInformation domainType, Class resultType, + @Nullable CursorStrategy cursorStrategy, @Nullable ScrollSubrange defaultSubrange, + Sort sort, QuerydslBinderCustomizer> customizer) { this.executor = executor; this.domainType = domainType; this.resultType = resultType; + this.cursorStrategy = cursorStrategy; + this.defaultSubrange = defaultSubrange; this.sort = sort; this.customizer = customizer; } @@ -431,7 +445,36 @@ public abstract class QuerydslDataFetcher { */ public

Builder projectAs(Class

projectionType) { Assert.notNull(projectionType, "Projection type must not be null"); - return new Builder<>(this.executor, this.domainType, projectionType, this.sort, this.customizer); + return new Builder<>(this.executor, this.domainType, projectionType, + this.cursorStrategy, this.defaultSubrange, this.sort, this.customizer); + } + + /** + * Configure strategy for decoding a cursor from a paginated request. + *

By default, this is {@link ScrollPositionCursorStrategy} with + * {@link CursorEncoder#base64()} encoding. + * @param cursorStrategy the strategy to use + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public Builder cursorStrategy(@Nullable CursorStrategy cursorStrategy) { + return new Builder<>(this.executor, this.domainType, this.resultType, + cursorStrategy, this.defaultSubrange, this.sort, this.customizer); + } + + /** + * Configure a {@link ScrollSubrange} to use when a paginated request does + * not specify a cursor and/or a count of items. + *

By default, this is {@link OffsetScrollPosition#initial()} with a + * count of 20. + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public Builder defaultScrollSubrange(@Nullable ScrollSubrange defaultSubrange) { + return new Builder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, defaultSubrange, this.sort, this.customizer); } /** @@ -442,7 +485,8 @@ public abstract class QuerydslDataFetcher { */ public Builder sortBy(Sort sort) { Assert.notNull(sort, "Sort must not be null"); - return new Builder<>(this.executor, this.domainType, this.resultType, sort, customizer); + return new Builder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, this.defaultSubrange, sort, customizer); } /** @@ -460,7 +504,8 @@ public abstract class QuerydslDataFetcher { */ public Builder customizer(QuerydslBinderCustomizer> customizer) { Assert.notNull(customizer, "QuerydslBinderCustomizer must not be null"); - return new Builder<>(this.executor, this.domainType, this.resultType, this.sort, customizer); + return new Builder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, this.defaultSubrange, this.sort, customizer); } /** @@ -484,11 +529,11 @@ public abstract class QuerydslDataFetcher { * {@link org.springframework.data.domain.Window}. * @since 1.2 */ - public DataFetcher> scrollable( - CursorStrategy cursorStrategy, ScrollSubrange defaultScrollSubrange) { - + public DataFetcher> scrollable() { return new ScrollableEntityFetcher<>( - this.executor, this.domainType, this.resultType, cursorStrategy, defaultScrollSubrange, + this.executor, this.domainType, this.resultType, + (this.cursorStrategy != null ? this.cursorStrategy : RepositoryUtils.defaultCursorStrategy()), + (this.defaultSubrange != null ? this.defaultSubrange : RepositoryUtils.defaultScrollSubrange()), this.sort, this.customizer); } @@ -531,28 +576,32 @@ public abstract class QuerydslDataFetcher { private final Class resultType; + @Nullable + private final CursorStrategy cursorStrategy; + + @Nullable + private final ScrollSubrange defaultSubrange; + private final Sort sort; private final QuerydslBinderCustomizer> customizer; @SuppressWarnings("unchecked") ReactiveBuilder(ReactiveQuerydslPredicateExecutor executor, Class domainType) { - this(executor, - TypeInformation.of((Class) domainType), - domainType, - Sort.unsorted(), - NO_OP_BINDER_CUSTOMIZER); + this(executor, TypeInformation.of((Class) domainType), + domainType, null, null, Sort.unsorted(), NO_OP_BINDER_CUSTOMIZER); } - ReactiveBuilder(ReactiveQuerydslPredicateExecutor executor, - TypeInformation domainType, - Class resultType, - Sort sort, - QuerydslBinderCustomizer> customizer) { + ReactiveBuilder( + ReactiveQuerydslPredicateExecutor executor, TypeInformation domainType, Class resultType, + @Nullable CursorStrategy cursorStrategy, @Nullable ScrollSubrange defaultSubrange, + Sort sort, QuerydslBinderCustomizer> customizer) { this.executor = executor; this.domainType = domainType; this.resultType = resultType; + this.cursorStrategy = cursorStrategy; + this.defaultSubrange = defaultSubrange; this.sort = sort; this.customizer = customizer; } @@ -568,7 +617,36 @@ public abstract class QuerydslDataFetcher { */ public

ReactiveBuilder projectAs(Class

projectionType) { Assert.notNull(projectionType, "Projection type must not be null"); - return new ReactiveBuilder<>(this.executor, this.domainType, projectionType, this.sort, this.customizer); + return new ReactiveBuilder<>(this.executor, this.domainType, projectionType, + this.cursorStrategy, this.defaultSubrange, this.sort, this.customizer); + } + + /** + * Configure strategy for decoding a cursor from a paginated request. + *

By default, this is {@link ScrollPositionCursorStrategy} with + * {@link CursorEncoder#base64()} encoding. + * @param cursorStrategy the strategy to use + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public ReactiveBuilder cursorStrategy(@Nullable CursorStrategy cursorStrategy) { + return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, + cursorStrategy, this.defaultSubrange, this.sort, this.customizer); + } + + /** + * Configure a {@link ScrollSubrange} to use when a paginated request does + * not specify a cursor and/or a count of items. + *

By default, this is {@link OffsetScrollPosition#initial()} with a + * count of 20. + * @return a new {@link Builder} instance with all previously configured + * options and {@code Sort} applied + * @since 1.2 + */ + public ReactiveBuilder defaultScrollSubrange(@Nullable ScrollSubrange defaultSubrange) { + return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, defaultSubrange, this.sort, this.customizer); } /** @@ -579,7 +657,8 @@ public abstract class QuerydslDataFetcher { */ public ReactiveBuilder sortBy(Sort sort) { Assert.notNull(sort, "Sort must not be null"); - return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, sort, customizer); + return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, this.defaultSubrange, sort, this.customizer); } /** @@ -597,7 +676,8 @@ public abstract class QuerydslDataFetcher { */ public ReactiveBuilder customizer(QuerydslBinderCustomizer> customizer) { Assert.notNull(customizer, "QuerydslBinderCustomizer must not be null"); - return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, this.sort, customizer); + return new ReactiveBuilder<>(this.executor, this.domainType, this.resultType, + this.cursorStrategy, this.defaultSubrange, this.sort, customizer); } /** @@ -621,12 +701,12 @@ public abstract class QuerydslDataFetcher { * {@link org.springframework.data.domain.Window}. * @since 1.2 */ - public DataFetcher>> scrollable( - CursorStrategy cursorStrategy, ScrollSubrange defaultScrollSubrange) { - + public DataFetcher>> scrollable() { return new ReactiveScrollableEntityFetcher<>( this.executor, this.domainType, this.resultType, - cursorStrategy, defaultScrollSubrange, this.sort, this.customizer); + (this.cursorStrategy != null ? this.cursorStrategy : RepositoryUtils.defaultCursorStrategy()), + (this.defaultSubrange != null ? this.defaultSubrange : RepositoryUtils.defaultScrollSubrange()), + this.sort, this.customizer); } } diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/query/QuerydslDataFetcherTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/query/QuerydslDataFetcherTests.java index cd9896fd..b5eda1fc 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/query/QuerydslDataFetcherTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/query/QuerydslDataFetcherTests.java @@ -34,7 +34,6 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.OffsetScrollPosition; import org.springframework.data.keyvalue.core.KeyValueTemplate; import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactory; import org.springframework.data.map.MapKeyValueAdapter; @@ -157,8 +156,8 @@ class QuerydslDataFetcherTests { ScrollPositionCursorStrategy cursorStrategy = new ScrollPositionCursorStrategy(); - DataFetcher> dataFetcher = QuerydslDataFetcher.builder(mockRepository) - .scrollable(cursorStrategy, new ScrollSubrange(OffsetScrollPosition.initial(), 10, true)); + DataFetcher> dataFetcher = + QuerydslDataFetcher.builder(mockRepository).cursorStrategy(cursorStrategy).scrollable(); GraphQlSetup graphQlSetup = paginationSetup(cursorStrategy).queryFetcher("books", dataFetcher); tester.accept(graphQlSetup); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/QueryByExampleDataFetcherJpaTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/QueryByExampleDataFetcherJpaTests.java index 3277587f..79639930 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/QueryByExampleDataFetcherJpaTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/query/jpa/QueryByExampleDataFetcherJpaTests.java @@ -158,8 +158,8 @@ class QueryByExampleDataFetcherJpaTests { ScrollPositionCursorStrategy cursorStrategy = new ScrollPositionCursorStrategy(); - DataFetcher> dataFetcher = QueryByExampleDataFetcher.builder(repository) - .scrollable(cursorStrategy, new ScrollSubrange(OffsetScrollPosition.initial(), 10, true)); + DataFetcher> dataFetcher = + QueryByExampleDataFetcher.builder(repository).cursorStrategy(cursorStrategy).scrollable(); GraphQlSetup graphQlSetup = paginationSetup(cursorStrategy).queryFetcher("books", dataFetcher); tester.accept(graphQlSetup); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/QueryByExampleDataFetcherMongoDbTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/QueryByExampleDataFetcherMongoDbTests.java index 529595b7..dbbe24cf 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/QueryByExampleDataFetcherMongoDbTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/query/mongo/QueryByExampleDataFetcherMongoDbTests.java @@ -155,8 +155,8 @@ class QueryByExampleDataFetcherMongoDbTests { ScrollPositionCursorStrategy cursorStrategy = new ScrollPositionCursorStrategy(); - DataFetcher> dataFetcher = QueryByExampleDataFetcher.builder(repository) - .scrollable(cursorStrategy, new ScrollSubrange(OffsetScrollPosition.initial(), 10, true)); + DataFetcher> dataFetcher = + QueryByExampleDataFetcher.builder(repository).cursorStrategy(cursorStrategy).scrollable(); GraphQlSetup graphQlSetup = paginationSetup(cursorStrategy).queryFetcher("books", dataFetcher); tester.accept(graphQlSetup);