hayes / hayes/pothos

[Relay]: Expose resolveOffsetConnection into two functions

Open
#78 3 comments 0 reactions 0 assignees View on GitHub
needs-api-design question
Dominant language
TypeScript
Stars
2.6k
Forks
184
Avg merge
4h 25m
Merged PRs (30d)
137

Description

Another request!

Is there any way to break the resolveOffsetConnection function into two parts, or change the return type on the `resolveOffsetConnection` callback?

The reason is that I get the `totalCount` and `pageCursors` from one aggregated database call. But I can't make that database call without the offset and limit ... which means I have to manually replicate [the offsetForArgs function](https://github.com/hayes/giraphql/blob/7137675aa4ae69f44793cb384f35ebe61caef514/packages/plugin-relay/src/utils/connections.ts#L21) or roll my own. But then I have two offset/limit calculations which means that if they ever get out of sync, things will get dicey. Plus it just seems inefficient.

I tried returning the totalCount, etc. from the resolveOffsetConnection function but it's expecting an array of nodes, not extra connection info.

Contributor guide

Open the contributing guide

Research direction

Start with packages/plugin-relay/src/utils/connections.ts, especially offsetForArgs, and trace the resolveOffsetConnection callback mentioned in the issue. Determine how the offset and limit can be shared with aggregated connection metadata while preserving the existing node-array behavior; done means callers no longer need to duplicate offset/limit calculation.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.