2
Answers

Error Handling in GraphQL

Hi,

How to handle errors in GraphQL ?

Thanks in advance.

Answers (2)

0
Photo of Jay Krishna Reddy
14 53.3k 5.4m 3y

A successful GraphQL query is supposed to return a JSON object with a root field called "data". If the request fails or partially fails (e.g. because the user requesting the data doesn’t have the right access permissions), a second root field called "errors" is added to the response:

  1. {  
  2.       "data": { ... },  
  3.       "errors": [ ... ]  
  4.     }  
Accepted
0
Photo of Salman Beg
152 12.1k 623.2k 3y
See this link help you, https://blog.logrocket.com/handling-graphql-errors-like-a-champ-with-unions-and-interfaces/ https://itnext.io/the-definitive-guide-to-handling-graphql-errors-e0c58b52b5e1