@@ -34,5 +34,115 @@ amplify update api
34
34
amplify update auth
35
35
36
36
amplify update function
37
- ` `
37
+ ```
38
+
39
+ ### Updating / evolving the GraphQL schema
40
+
41
+ To update the schema, open the schema at * amplify/backend/api/jamstackcms* . Here is the base schema:
42
+
43
+ ``` graphql
44
+
45
+ type Post @model
46
+ @auth (
47
+ rules : [
48
+ { allow : groups , groups : ["Admin" ], operations : [create , update , delete ] },
49
+ { allow : private , operations : [read ] },
50
+ { allow : public , operations : [read ] }
51
+ ]
52
+ ) {
53
+ id : ID !
54
+ title : String !
55
+ description : String
56
+ content : String !
57
+ cover_image : String
58
+ createdAt : String
59
+ published : Boolean
60
+ previewEnabled : Boolean
61
+ categories : [String ]
62
+ author : User @connection
63
+ }
64
+
65
+ type Comment @model @auth (
66
+ rules : [
67
+ { allow : groups , groups : ["Admin" ], operations : [create , update , delete ] },
68
+ { allow : owner , ownerField : " createdBy" , operations : [create , update , delete ] }
69
+ ]
70
+ ) {
71
+ id : ID !
72
+ message : String !
73
+ createdBy : String
74
+ createdAt : String
75
+ }
76
+
77
+ type Settings @model @auth (rules : [
78
+ { allow : groups , groups : ["Admin" ] },
79
+ { allow : groups , groupsField : " adminGroups" },
80
+ { allow : public , operations : [read ] },
81
+ ]) {
82
+ id : ID !
83
+ categories : [String ]
84
+ adminGroups : [String ]
85
+ theme : String
86
+ border : String
87
+ borderWidth : Int
88
+ description : String
89
+ }
90
+
91
+ type Preview @model
92
+ @auth (
93
+ rules : [
94
+ { allow : groups , groups : ["Admin" ] },
95
+ { allow : private , operations : [read ] }
96
+ ]
97
+ ) {
98
+ id : ID !
99
+ title : String !
100
+ description : String
101
+ content : String !
102
+ cover_image : String
103
+ createdAt : String
104
+ categories : [String ]
105
+ }
106
+
107
+ type Page @model (subscriptions : null )
108
+ @auth (
109
+ rules : [
110
+ { allow : groups , groups : ["Admin" ] },
111
+ { allow : private , operations : [read ] },
112
+ { allow : public , operations : [read ] }
113
+ ]
114
+ )
115
+ {
116
+ id : ID !
117
+ name : String !
118
+ slug : String !
119
+ content : String !
120
+ components : String
121
+ published : Boolean
122
+ }
123
+
124
+ type User @model
125
+ @auth (rules : [
126
+ { allow : owner },
127
+ { allow : groups , groups : ["Admin" ]},
128
+ { allow : public , operations : [read ] }
129
+ ])
130
+ {
131
+ id : ID !
132
+ name : String
133
+ username : String
134
+ avatarUrl : String
135
+ }
136
+ ```
38
137
138
+ Once you 've made the updates , run the following command to test the new API :
139
+
140
+ ```sh
141
+ amplify mock
142
+ ```
143
+
144
+ Once you've tested the updates, run the following command to deploy the new API:
145
+
146
+ ``` sh
147
+ amplify push
148
+ ```
0 commit comments