valu/wp-graphql-offset-pagination
Composer 安装命令:
composer require valu/wp-graphql-offset-pagination
包简介
Add offset pagination to wp-graphql
README 文档
README
Adds traditional offset pagination support to WPGraphQL. This is useful only when you need to implement:
- Numbered links to the "pages"
- Ordering with custom SQL
- Read the tutorial
- You should read it even if don't plan to use this plugin as it teaches you a lot about WPGraphQL internals!
You should not use this plugin if you can avoid it. The cursors in the wp-graphql core are faster and more efficient although this plugin should perform comparatively to a traditional WordPress pagination implementation.
This plugin implements offset pagination for post object (build-in and custom ones), content nodes and user connections. This means there's no WooCommerce for example but checkout this issue if you are interested in one.
PRs welcome for term connections. See CONTRIBUTING.md.
Usage
query Posts { posts(where: { offsetPagination: { size: 10, offset: 10 } }) { pageInfo { offsetPagination { # Boolean whether there are more nodes in this connection. # Eg. you can increment offset to get more nodes. # Use this to implement "fetch more" buttons etc. hasMore # True when there are previous nodes # Eg. you can decrement offset to get previous nodes. hasPrevious # Get the total node count in the connection. Using this # field activates total calculations which will make your # queries slower. Use with caution. total } } nodes { title } } }
The where argument is the same for contentNodes and users.
Installation
Use must have WPGraphQL v0.8.4 or later installed.
If you use composer you can install it from Packagist
composer require valu/wp-graphql-offset-pagination
Otherwise you can clone it from Github to your plugins using the stable branch
cd wp-content/plugins
git clone --branch stable https://github.com/valu-digital/wp-graphql-offset-pagination.git
Prior Art
This a reimplementation of darylldoyle/wp-graphql-offset-pagination by Daryll Doyle. The API is bit different but this one has unit&integration tests and support for latest WPGraphQL.
valu/wp-graphql-offset-pagination 适用场景与选型建议
valu/wp-graphql-offset-pagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 95.41k 次下载、GitHub Stars 达 84, 最近一次更新时间为 2020 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 valu/wp-graphql-offset-pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 valu/wp-graphql-offset-pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 95.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 84
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2020-01-29