Execute is the underlying dgraph implementation of Dgraph execution. If field is nil, returned response has JSON in DQL form, otherwise it will be in GraphQL form.
(ctx context.Context, req *dgoapi.Request, field schema.Field)
| 23 | // Execute is the underlying dgraph implementation of Dgraph execution. |
| 24 | // If field is nil, returned response has JSON in DQL form, otherwise it will be in GraphQL form. |
| 25 | func (dg *DgraphEx) Execute(ctx context.Context, req *dgoapi.Request, |
| 26 | field schema.Field) (*dgoapi.Response, error) { |
| 27 | |
| 28 | span := trace.FromContext(ctx) |
| 29 | stop := x.SpanTimer(span, "dgraph.Execute") |
| 30 | defer stop() |
| 31 | |
| 32 | if req == nil || (req.Query == "" && len(req.Mutations) == 0) { |
| 33 | return nil, nil |
| 34 | } |
| 35 | |
| 36 | if glog.V(3) { |
| 37 | muts := make([]string, len(req.Mutations)) |
| 38 | for i, m := range req.Mutations { |
| 39 | muts[i] = m.String() |
| 40 | } |
| 41 | |
| 42 | glog.Infof("Executing Dgraph request; with\nQuery: \n%s\nMutations:%s", |
| 43 | req.Query, strings.Join(muts, "\n")) |
| 44 | } |
| 45 | |
| 46 | ctx = context.WithValue(ctx, edgraph.IsGraphql, true) |
| 47 | resp, err := (&edgraph.Server{}).QueryGraphQL(ctx, req, field) |
| 48 | if !x.IsGqlErrorList(err) { |
| 49 | err = schema.GQLWrapf(err, "Dgraph execution failed") |
| 50 | } |
| 51 | |
| 52 | return resp, err |
| 53 | } |
| 54 | |
| 55 | // CommitOrAbort is the underlying dgraph implementation for committing a Dgraph transaction |
| 56 | func (dg *DgraphEx) CommitOrAbort(ctx context.Context, |
nothing calls this directly
no test coverage detected