Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL for defining interfaces #71

Open
jeggy opened this issue Jan 14, 2020 · 0 comments
Open

DSL for defining interfaces #71

jeggy opened this issue Jan 14, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@jeggy
Copy link
Member

jeggy commented Jan 14, 2020

It would be nice to be able to define interface properties that are not actually part of the Kotlin interface.

Idea being something like this:

interface MyInterface
data class MyDataClass(val id: Int): MyInterface
...
interface<MyInterface> {
  property<String>("field1") // No default implementation and will run into runtime schema creation error if not implement in all types that implement this interface
  property<String>("field2") { // This property has a default implementation, but can be overwritten within implemented types
    resolver { a: MyInterface ->
      "FIELD-2"
    }
  }
}
type<MyDataClass> {
  property<String>("field1") {
    resolver { data: MyDataClass ->
      "FIELD-${data.id}"
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant