An Android application that shows the user random demotivational quotes fetched from the Demotivational Quotes GraphQL API.
The application follows the Model, View, ViewModel (MVVM) software architectural pattern. With the following file and directory structure:
📦app
┣ ..
┣ 📂src
┃ ┣ 📂main
┃ ┃ ┣ 📂graphql
┃ ┃ ┃ ┣ 📂queries
┃ ┃ ┃ ┃ ┗ 📜quotes.graphql
┃ ┃ ┃ ┗ 📜schema.graphqls
┃ ┃ ┣ 📂java
┃ ┃ ┃ ┗ 📂com.example.demotivate
┃ ┃ ┃ ┣ 📂graphql
┃ ┃ ┃ ┃ ┗ 📜Apollo.kt
┃ ┃ ┃ ┣ 📂view
┃ ┃ ┃ ┃ ┗ 📜MainActivity.kt
┃ ┃ ┃ ┗ 📂viewmodel
┃ ┃ ┃ ┗ 📜QuotesViewModel.kt
┃ ┃ ┗ ..
┃ ┣ ..
┗ ..
- Given a GraphQL schema and query definition, the Apollo Kotlin plugin defines a Gradle task named
generateApolloSources
to generate the models
- Fetches all quotes via Apollo client and sends them to the ViewModel
- Controls the application's display of the quotes and interaction with the user through the button
- Triggers and subscribes to the ViewModel's
LiveData
updates
- Updates the
MutableLiveData
with a random quote