File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
src/main/java/graphql/annotations/connection Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 2020import java .util .ArrayList ;
2121import java .util .List ;
2222
23+ /**
24+ * Use this class in {@link GraphQLConnection} to do a real pagination,
25+ * i.e you fetch each time the relevant data, you make the cursors and
26+ * you decide if there are previous or next pages
27+ *
28+ * Note: If you are using the connection, the relevant dataFetcher must implements {@link PaginationDataFetcher}
29+ * @param <T> the entity type that is paginated
30+ */
2331public class EnhancedConnectionFetcher <T > implements ConnectionFetcher <Connection <T >> {
2432
2533 private PaginationDataFetcher <T > paginationDataFetcher ;
Original file line number Diff line number Diff line change 1818
1919import java .util .List ;
2020
21+ /**
22+ * When use connection with {@link EnhancedConnectionFetcher}, the dataFetcher
23+ * must implements this interface
24+ * @param <T> the type of the entity that is fetched
25+ */
2126public interface PaginationDataFetcher <T > extends DataFetcher <List <T >> {
2227
28+ /**
29+ * decides whether this is the last page
30+ * @param lastCursor the cursor of the last entity that was fetched
31+ * @return true if there is a next page, o.w false
32+ */
2333 boolean hasNextPage (String lastCursor );
2434
35+ /**
36+ * decides whether this is the first page
37+ * @param firstCursor the cursor of the first entity that was fetched
38+ * @return true if there is a previous page, o.w false
39+ */
2540 boolean hasPreviousPage (String firstCursor );
2641
42+ /**
43+ * get the cursor of the entity. This method is called when the edges are built.
44+ * This method is called for every entity that was fetched
45+ * @param entity the fetched entity (one of them)
46+ * @return the cursor of the entity
47+ */
2748 String getCursor (T entity );
2849}
You can’t perform that action at this time.
0 commit comments