Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

Custom Error Handling #52

Closed timhuff closed 6 years ago

timhuff commented 6 years ago

This isn't really an issue with the project but I figured I'd let you guys know what I've done with my fork because I think it would add value here as well. I added an API called setErrorHandler. It's a very small change. This enables me to specify a global error handler for all queries (basically I replace the unexpected errors with new Error("An unexpected error has occurred").

https://github.com/timhuff/objection-graphql/commit/9507f9c0d55ef7236216a51c222e687dc8702ed5

As an aside, my project is not a large deviation from this one. There's no conflicts and it's backwards compatible. I've basically just augmented it with a few small functions. After working with it for a few months, I can confirm that they're extremely helpful. My original pull request was denied (thus the fork) due to a difference of opinion related to separation of concerns. I'd encourage you to consider merging, though, as I do feel that the changes I've made really brings the library to a new level. For example, I'm able to define all mutations and subscriptions inside the Objection model, itself. Organizationally, this is a pretty nice ability to have.