<template>
  <module :module="module"></module>
</template>

<script>
  import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
  import ASSIGNMENTS_QUERY from '@/graphql/gql/assignmentsQuery.gql';

  import Module from '@/components/modules/Module.vue';

  export default {
    components: {
      Module
    },

    apollo: {
      module() {
        return {
          query: MODULE_DETAILS_QUERY,
          variables: {
            slug: this.$route.params.slug
          },
          update(data) {
            const cleanedData = this.$getRidOfEdges(data);
            return cleanedData.module || {};
          }
        }
      },
      assignments: {
        query: ASSIGNMENTS_QUERY
      }
    },

    data() {
      return {
        module: {},
        assignments: []
      }
    }
  }
</script>
