@@ -8,7 +8,6 @@ import { AppStore } from '@/store/modules/app'
88import classData from '@/types/store/classData'
99import { API , Auth , graphqlOperation } from 'aws-amplify'
1010import { GRAPHQL_AUTH_MODE , GraphQLResult } from '@aws-amplify/api'
11- import { getClass , listLessonsByClass } from '@/graphql/queries'
1211import {
1312 createSchool ,
1413 createClass ,
@@ -22,6 +21,60 @@ type LessonsGroupedBy = {
2221 [ key : string ] : classData . LessonWithId [ ]
2322}
2423
24+ const getClassSimple = /* GraphQL */ `
25+ query GetClass($id: ID!) {
26+ getClass(id: $id) {
27+ id
28+ className
29+ }
30+ }
31+ `
32+
33+ const listLessonsByClassSimple = /* GraphQL */ `
34+ query ListLessonsByClass(
35+ $classId: ID
36+ $startTime: ModelStringKeyConditionInput
37+ $sortDirection: ModelSortDirection
38+ $filter: ModelLessonFilterInput
39+ $limit: Int
40+ $nextToken: String
41+ ) {
42+ listLessonsByClass(
43+ classId: $classId
44+ startTime: $startTime
45+ sortDirection: $sortDirection
46+ filter: $filter
47+ limit: $limit
48+ nextToken: $nextToken
49+ ) {
50+ items {
51+ id
52+ startTime
53+ endTime
54+ title
55+ subject {
56+ name
57+ color
58+ }
59+ goal
60+ description
61+ videos {
62+ title
63+ url
64+ thumbnailUrl
65+ }
66+ pages
67+ materials {
68+ title
69+ url
70+ }
71+ isHidden
72+ }
73+ nextToken
74+ }
75+ }
76+ `
77+
2578const VuexModule = createModule ( {
2679 namespaced : 'classData' ,
2780 strict : false ,
@@ -42,17 +95,24 @@ const generateUniqueId = (): string => {
4295 return result + ''
4396}
4497// Generate a new Date object with a specified date & time
45- const d = ( date : Date , hours : number , minutes : number , seconds : number ) => {
98+ const d = (
99+ date : Date ,
100+ hours : number ,
101+ minutes : number ,
102+ seconds : number ,
103+ milliseconds : number
104+ ) => {
46105 const newDate = new Date ( date )
47106 newDate . setHours ( hours )
48107 newDate . setMinutes ( minutes )
49108 newDate . setSeconds ( seconds )
109+ newDate . setMilliseconds ( milliseconds )
50110 return newDate
51111}
52112
53113const getFullDayArray = ( date : Date ) => {
54- const start = d ( date , 0 , 0 , 0 )
55- const end = d ( date , 24 , 0 , 0 )
114+ const start = d ( date , 0 , 0 , 0 , 0 )
115+ const end = d ( date , 24 , 0 , 0 , 0 )
56116 return [ start , end ]
57117}
58118
@@ -64,7 +124,7 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
64124 @action
65125 public async lessonsOnCurrentDate ( date : Date ) {
66126 const lessons = ( await API . graphql ( {
67- query : listLessonsByClass ,
127+ query : listLessonsByClassSimple ,
68128 variables : {
69129 classId : this . classId ,
70130 startTime : {
@@ -156,9 +216,10 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
156216
157217 @action
158218 public async loadClassData ( classId : classData . ClassId ) {
159- const result = ( await API . graphql (
160- graphqlOperation ( getClass , { id : classId } )
161- ) ) as GraphQLResult < GetClassQuery >
219+ const result = ( await API . graphql ( {
220+ query : getClassSimple ,
221+ variables : { id : classId } ,
222+ } ) ) as GraphQLResult < GetClassQuery >
162223
163224 const classObject = result ?. data ?. getClass
164225 if ( ! classObject ) {
@@ -188,11 +249,10 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
188249 do {
189250 classId = generateUniqueId ( )
190251 try {
191- const result = ( await API . graphql (
192- graphqlOperation ( getClass , {
193- id : classId ,
194- } )
195- ) ) as GraphQLResult < GetClassQuery >
252+ const result = ( await API . graphql ( {
253+ query : getClassSimple ,
254+ variables : { id : classId } ,
255+ } ) ) as GraphQLResult < GetClassQuery >
196256 classObject = result ?. data ?. getClass
197257 } catch {
198258 throw new Error ( 'エラーによって処理に失敗しました' )
0 commit comments