InterviewBuddy
All interview questions

Where should authorization happen in a GraphQL API?

Intermediate

Answer

Enforce authorization in the server's business or data-access layer for every protected object and action, including nested fields.

Explanation

Checking only the top-level query can leave alternate access paths exposed.

Example

Both user.orders and order(id:) must enforce the same ownership rules.