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 limit the number of items of nested array? #306

Open
Damar225 opened this issue Feb 19, 2023 · 2 comments
Open

How to limit the number of items of nested array? #306

Damar225 opened this issue Feb 19, 2023 · 2 comments

Comments

@Damar225
Copy link

Damar225 commented Feb 19, 2023

Hello, I Have a query like this

`
query {
  doctors @rest(type: "doctors", path: "/doctors/") {
	  Result {
		  Id
		  FirstName
		  LastName
                  Items (limit: 10) {
                      id
                      title
                  }
            }
}
`

I want to get only 10 items from the Items, but I get the full list!

Is This doable or not?

Thank you.

@fbartho
Copy link
Collaborator

fbartho commented Feb 19, 2023

Short answer: no.

Your REST API always returns the full list, so the @rest annotation can’t magically change that. If it could, you’d still have a problem, because the backend would return the full list, let's say 10000 items, and then @rest would filter away 9990 items on the client side. Then you'd need some way to access the remaining items. @rest() is meant as a small escape hatch for a few APIs, or as a stepping stone while converting the Backend to GraphQL. It can't fix having the wrong backend API. Does that make sense?

@fbartho
Copy link
Collaborator

fbartho commented Feb 19, 2023

Obviously, you can always filter the results before displaying them — if this is just a “the UI doesn’t need more that 10 items here” sort of situation.

Apollo-link-rest just can’t invent the “limit” feature (there’s infinite other hypothetical features we could add there).

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

No branches or pull requests

2 participants