facebook / facebook/relay

Return cursor on mutation's payload issue

Open
#2,377 2 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

This is a follow-up to this issue: https://github.com/facebook/relay/issues/2337

I also have the same problem. I dont think this is server implementation specific but, more on the side of the architecture of Relay-GraphQL. Say for example I"m doing 2 steps:

1. Fetch a list of records for my Paginated Container with a filter {name: 'blah'}. This essentially would be a sub-list of the bigger list depending on the filter. So say the total record in the DB is 100 but, with the filter, you only return 20 records, the cursor would be based on 20 records.

2. Subsequently I send a create record mutation and I want to get the cursor (so I can add the record to my Paginated Connection on the client). My mutation payload would need the cursor in this case and if I had to generate it with say offsetToCursor.

I do not know what the original filter (from step #1 is). So essentially I'd have to do offsetToCursor(collection.find({}).length), which would be wrong because, this would return 101 and not 21.

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.