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

How to sort / filter the posts #16

Closed
AntoninSlejska opened this issue Aug 6, 2019 · 2 comments
Closed

How to sort / filter the posts #16

AntoninSlejska opened this issue Aug 6, 2019 · 2 comments

Comments

@AntoninSlejska
Copy link

I have a simple request like this:

query {Posts{_id title date {published}}}

How can I sort the posts e.g. by publishing date and limit the number of posts? And how can I filter the posts, e.g. that I get only posts older than some date?

@guiguetz
Copy link

Hi! You should check out this link. I'm new to GraphQL and running onto the same issues, but they explain in a pretty simple way.

but basically your query should become something like

query {
  Posts(first: 10, offset: $cursor) {
    _id
    title
    date {
      published
    }
  }
}

Where you get $cursor controlled by your resolver indicating where should your pagination work.

@AntoninSlejska
Copy link
Author

Thanks Bruno!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants