( ctx context.Context, mutation schema.Mutation)
| 209 | } |
| 210 | |
| 211 | func (mr *dgraphResolver) rewriteAndExecute( |
| 212 | ctx context.Context, |
| 213 | mutation schema.Mutation) (*Resolved, bool) { |
| 214 | var mutResp, qryResp *dgoapi.Response |
| 215 | req := &dgoapi.Request{} |
| 216 | commit := false |
| 217 | |
| 218 | defer func() { |
| 219 | if !commit && mutResp != nil && mutResp.Txn != nil { |
| 220 | mutResp.Txn.Aborted = true |
| 221 | _, err := mr.executor.CommitOrAbort(ctx, mutResp.Txn) |
| 222 | if err != nil { |
| 223 | glog.Errorf("Error occurred while aborting transaction: %s", err) |
| 224 | } |
| 225 | } |
| 226 | }() |
| 227 | |
| 228 | dgraphPreMutationQueryDuration := &schema.LabeledOffsetDuration{Label: "preMutationQuery"} |
| 229 | dgraphMutationDuration := &schema.LabeledOffsetDuration{Label: "mutation"} |
| 230 | dgraphPostMutationQueryDuration := &schema.LabeledOffsetDuration{Label: "query"} |
| 231 | ext := &schema.Extensions{ |
| 232 | Tracing: &schema.Trace{ |
| 233 | Execution: &schema.ExecutionTrace{ |
| 234 | Resolvers: []*schema.ResolverTrace{ |
| 235 | { |
| 236 | Dgraph: []*schema.LabeledOffsetDuration{ |
| 237 | dgraphPreMutationQueryDuration, |
| 238 | dgraphMutationDuration, |
| 239 | dgraphPostMutationQueryDuration, |
| 240 | }, |
| 241 | }, |
| 242 | }, |
| 243 | }, |
| 244 | }, |
| 245 | } |
| 246 | |
| 247 | emptyResult := func(err error) *Resolved { |
| 248 | return &Resolved{ |
| 249 | // all the standard mutations are nullable objects, so Data should pretty-much be |
| 250 | // {"mutAlias":null} everytime. |
| 251 | Data: mutation.NullResponse(), |
| 252 | Field: mutation, |
| 253 | // there is no completion down the pipeline, so error's path should be prepended with |
| 254 | // mutation's alias before returning the response. |
| 255 | Err: schema.PrependPath(err, mutation.ResponseName()), |
| 256 | Extensions: ext, |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // upserts stores rewritten []*UpsertMutation by Rewrite function. These mutations |
| 261 | // are then executed and the results processed and returned. |
| 262 | var upserts []*UpsertMutation |
| 263 | var err error |
| 264 | // queries stores rewritten []*dql.GraphQuery by RewriteQueries function. These queries |
| 265 | // are then executed and the results are processed |
| 266 | var queries []*dql.GraphQuery |
| 267 | var filterTypes []string |
| 268 | queries, filterTypes, err = mr.mutationRewriter.RewriteQueries(ctx, mutation) |
no test coverage detected