How to add custom error code like 404, 401, 400 with gqlgen + gin?
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
Current resolver do not have gin context that means and method only returns err
### What did you expect?
Want to have custom error code like `ctx.JSON(http.StatusNotFound, responseBody)` but gqlgen only handles it by returning array of error, is there any way to solve this?
Contributor guide
Research direction
The issue is about integrating gqlgen with Gin to return custom HTTP status codes like 404 or 401. Look at gqlgen's error handling and how it interfaces with HTTP handlers. Check the gqlgen documentation and source code for error extensions or middleware. Examine how to wrap or extend the GraphQL response to include HTTP status codes, possibly using a custom error presenter or hooking into Gin's context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100