AndersDJohnson / AndersDJohnson/fetch-paginate
feat: support graphql with pages/cursors
- 主要語言
- TypeScript
- 星號
- 27
- 分支
- 3
- 平均合併
- 1 分鐘
- 30 天內合併 PR
- 2
描述
We could consider some kind of support for GraphQL and deeply nested page values or cursors.
A shorthand inline query syntax with template literal interpolation using last call's response:
```ts
fetchPaginate('https://graphql.example.com', {
graphql: (previous) => `
query someQuery {
products(page: ${previous?.data?.products?.nextPage || 1}) {
id
nextPage
}
}
`
})
```
Or, using a static query but dynamically re-defining variables for each paged call:
```ts
const query = `
query someQuery($page: Int = 1, $type: String) {
products(page: $page, type: $type) {
id
nextPage
}
}
`;
fetchPaginate('https://graphql.example.com', {
graphql: {
query,
variables: (previous) => ({
type: 'blog',
page: previous?.data?.products?.nextPage
})
}
})
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。