@@ -8,7 +8,6 @@ import { AppStore } from '@/store/modules/app'
8
8
import classData from '@/types/store/classData'
9
9
import { API , Auth , graphqlOperation } from 'aws-amplify'
10
10
import { GRAPHQL_AUTH_MODE , GraphQLResult } from '@aws-amplify/api'
11
- import { getClass , listLessonsByClass } from '@/graphql/queries'
12
11
import {
13
12
createSchool ,
14
13
createClass ,
@@ -22,6 +21,60 @@ type LessonsGroupedBy = {
22
21
[ key : string ] : classData . LessonWithId [ ]
23
22
}
24
23
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
+
25
78
const VuexModule = createModule ( {
26
79
namespaced : 'classData' ,
27
80
strict : false ,
@@ -64,7 +117,7 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
64
117
@action
65
118
public async lessonsOnCurrentDate ( date : Date ) {
66
119
const lessons = ( await API . graphql ( {
67
- query : listLessonsByClass ,
120
+ query : listLessonsByClassSimple ,
68
121
variables : {
69
122
classId : this . classId ,
70
123
startTime : {
@@ -156,9 +209,10 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
156
209
157
210
@action
158
211
public async loadClassData ( classId : classData . ClassId ) {
159
- const result = ( await API . graphql (
160
- graphqlOperation ( getClass , { id : classId } )
161
- ) ) as GraphQLResult < GetClassQuery >
212
+ const result = ( await API . graphql ( {
213
+ query : getClassSimple ,
214
+ variables : { id : classId } ,
215
+ } ) ) as GraphQLResult < GetClassQuery >
162
216
163
217
const classObject = result ?. data ?. getClass
164
218
if ( ! classObject ) {
@@ -188,11 +242,10 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
188
242
do {
189
243
classId = generateUniqueId ( )
190
244
try {
191
- const result = ( await API . graphql (
192
- graphqlOperation ( getClass , {
193
- id : classId ,
194
- } )
195
- ) ) as GraphQLResult < GetClassQuery >
245
+ const result = ( await API . graphql ( {
246
+ query : getClassSimple ,
247
+ variables : { id : classId } ,
248
+ } ) ) as GraphQLResult < GetClassQuery >
196
249
classObject = result ?. data ?. getClass
197
250
} catch {
198
251
throw new Error ( 'エラーによって処理に失敗しました' )
0 commit comments