Skip to content
Modern webserver in Haskell: Graphql + Postgresql + Authentication + DB migration + Dotenv and more
Haskell PLpgSQL
Branch: master
Clone or download

README.md

Modern Haskell Webserver Boilerplate

  • Graphql API
      type User {
          id: Int!
          email: String!
          name: String!
          updatedAt: String!
          createdAt: String!
      }
    
      type Session {
          token: String!
          user: User!
      }
    
      type Query {
          login(email: String!, password: String!): Session!
          myUserInfo: User!
      }
    
      type Mutation {
          register(email: String!, password: String!, name: String!): Session!
          changePassword(oldPassword: String!, newPassword: String!): Boolean!
      }
  • Database:

This boilerplate wires up:

  • Reading .env using envy
  • Database
  • Graphql API
    • login(email: String, password: String) { token user { id } }
    • register(email: String, password: String, name: String) { token user { id } }
  • Authorization using JWT
  • Monad transformers

Running

  • Feed in you database & secret in .env:
    $ cp .env.default .env
    
    DATABASE_URL="postgres://Dandoh:dandoh@127.0.0.1:5432/webhaskell?sslmode=disable"
    JWT_SECRET="my_jwt_secret"
    
  • Migrations
    $ dbmate up
    
  • Run webserver
    $ stack run
    
You can’t perform that action at this time.