NestJS · Senior · Question 26 of 75
Why is it useful to have the same validation and authorization for HTTP, GraphQL and message handlers?
- 1Nest applies HTTP guards to messages automatically in all cases
- 2GraphQL and queues don't need validation
- ✓Correct answer: Each entry point is a door into the system; enforcing rules in shared services or context-aware guards avoids gaps
Explanation
Guards and pipes can be written to work with any ExecutionContext type, or rules can live in services.