fokot / caliban-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caliban example

This project serves as example of using Caliban.

Running

To run run sbt run and open [http://localhost:8000/graphiql]

To login use credentials

/-------------------\
| login  | password |
---------------------
| admin  |    a     |
| viewer |    v     |
\-------------------/

Authorization

Authorization is solved nicely in auth and GQL files

def book(args: BookInp): Z[Book] =
  isViewer *> ZIO.accessM[Env](_.storage.getBook(args.id).map(bookToGQL))

// when I will need the user
val myBooks: Z[List[Book]] =
  isAuthenticated >>= (u => ZIO.accessM[Env](_.storage.getBooksForUser(u).map(_.map(bookToGQL))))

More about Caliban you can read at my blog http://fokot.github.io/

P.S. If you have any improvement how to do things better leave me an issue or a PR.

About


Languages

Language:Scala 74.8%Language:HTML 25.2%