facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.27k stars 1.8k forks source link

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

Open vinibgoulart opened 4 months ago

vinibgoulart commented 4 months ago

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
    }
  }