Skip to content

Support pagination return values and pagination requests in @SchemaMapping methods #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #103
rstoyanchev opened this issue Feb 22, 2023 · 3 comments
Closed
Tracked by #103
Assignees
Labels
in: data Issues related to working with data type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

When a controller method returns Page we should adapt that to graphql.relay.Connection. Likewise, we should support Pageable as a controller method argument, initialized from GraphQL input arguments.

As part of that we'll need a strategy to encode and decode a cursor. This includes indicating sort order, even if the relay spec does not specify how to do that.

@rstoyanchev rstoyanchev added type: enhancement A general enhancement in: data Issues related to working with data labels Feb 22, 2023
@rstoyanchev rstoyanchev added this to the 1.2.0-M1 milestone Feb 22, 2023
@rstoyanchev rstoyanchev self-assigned this Feb 22, 2023
@rstoyanchev rstoyanchev changed the title Support Page as return type and Pageable as input argument Support Page return type and Pageable input argument in @SchemaMapping methods Feb 22, 2023
@mladenjotanovichtec
Copy link

Hi @rstoyanchev, based on our previous discussion for Pageable and @SortDefaults, it would be
really great that we can annotate Pageable method argument with that annotation and that specified
values are injected into Pageable instance. I am referring to Pageable resolver and support for Sort resolver.

Also, I would like to contribute for the first time in the project so this could be the place for that, what are your thoughts?

@rstoyanchev rstoyanchev changed the title Support Page return type and Pageable input argument in @SchemaMapping methods Support pagination return values and request input for @SchemaMapping methods Mar 17, 2023
@rstoyanchev
Copy link
Contributor Author

We have worked with the Spring Data team to enable support for keyset and offset based scrolling through a result set, see spring-projects/spring-data-commons#2787. Now that it is available in snapshots, we've been able to both provide feedback to the Spring Data team, and to use the new API for GraphQL pagination.

The main new concepts are Window and ScrollPosition, see "Scrolling" for an introduction. We will provide support for Window and Slice as a return value from from any DataFetcher, and adapting it to graphql.relay.Connection. We'll also support ScrollPosition as a cursor for pagination, and allow injecting the ScrollPosition, number of elements requested, and sort information into a controller method.

@rstoyanchev
Copy link
Contributor Author

rstoyanchev commented Mar 17, 2023

@mladenjotanovichtec, apologies for the slow response, and thanks for the offer to help! As per my previous comment, Spring Data support has added new features for pagination, and we have evolved our plans accordingly. At the moment we are a bit too close to M1, and busy wrapping up, but there will be plenty of opportunities to contribute. We'll make an effort to call them out, but feel free to reach out as well. In the mean time we really do appreciate feedback on the new and existing features.

@rstoyanchev rstoyanchev changed the title Support pagination return values and request input for @SchemaMapping methods Support pagination return values and pagination requests in @SchemaMapping methods Mar 17, 2023
rstoyanchev added a commit that referenced this issue Mar 17, 2023
ConnectionTypeVisitor to decorate DataFetchers for Connection fields
in order to adapt Window, Slice, and others to Connection.

A ScrollRequest controller method argument to inject the ScrollPosition
and the number of elements requested.

SortStrategy for an application to customize how to extract sort
details from GraphQL arguments.

See gh-620
rstoyanchev added a commit that referenced this issue Mar 17, 2023
rstoyanchev added a commit that referenced this issue Mar 17, 2023
rstoyanchev added a commit that referenced this issue Mar 19, 2023
...to Subrange and ScrollSubrange

See gh-620
rstoyanchev added a commit that referenced this issue Mar 19, 2023
For a completely generic SortStrategy we can't provide any concrete
support we know neither the input structure nor the Object structure.
At best, a nearly empty argument resolver, which is not any better
than providing your own custom argument resolver.

Hence, SortStrategy is now explicitly based on Spring Data's Sort,
which enables us to provide concrete support with a base class.

See gh-620
rstoyanchev added a commit that referenced this issue Mar 20, 2023
rstoyanchev added a commit that referenced this issue Mar 20, 2023
rstoyanchev added a commit that referenced this issue Mar 20, 2023
rstoyanchev added a commit that referenced this issue Mar 21, 2023
rstoyanchev added a commit that referenced this issue Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues related to working with data type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants