I have an application which has an admin interface which is restricted to users with the admin role in addition to a public app which includes anonymous and registered users.
I could approach this in two ways:
The more traditional unified API e.g.
api.posts.create (restricted by admin check)
api.posts.getById, { includeDraft: true}) // if includeDraft is true restrict to admins so public users can't see draft posts
or alternatively completely separate APIs:
api.admin.posts.create
api.admin.posts.getById // includes draft posts
api.public.posts.getById // excludes draft posts
The tradeoff of the separate APIs is that its more boilerplate in terms of having multiple endpoints that might have a degree of overlapping functionality. The benefit is that its clearer and access control can be easily enforced by wrapping all admin namespaced functions with ctx wrappers e.g. adminQuery, adminMutation.
I'm curious if their has been any discussion around patterns like these and recommendations or real life examples.