127127 {
128128 "PostSecret.title": "ps1",
129129 "dgraph.type": [
130- "PostSecret"
130+ "PostSecret"
131131 ],
132132 "uid": "_:PostSecret4"
133133 }
136136 {
137137 "PostSecret.title": "ps2",
138138 "dgraph.type": [
139- "PostSecret"
139+ "PostSecret"
140140 ],
141141 "uid": "_:PostSecret7"
142142 }
145145 {
146146 "PostSecret.title": "ps3",
147147 "dgraph.type": [
148- "PostSecret"
148+ "PostSecret"
149149 ],
150150 "uid": "_:PostSecret10"
151151 }
154154 {
155155 "PostSecret.title": "ps4",
156156 "dgraph.type": [
157- "PostSecret"
157+ "PostSecret"
158158 ],
159159 "uid": "_:PostSecret13"
160160 }
163163 {
164164 "PostSecret.title": "ps5",
165165 "dgraph.type": [
166- "PostSecret"
166+ "PostSecret"
167167 ],
168168 "uid": "_:PostSecret16"
169169 }
172172 {
173173 "PostSecret.title": "ps6",
174174 "dgraph.type": [
175- "PostSecret"
175+ "PostSecret"
176176 ],
177177 "uid": "_:PostSecret19"
178178 }
181181 {
182182 "PostSecret.title": "ps7",
183183 "dgraph.type": [
184- "PostSecret"
184+ "PostSecret"
185185 ],
186186 "uid": "_:PostSecret22"
187187 }
190190 {
191191 "PostSecret.title": "ps8",
192192 "dgraph.type": [
193- "PostSecret"
193+ "PostSecret"
194194 ],
195195 "uid": "_:PostSecret25"
196196 }
392392 name : " Add Multiple Mutations with embedded value"
393393 gqlmutation : |
394394 mutation addAuthor {
395- addAuthor(input: [{ name: "A.N. Author", posts: []},
395+ addAuthor(input: [{ name: "A.N. Author", posts: []},
396396 { name: "Different Author", posts: []}]) {
397397 author {
398398 name
15641564# Additional Deletes
15651565#
15661566# If we have
1567- #
1567+ #
15681568# type Post { ... author: Author @hasInverse(field: posts) ... }
15691569# type Author { ... posts: [Post] ... }
15701570#
15711571# and existing edge
1572- #
1572+ #
15731573# Post1 --- author --> Author1
1574- #
1574+ #
15751575# there must also exist edge
1576- #
1576+ #
15771577# Author1 --- posts --> Post1
15781578#
1579- # So if we did an add Author2 and connect the author to Post1, that changes the
1579+ # So if we did an add Author2 and connect the author to Post1, that changes the
15801580# author of Post1 to Author2, we need to
15811581# * add edge Post1 --- author --> Author2 (done by asIDReference/asXIDReference)
15821582# * add edge Author2 --- posts --> Post1 (done by addInverseLink)
15971597 }
15981598 }
15991599 gqlvariables : |
1600- {
1600+ {
16011601 "auth": {
16021602 "name": "A.N. Author",
16031603 "posts": [ { "postID": "0x456" } ]
16041604 }
16051605 }
16061606 dgmutations :
16071607 - setjson : |
1608- {
1608+ {
16091609 "uid":"_:Author1",
16101610 "dgraph.type":["Author"],
16111611 "Author.name":"A.N. Author",
20602060 code
20612061 name
20622062 cities {
2063- name
2063+ name
20642064 district {
20652065 code
20662066 name
20712071 }
20722072 }
20732073 gqlvariables : |
2074- {
2074+ {
20752075 "city": {
20762076 "name": "c1",
20772077 "district":{
21502150 }
21512151 }
21522152 gqlvariables : |
2153- {
2153+ {
21542154 "auth": {
21552155 "name": "A.N. Author",
2156- "country": {
2156+ "country": {
21572157 "name": "A Country",
21582158 "states": [ { "code": "abc", "name": "Alphabet" } ]
21592159 }
21732173
21742174 dgmutationssec :
21752175 - setjson : |
2176- {
2176+ {
21772177 "uid":"_:Author1",
21782178 "dgraph.type":["Author"],
21792179 "Author.name":"A.N. Author",
22142214 }
22152215 }
22162216
2217+ - name : " Deep mutation three level xid"
2218+ gqlmutation : |
2219+ mutation($auth: AddPost1Input!) {
2220+ addPost1(input: [$auth]) {
2221+ post1 {
2222+ id
2223+ comments {
2224+ id
2225+ replies {
2226+ id
2227+ }
2228+ }
2229+ }
2230+ }
2231+ }
2232+
2233+ gqlvariables : |
2234+ {
2235+ "auth": {
2236+ "id": "post1",
2237+ "comments": [{
2238+ "id": "comment1",
2239+ "replies": [{
2240+ "id": "reply1"
2241+ }]
2242+ }]
2243+ }
2244+ }
2245+ dgquery : |-
2246+ query {
2247+ Comment14 as Comment14(func: eq(Comment1.id, "comment1")) @filter(type(Comment1)) {
2248+ uid
2249+ }
2250+ Comment16 as Comment16(func: eq(Comment1.id, "reply1")) @filter(type(Comment1)) {
2251+ uid
2252+ }
2253+ }
2254+ dgmutations :
2255+ - setjson : |
2256+ {
2257+ "Comment1.id": "comment1",
2258+ "dgraph.type": [
2259+ "Comment1"
2260+ ],
2261+ "uid": "_:Comment14"
2262+ }
2263+ cond: "@if(eq(len(Comment14), 0))"
2264+ - setjson : |
2265+ {
2266+ "Comment1.id": "reply1",
2267+ "dgraph.type": [
2268+ "Comment1"
2269+ ],
2270+ "uid": "_:Comment16"
2271+ }
2272+ cond: "@if(eq(len(Comment16), 0) AND eq(len(Comment14), 0))"
2273+ - setjson : |
2274+ {"uid":"_:Comment14", "Comment1.replies": [{"uid": "uid(Comment16)"}]}
2275+ cond: "@if(eq(len(Comment16), 1) AND eq(len(Comment14), 0))"
2276+ - setjson : |
2277+ {"uid":"_:Comment14", "Comment1.replies": [{"uid": "_:Comment16"}]}
2278+ cond: "@if(eq(len(Comment16), 0) AND eq(len(Comment14), 0))"
2279+ - setjson : |
2280+ {"uid":"uid(Comment16)"}
2281+ cond: "@if(eq(len(Comment16), 1) AND eq(len(Comment14), 0))"
2282+ dgquerysec : |-
2283+ query {
2284+ Post12 as Post12(func: eq(Post1.id, "post1")) @filter(type(Post1)) {
2285+ uid
2286+ }
2287+ Comment14 as Comment14(func: eq(Comment1.id, "comment1")) @filter(type(Comment1)) {
2288+ uid
2289+ }
2290+ }
2291+ dgmutationssec :
2292+ - setjson : |
2293+ {
2294+ "Post1.comments":
2295+ [{
2296+ "uid":"uid(Comment14)"
2297+ }],
2298+ "Post1.id":"post1",
2299+ "dgraph.type":["Post1"],
2300+ "uid":"_:Post12"
2301+ }
2302+ cond: "@if(eq(len(Post12), 0) AND eq(len(Comment14), 1))"
2303+
22172304 -
22182305 name : " Add mutation error on @id field for empty value"
22192306 gqlmutation : |
22582345 }
22592346 explanation : " The add mutation should not be allowed since value of @id field is empty."
22602347 error :
2261- { "message": "failed to rewrite mutation payload because encountered an empty value for @id field `State.code`" }
2348+ { "message": "failed to rewrite mutation payload because encountered an empty value for @id field `State.code`" }
0 commit comments