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

Method QueryNoGrpc

edgraph/server.go:1359–1382  ·  view source on GitHub ↗

Query handles queries or mutations

(ctx context.Context, req *api.Request)

Source from the content-addressed store, hash-verified

1357
1358// Query handles queries or mutations
1359func (s *Server) QueryNoGrpc(ctx context.Context, req *api.Request) (*api.Response, error) {
1360 ctx = x.AttachJWTNamespace(ctx)
1361 if x.WorkerConfig.AclEnabled && req.GetStartTs() != 0 {
1362 // A fresh StartTs is assigned if it is 0.
1363 ns, err := x.ExtractNamespace(ctx)
1364 if err != nil {
1365 return nil, err
1366 }
1367 if req.GetHash() != getHash(ns, req.GetStartTs()) {
1368 return nil, x.ErrHashMismatch
1369 }
1370 }
1371 // Add a timeout for queries which don't have a deadline set. We don't want to
1372 // apply a timeout if it's a mutation, that's currently handled by flag
1373 // "txn-abort-after".
1374 if req.GetMutations() == nil && x.Config.QueryTimeout != 0 {
1375 if d, _ := ctx.Deadline(); d.IsZero() {
1376 var cancel context.CancelFunc
1377 ctx, cancel = context.WithTimeout(ctx, x.Config.QueryTimeout)
1378 defer cancel()
1379 }
1380 }
1381 return s.doQuery(ctx, &Request{req: req, doAuth: getAuthMode(ctx)})
1382}
1383
1384func (s *Server) QueryNoAuth(ctx context.Context, req *api.Request) (*api.Response, error) {
1385 return s.doQuery(ctx, &Request{req: req, doAuth: NoAuthorize})

Callers 4

QueryMethod · 0.95
GetGQLSchemaFunction · 0.80
queryHandlerFunction · 0.80
mutationHandlerFunction · 0.80

Calls 7

doQueryMethod · 0.95
AttachJWTNamespaceFunction · 0.92
ExtractNamespaceFunction · 0.92
getAuthModeFunction · 0.85
GetMutationsMethod · 0.80
getHashFunction · 0.70
GetStartTsMethod · 0.45

Tested by

no test coverage detected