ChilliCream / ChilliCream/graphql-platform
Please add sufficent error handling example with HTTP status codes to documentation
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Is your feature request related to a problem?
In the current state of docs, it's unclear how the HTTP status interceptor determines the status code related to exception/returned data value in the resolver.
If you want to implement the 6a pattern and return 200 OK every time a "known" error occurs (for example validation issue), you have to do one of these things:
a) always return nullable! (otherwise, you'll get 500)
b) try-catch the exception -> report exception with resolverCtx.ReportError(...) -> return data/null.
Some people (including myself) don't automatically implement nullable return values, which results in non-sense 500 errors. This behavior of the HotChocolate pipeline should be documented in docs.
Note
This also affects errors related to authentication, if - for example - I return user data that are C# record (non-nullable by nature) and the user isn't authorized, it shoots out 500 HTTP code. When you make the user data record nullable, you get 200 HTTP code. (correct behavior, but this 'authorize' attribute should be namely documented because normally you don't even have to return null in resolver).
The solution you'd like
Add HotChocolate HTTP status code and error behavior in docs.
Product
Hot Chocolate
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Hot Chocolate documentation covering HTTP status codes, error handling, interceptors, and resolver nullability. Document the described validation and authorization cases, including how nullable and non-nullable resolver results affect the returned status code; done means the behavior and recommended patterns are clear to readers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100