11

Describing Errors in GraphQL

As developers, we know that errors are an inevitable part of building any application. Luckily, GraphQL provides us with powerful tools to handle them gracefully. By defining errors using GraphQL types and following established conventions, we can enhance the reliability and schema consumer experience of our GraphQL APIs.

In this chapter, we will explore the essential concepts and best practices for effectively describing errors in GraphQL. We will start by understanding how we throw errors, before learning how to specify errors with enums, and fully describe them with union-based responses. By the end of the chapter, we will learn why we need to mask all errors eventually and whitelist only those wanted by the ...

Get GraphQL Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.