Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

How would I return a list of objects with total records #356

Closed
ChrisJokinen opened this issue May 4, 2021 · 1 comment
Closed

How would I return a list of objects with total records #356

ChrisJokinen opened this issue May 4, 2021 · 1 comment

Comments

@ChrisJokinen
Copy link

ChrisJokinen commented May 4, 2021

Lets say I have a list of records I can return based on some value. And there are so many records I want to paginate over them. But the front end wants to make a nice navigation of page 1, 2, etc...

If I design a schema like this

type Orders{
  id: ID
  user_id: Int
  date: String
  ...
}

and I have a query like

userOrders(user_id: Int!, limit: Int, offset:: Int): [Orders]

I would like to return a result like

{
  data: {
    userOrders: [
        { id:1,user_id:1,date:"2021-04-01",...},
        { id:2,user_id:1,date:"2021-04-11",...},
        ...
    ]
  },
  total: 124
}

is there a way to do this, or would I need to modify my type to include a "total" field?

@hugovk
Copy link
Contributor

hugovk commented Mar 3, 2023

Thanks for the report, however we're going to archive this repo soon as we're no longer maintaining it: #359

@hugovk hugovk closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants