Skip to content

Commit 0c96e06

Browse files
committed
Added javadocs
1 parent b52ae1f commit 0c96e06

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/main/java/graphql/annotations/connection/EnhancedConnectionFetcher.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
import java.util.ArrayList;
2121
import 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+
*/
2331
public class EnhancedConnectionFetcher<T> implements ConnectionFetcher<Connection<T>> {
2432

2533
private PaginationDataFetcher<T> paginationDataFetcher;

src/main/java/graphql/annotations/connection/PaginationDataFetcher.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,32 @@
1818

1919
import 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+
*/
2126
public 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
}

0 commit comments

Comments
 (0)