-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.graphql
87 lines (81 loc) · 2.68 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
type Section @model @auth(rules: [
{ allow: private, operations: [read]},
{ allow: groups, groups: ["Admins", "Instructors"]},
{ allow: owner, ownerField: "owner", operations: [create, update, delete, read] },
{ allow: public, operations: [read]}
]) {
id: ID!
name: String
owner: String
description: String
code: String!
assignments: [Assignment] @hasMany(indexName: "bySection", fields: ["id"])
}
type Assignment @model @auth(rules: [
{ allow: private, operations: [read]},
# { allow: groups, groupsField: "learner", operations: [read]},
# { allow: owner, ownerField: "owner", operations: [create, update, delete, read] },
{ allow: groups, groups: ["Instructors", "Admins"], operations: [create, update, delete, read] },
{ allow: public, operations: [read]}
]) {
id: ID!
due: AWSDateTime
learner: String
# owner: String
sectionID: ID @index(name: "bySection")
grades: [Grade] @hasMany(indexName: "byAssignment", fields: ["id"])
unitID: ID @index(name: "byUnit")
}
type Grade @model @auth(rules: [
# { allow: groups, groupsField: "instructor", operations: [read]}
{ allow: owner, ownerField: "owner", operations: [create, read]},
{ allow: groups, groups: ["Admins"], operations: [read]}
]) {
id: ID!
percentComplete: Float
accuracy: Float
complete: Boolean
owner: String
instructor: String
unitVersion: Int
data: AWSJSON
# unitID: ID @index(name: "byUnit")
assignmentID: ID @index(name: "byAssignment")
}
type Unit @model @auth(rules: [
{ allow: private, operations: [read]},
{ allow: groups, groups: ["Admins", "Instructors"]},
# { allow: groups, groupsField: "learner", operations: [read]}
# { allow: owner, ownerField: "owner", operations: [create, update, delete, read] },
{ allow: public, operations: [read]}])
{
id: ID!
number: Float
name: String
# learner: String
# owner: String
description: String
data: AWSJSON
publish: Boolean
# audioFiles: [String]
# videoFiles: [String]
# imageFiles: [String]
# urls: [String]
assignments: [Assignment] @hasMany(indexName: "byUnit", fields: ["id"])
words: [Word] @manyToMany(relationName: "UnitWord")
# grades: [Grade] @hasMany(indexName: "byUnit", fields: ["id"])
}
type Word @model @auth(rules: [
{ allow: private, operations: [read]},
{ allow: groups, groups: ["Instructors", "Admins"]},
# { allow: owner, ownerField: "owner", operations: [create, update, delete, read] },
{ allow: public, operations: [read]}]) {
id: ID!
phrase: String
# owner: String
phonetic: String
definition: String
audio: [String]
units: [Unit] @manyToMany(relationName: "UnitWord")
}
# https://docs.amplify.aws/cli/graphql/authorization-rules/#per-user--owner-based-data-access.