0

We are following the optimistic ui pattern (http://dev.apollodata.com/react/optimistic-ui.html) with the apollo graphql client. Is there a way to handle the actual result from the server? For example, if the server did error on the mutation, we would like to notify the user. Is there a place to get the real result of the mutation?

tgogos
  • 23,218
  • 20
  • 96
  • 128
Mark
  • 4,446
  • 5
  • 26
  • 34

1 Answers1

0

The mutation returns a Promise. So you can handle the result from the server using than and catch.

If you are using the update functionality of the mutation definition you could use the catch to handle a server error. To get the error as object you could use errorResponse = JSON.parse(JSON.stringify(mutationError))

Locco0_0
  • 3,420
  • 5
  • 30
  • 42
  • I don't think mutation responses are catchable anymore. The responses from a failed mutation will still comeback as success(200) but the data object from the resolved promise will have an error stored in data.error – Kenny Hammerlund Sep 20 '18 at 20:12