pretender91 / workout-tracker

0 stars 0 forks source link

Add authentication and auth scopes to application #3

Closed pretender91 closed 1 year ago

pretender91 commented 1 year ago

As a developer I want to invoke queries and mutations based on auth scope (guest, user, admin etc). Also I should have mutation to give auth token that grants me access to proper auth scope.

pretender91 commented 1 year ago

After some research there are some theses:

Preferable scopes:

As I understand we can put scopes in several places:

I think we should put scopes as close as possible to root. Namespaces are preferable. Something like this:

enum Role {
    GUEST
    USER
    ADMIN
}

type Viewer {
    role: Role!
}

type Query {
    viewer: Viewer!
    guest: GuestQuery
    user: UserQuery
    admin: AdminQuery
}

type Mutation {
    guest: GuestMutation
    user: UserMutation
    admin: AdminMutation
}