You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: clayallsopp/graphqlhub@07fec4c#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)
Not really, it doesn't easily work out-of-the-box - I believe you have to write the logic which calculates the correct sliceStart accounting for whatever args are passed, which ends up duplicating logic from within connectionFromArraySlice
I ended up doing this, takes advantage of the fact that cursors are soley based on the offset and not whatever the array contains: https://github.com/clayallsopp/graphqlhub/pull/29/files; would be happy to open a PR to merge it into graphql-relay-js if its a thing that might be useful for others, but totally happen to just close this too
@clayallsopp have you figured out a clean way to deal with this?
I too have a similar case where it's easier for me to fetch exactly the data I need instead of fetching all the data and having the library trim the data after the fact. I think this is rather common (in my case, request a slice of the database collection instead of the entire thing)
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: clayallsopp/graphqlhub@07fec4c#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 currentconnectionFromPromisedArray
doesnt help in this regard, as you have to resolve the entire list and then it trims after-the-factI 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)
The text was updated successfully, but these errors were encountered: