This repository contains code samples that demonstrate various error handling techniques in GraphQL using Hot Chocolate
To get started with this repository, simply clone or download the source code and run the samples using Visual Studio or any other IDE that supports .NET Core or using dotnet CLI.
You can read in detail about the different approaches in Error Handling in GraphQL With Hot Chocolate
The repository contains the following code samples:
-
The top level error list approach in GraphQL involves returning an array of error objects as part of the top-level response. This approach is useful for handling multiple errors that occur during a single request. Clients can check the array for errors and take appropriate action, such as displaying an error message to the user or retrying the request.
-
The error union approach in GraphQL is a concise and expressive way of representing errors for queries, eliminating the need for a top-level error list and allowing clients to easily handle and display errors. Custom error types can provide specific details about the error to help users address the issue more effectively.
-
Support for multiple errors and easier evolution. It keeps resolver code clean of error handling and ensures consistent and effective error handling, but can result in verbose schema due to the number of types involved.
Contributions to this repository are welcome. If you have any suggestions, bug reports, or feature requests, please feel free to open an issue or submit a pull request.
This repository is licensed under the MIT License. See the LICENSE file for more information.