MCPcopy
hub / github.com/dgraph-io/dgraph / Execute

Method Execute

graphql/dgraph/execute.go:25–53  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
25func (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
56func (dg *DgraphEx) CommitOrAbort(ctx context.Context,

Callers

nothing calls this directly

Calls 6

SpanTimerFunction · 0.92
IsGqlErrorListFunction · 0.92
GQLWrapfFunction · 0.92
InfofMethod · 0.80
QueryGraphQLMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected