zio / zio-quill

Compile-time Language Integrated Queries for Scala
https://zio.dev/zio-quill
Apache License 2.0
2.16k stars 348 forks source link

GraphQL support #19

Open fwbrasil opened 8 years ago

fwbrasil commented 8 years ago

schema

case class User(id: Int, name: String, username: String, age: Int, friends: List[User])

target query

{
  user(id: 1) {
    name
    age
    friends {
      name
    }
  }
}

Option 1 - Translate collection-like queries to GraphQL

val q = quote {
  (id: Int) => query[User].filter(_.id == id).map { user => 
    (user.name, user.age, user.friends.map(_.name))
  }
}

Option 2 - Create a new DSL similar to the target lang

val q = quote {
  (id: Int) =>
    query[User](_.id -> id)(
      _.name,
      _.age,
      _.friends(
        _.name
      )
    )
}

I'm leaning toward the first option.

nemccarthy commented 6 years ago

+1