code4romania / teacher-workout-android

Teacher Workout Android app
Mozilla Public License 2.0
5 stars 17 forks source link

Connect home and discover screens to the backend #48

Open daniyelp opened 2 years ago

daniyelp commented 2 years ago

What does it fix?

Resolves #38.

As a quick sum-up, I imported the GraphQL schema, created the repository to fetch the lessons and the lesson themes and updated the screens to the new model classes (*interfaces) created by Apollo. It might not be ready for merging yet, because there were some things that got me confused / I wasn't quite sure of:

alexandru-calinoiu commented 2 years ago

Good point with the nullable id's, opened a issue with the backend https://github.com/code4romania/teacher-workout-backend/issues/74

alexandru-calinoiu commented 2 years ago

There is a small discussion that needs to happen here,

The fact that data and model are hosted in the commons/ui module does not look right, even name wise :)

The usual approach I see in the wild is for this model and data projects / modules to be shared in the entire app and host all repos / mappers and models of the app. There are a couple of issues that this approach has that I will try to very briefly summarize:

alexandru-calinoiu commented 2 years ago

I've made a POC with a proposed approach to data access https://github.com/code4romania/teacher-workout-android/pull/50

Please take a look and let me know what you think.

daniyelp commented 2 years ago

Good points at first. At the moment, I'm really caught into something and I'll try to take a deeper look into the PR Monday or Tuesday.

daniyelp commented 2 years ago

@alexandru-calinoiu As I said in the other PR, what I did doesn't seem like the the way to go. It's too much of a REST approach :dizzy_face:. So I think that we should close this PR. But regarding the last question I've asked, how would we fetch all the data needed for the home screen in one go?

alexandru-calinoiu commented 2 years ago

@daniyelp one can write a query similar to this one to fetch all the data

query {
  lessonStatuses(lessonIds: ["1"]) {
    currentLessonStep {
      id

      ... on SlideStep {
        __typename
        title
        description
      }
      ... on ExerciseStep {
        __typename
      }
    }
  }
  themes {
    edges {
      node {
        id
        title
        thumbnail {
          url
        }
      }
    }
  }
}

But I think we need to open a ticket with the backend so that the lessonStatuses query will bring all lesson statuses for the current user.