graphql / graphql/graphql-relay-js

Better support for async connections

Open
#80 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
177
Avg merge
10m
Merged PRs (30d)
1

Description

Hey, a pretty common situation is that getting the list of connected IDs is cheap (i.e. the list of the IDs of your friends), but resolving each ID is expensive.

Specifically for this kind of use case: https://github.com/clayallsopp/graphqlhub/pull/28/commits/07fec4c728cbf55b321bcdcdf3741c53944230d2#diff-6cd9d3d473d2f9b30b961ebfb3d3f048R50 - I have the entire list of IDs in memory, so if the query specifies `first: 5` or provides a cursor, it would be great to reduce the set of IDs we're resolving before we resolve them. the current `connectionFromPromisedArray` doesnt help in this regard, as you have to resolve the entire list and then it trims after-the-fact

I think something like this API would be very helpful in general - I think it's possible? (assuming you have the entire list of IDs in memory and cursors are pure functions of offset and IDs)

```
let connectionIds = item.kids;
return promisedConnectionFromIdsArray(connectionIds, args, (trimmedIds) => {
return Promise.all(trimmedIds.map(getItem));
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.