parseMutationBlock parses the mutation block
(it *lex.ItemIterator)
| 144 | |
| 145 | // parseMutationBlock parses the mutation block |
| 146 | func parseMutationBlock(it *lex.ItemIterator) (*api.Mutation, error) { |
| 147 | var mu api.Mutation |
| 148 | |
| 149 | item := it.Item() |
| 150 | if item.Typ != itemLeftCurl { |
| 151 | return nil, it.Errorf("Expected { at the start of block. Got: [%s]", item.Val) |
| 152 | } |
| 153 | |
| 154 | for it.Next() { |
| 155 | item := it.Item() |
| 156 | if item.Typ == itemText { |
| 157 | continue |
| 158 | } |
| 159 | if item.Typ == itemRightCurl { |
| 160 | return &mu, nil |
| 161 | } |
| 162 | if item.Typ == itemMutationOp { |
| 163 | if err := parseMutationOp(it, item.Val, &mu); err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | return nil, it.Errorf("Invalid mutation.") |
| 169 | } |
| 170 | |
| 171 | // parseMutationOp parses and stores set or delete operation string in Mutation. |
| 172 | func parseMutationOp(it *lex.ItemIterator, op string, mu *api.Mutation) error { |
no test coverage detected