Skip to content

Instantly share code, notes, and snippets.

@jpshelley
Created September 28, 2016 23:10
Show Gist options
  • Save jpshelley/4893a19250a8e82d038b9466cdd306e1 to your computer and use it in GitHub Desktop.
Save jpshelley/4893a19250a8e82d038b9466cdd306e1 to your computer and use it in GitHub Desktop.
gql-annotation-viewmodel
query Hero {
hero {
name,
isJedi
}
}
class MyViewModel {
var heroNameText: String = getHero().name
var showIsJediImage: Boolean? = getHero().isJedi
@GraphQL(queryDocument = hero_query.graphql)
fun getHero(): Hero {
// . . . MyViewModelGQL could be the generated code after the annotation processor runs
// . . . The property "hero" is created based on the graphql file, and a getter is created.
// . . . Unsure where the actual GraphQL call is made to get the response, but this is just a rought draft.
return MyViewModelGQL.getHero()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment