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

Function GetTypes

worker/schema.go:238–261  ·  view source on GitHub ↗

GetTypes processes the type requests and retrieves the desired types.

(ctx context.Context, req *pb.SchemaRequest)

Source from the content-addressed store, hash-verified

236
237// GetTypes processes the type requests and retrieves the desired types.
238func GetTypes(ctx context.Context, req *pb.SchemaRequest) ([]*pb.TypeUpdate, error) {
239 if len(req.Types) == 0 && len(req.Predicates) > 0 {
240 return nil, nil
241 }
242
243 var typeNames []string
244 var out []*pb.TypeUpdate
245
246 if len(req.Types) == 0 {
247 typeNames = schema.State().Types()
248 } else {
249 typeNames = req.Types
250 }
251
252 for _, name := range typeNames {
253 typeUpdate, found := schema.State().GetType(name)
254 if !found {
255 continue
256 }
257 out = append(out, proto.Clone(&typeUpdate).(*pb.TypeUpdate))
258 }
259
260 return out, nil
261}

Callers 2

ProcessMethod · 0.92
TestEmptyTypeSchemaFunction · 0.85

Calls 3

StateFunction · 0.92
TypesMethod · 0.80
GetTypeMethod · 0.45

Tested by 1

TestEmptyTypeSchemaFunction · 0.68