Q22: What are custom Schema Directives and what are common use-cases?
Custom directives (prefixed with @) attach custom behavior or metadata to schema locations (fields, objects, arguments).
Common use-cases:
- Authentication/Authorization (
@auth(role: ADMIN)) - Input formatting (
@upperCase,@trim) - Deprecation markings or rate-limiting metadata
Key Takeaways
- Directives add declarative, reusable middleware logic directly to schema declarations.
Knowledge Check
Where can custom directives be attached in GraphQL?