Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adds traditional offset pagination support to WPGraphQL

NotificationsYou must be signed in to change notification settings

valu-digital/wp-graphql-offset-pagination

Repository files navigation

Adds traditional offset pagination support to WPGraphQL. This is useful onlywhen you need to implement:

  • Numbered links to the "pages"
  • Ordering with custom SQL
    • Read thetutorial
    • You should read it even if don't plan to use this plugin as it teachesyou a lot about WPGraphQL internals!

You should not use this plugin if you can avoid it. The cursors in thewp-graphql core are faster and more efficient although this plugin should performcomparatively to a traditional WordPress pagination implementation.

This plugin implements offset pagination for post object (build-in and customones), content nodes and user connections. This means there's no WooCommerce for examplebut checkoutthis issue if you are interested in one.

PRs welcome for term connections. SeeCONTRIBUTING.md.

Usage

queryPosts {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 forcontentNodes andusers.

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/pluginsgit clone --branch stable https://github.com/valu-digital/wp-graphql-offset-pagination.git

Prior Art

This a reimplementation ofdarylldoyle/wp-graphql-offset-pagination byDaryll Doyle. The API is bit different but this one has unit&integrationtests and support for latest WPGraphQL.

About

Adds traditional offset pagination support to WPGraphQL

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp