graphql/dataloader

[QUESTION] How should I paginate my data using DataLoader?

Open

#231 aberto em 5 de dez. de 2019

Ver no GitHub
 (20 comments) (8 reactions) (0 assignees)JavaScript (556 forks)batch import
help wanted

Métricas do repositório

Stars
 (12.520 stars)
Métricas de merge de PR
 (Mesclagem média 5d 2h) (1 fundiu PR em 30d)

Description

I have the following query:

{
  user(id: $id) {
    username
    comments(last: 10) { # How can I handle pagination here?
      id
      body
      author {
        username
      }
      replies(last: 3) { # How can I handle pagination here?
        id
        body
      }
    }
  }
}

How can I handle pagination in those cases? Should I use DataLoader?

Until now, everything that I found on the web suggests using the splice array method, but if I use it, my server will run out of memory, as I should paginate the data on the SQL query, am I right?

So how I am able to query my database with such GraphQL query? Do you handle those cases in any of your projects?

I am really struggling with that. It is even possible to use DataLoader in this case? And if I not use it, I my server will suffer a lot with the N+1 problem...

Guia do colaborador