AndersDJohnson / AndersDJohnson/fetch-paginate

feat: support graphql with pages/cursors

未關閉
#19 0 則留言 0 個 reaction 已指派 1 人 已被 @AndersDJohnson 認領 在 GitHub 檢視
enhancement hacktoberfest help wanted
主要語言
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。