facebook / facebook/relay

Why does receiving a null node break the execution of the mutation in @appendNode?

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

Description

Why does receiving a null node break the execution of the mutation? Would it be possible to just not update this node and close it but complete the mutation?

When I receive a null node in return of my mutation, I receive the following error: "MutationHandlers: Expected target node to exist."

https://github.com/facebook/relay/blob/ee03182fa05430690f3b33dfff5d3426e49fd8dc/packages/relay-runtime/handlers/connection/MutationHandlers.js#L195

```
mutation StockCreateMutation(
$input: StockCreateInput!
$connections: [ID!]!
) {
StockCreate(input: $input) {
stock @appendNode(connections: $connections, edgeTypeName: "StockEdge") {
id
type
quantity
createdAt
createdBy {
id
name
}
product {
id
name
stock
}
}
error
success
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start in packages/relay-runtime/handlers/connection/MutationHandlers.js around line 195 and trace the @appendNode handling for a null returned node. Reproduce the StockCreateMutation with stock returning null, then verify the mutation completes without the “Expected target node to exist” error while leaving the connection unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript, react
Domain
api, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.