Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
Release type: minor

Implement Relay-style cursor pagination for SQLAlchemy relationships by extending the connection resolver and DataLoader to accept pagination arguments, computing pageInfo metadata, and introducing cursor utilities. Add PaginatedLoader to scope DataLoader instances per pagination parameters and update tests to verify pagination behavior.

**New Features**:
- Support cursor-based pagination (first, after, last, before) on GraphQL relationship fields
- Introduce PaginatedLoader to manage DataLoader instances per pagination configuration

**Enhancements**:
- Extend connection resolvers to compute pageInfo fields (hasNextPage, hasPreviousPage, totalCount) and handle forward and backward pagination
- Add utilities for cursor encoding/decoding and relationship key extraction

**Tests**:
- Add comprehensive tests for forward and backward pagination scenarios in both synchronous and asynchronous execution contexts

**Examples**:

Get the first three books for a specific author:

```gql
query {
author(id: 1) {
id
name
books(first: 3) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```

Get all books after a specific book's cursor:

```gql
query($afterBook: String) {
author(id: 1) {
id
name
books(after: $afterBook) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```

Get the first three books for a specific author after a specific book's cursor:

```gql
query($afterBook: String) {
author(id: 1) {
id
name
books(first: 3, after: $afterBook) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```


Get the last three books for a specific author:

```gql
query {
author(id: 1) {
id
name
books(last: 3) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```

Get all books before a specific book's cursor:

```gql
query($beforeBook: String) {
author(id: 1) {
id
name
books(before: $beforeBook) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```

Get the last three books for a specific author before a specific book's cursor:

```gql
query($beforeBook: String) {
author(id: 1) {
id
name
books(last: 3, before: $beforeBook) {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
```
Loading
Loading