Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prev/next on edge #1133

Open
moonmeister opened this issue Jan 24, 2020 · 7 comments
Open

feat: prev/next on edge #1133

moonmeister opened this issue Jan 24, 2020 · 7 comments
Assignees
Labels
component: connections Relating to GraphQL Connections effort: high More than a week impact: med Minor performance improvements, fix broad user base issues needs: discussion Requires a discussion to proceed type: enhancement Improvements to existing functionality

Comments

@moonmeister
Copy link
Collaborator

I've seem other GraphQL APIs on CMSs provide prev and next connections on a node edge. This would be helpful in my case for creating page level navigation for next post and previous post. I've solved this in JS for now but it would be nice for these to be available in query. It would look something like:

query {
  posts {
    edges {
      next {
        #WpGraphql_Post
      }
      prev {
        #WpGraphql_Post
      }
      node {
        #WpGraphql_Post
       }
    }
  }
}
@jasonbahl
Copy link
Collaborator

@moonmeister I have a GIST that may apply here: https://gist.github.com/jasonbahl/55a6eff4cd67ce639ecd2d9989fef4cc

I've been thinking about adding support for this, but haven't landed on an ideal implementation. I plan on doing some work on Connections in an upcoming release, so this could be a good time to dive more into this.

@jasonbahl jasonbahl self-assigned this Jan 24, 2020
@jasonbahl jasonbahl added component: connections Relating to GraphQL Connections effort: high More than a week type: enhancement Improvements to existing functionality impact: med Minor performance improvements, fix broad user base issues needs: discussion Requires a discussion to proceed labels Jan 24, 2020
@drewbaker
Copy link

That gist is for older version of WP-GQL I think, this is an updated version that we use all the time: https://github.com/funkhaus/stackhaus-backend/blob/master/functions/gql-functions.php#L32-L146

@parkerproject
Copy link

@drewbaker am curious which file do you add that code in your gist?

@drewbaker
Copy link

In your themes functions.php file

@justlevine justlevine moved this to 🆕 New in WPGraphQL Issue Triage Jul 29, 2022
@justlevine justlevine moved this from 🆕 New to 📋 Backlog in WPGraphQL Issue Triage Jul 30, 2022
@stale
Copy link

stale bot commented Aug 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 3, 2022
@moonmeister moonmeister mentioned this issue Aug 25, 2022
@stale
Copy link

stale bot commented Sep 2, 2022

This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.

@stale stale bot closed this as completed Sep 2, 2022
Repository owner moved this from 📋 Backlog to ✅ Done in WPGraphQL Issue Triage Sep 2, 2022
@moonmeister moonmeister reopened this Sep 2, 2022
Repository owner moved this from ✅ Done to 🗺 Planned in WPGraphQL Issue Triage Sep 2, 2022
@stale stale bot removed the stale label Sep 2, 2022
@nireno
Copy link

nireno commented Oct 20, 2022

I'm hoping this can also apply to single post queries the way that WPGraphql Next-Previous Post allows:

query Post {
    post(id: 1, idType: DATABASE_ID) {
        title
        next {
            title
        }
        previous {
            title
        }
    }
}

Additionally, for my use case I need to paginate based on a post category/tag. So for a given post I'd like the next and prev post to behave is if it's only paginating across the set of posts tagged with foo for example.

@bhardie bhardie added the not stale Short-circuits stalebot. USE SPARINGLY label Dec 13, 2022
@justlevine justlevine removed the not stale Short-circuits stalebot. USE SPARINGLY label Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: connections Relating to GraphQL Connections effort: high More than a week impact: med Minor performance improvements, fix broad user base issues needs: discussion Requires a discussion to proceed type: enhancement Improvements to existing functionality
Projects
Status: 🗺 Planned
Development

No branches or pull requests

7 participants