facebook / facebook/relay

Unable to handle connection being root level field in schema object when doing RANGE_DELETE

Open
#2,708 4 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

https://github.com/facebook/relay/blob/f6f6723849c1b7dbd7b72a4a0f6fd18a521f8d44/packages/relay-runtime/mutations/RelayDeclarativeMutationConfig.js#L344

So this line, and the logic built around it, prevents from deleting a node in a connection, where the connection is a root field in the parent.
Assume I have a schema as follows:
```
Tag {
tag_id: Int
text: String
}

Todo {
todo_id: Int
text: String
tags: [Tag]
}

TodoList {
todos: [Todo]
}
```

As of now, to delete a single todo, the `pathToConnection`, from parent to connection, is just `["todos"]`. I understand that when modifying a todo by deleting a subconnection inside the todo, such as `tags`, the `pathToConnection` would be `["todos", "tags"]`. But building logic without the first situation in mind leads me to be forced to provide this as the `pathToConnection: ["todos", ""]`. Am I misunderstanding how I should structure my schema?

Contributor guide

Open the contributing guide

Research direction

Start in packages/relay-runtime/mutations/RelayDeclarativeMutationConfig.js around line 344 and trace RANGE_DELETE handling for pathToConnection values. Reproduce the root-level todos case and the nested todos/tags case from the issue schema; done means root-level connections work without an empty path segment while nested connections retain their behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.