My team is using the Apollo client for Ember. We a...
# orm-help
s
My team is using the Apollo client for Ember. We are trying to figure out a better pattern for making paginated queries. (Hope this is a good place to ask!) Currently we have a service that queries a paginated list of Type Cases. Cases are the leaf nodes of a heavily nested query (part of a complicated business object). Currently my team is using 3 methods to manage 1 paginated endpoint: 1. queryCases for making the initial watchQuery call (returns a query reference) 2. loadMoreCases to call fetchMore and updateQuery (returns a query reference) 3. getNodes helper function to return the actual nodes. I believe the model using the service shouldn’t have to know the structure of the graphql query. This feels like an inefficient implementation/not really great developer experience. Are there better pattern suggestions?
a
Hey! in your generated file (with prissa) you have 2 queries:
users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]!
and
usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection!
with the second one, you have everything to create your own pagination in
pageInfo
you have an example here: https://github.com/alan345/naperg