No-object type (eg. int, bool, float) becomes an ` Object` type

I defined the schema and go structure as follows:

const DNODE_SCHEMA = `
	name: string @index(exact) .
	downstream: [uid] @reverse @count .
	deployment: string @index(exact) .
	count_l4: int .
	count_l7: int .
	sum_latency_ms: float .
	since: datetime .
	active: bool .
	reserve: bool .
	type: string .
	type Pod {
type Pod struct {
	Uid  string `json:"uid,omitempty"`
	Name string `json:"name,omitempty"`
	DownStream []Pod  `json:"downstream,omitempty"`
	Deployment string `json:"deployment,omitempty"` 
	CountL4      int       `json:"downstream|count_l4,omitempty"`   
	CountL7      int       `json:"downstream|count_l7,omitempty"`    
	SumLatencyMs float64   `json:"downstream|sum_latency_ms,omitempty"` 
	Since        time.Time `json:"downstream|since,omitempty"`        
	Active       bool      `json:"downstream|active,omitempty"` 
	Reserve      bool      `json:"downstream|reserve,omitempty"`    

But when I query the nodes recursively, some facets become of type Object:

# query
  pod(func: has(name)) @recurse(depth: 10)  {
   downstream @facets 
# result
        "uid": "0xc6",
        "name": "carts-77c79d8f5c-tn4dn",
        "downstream": [
            "uid": "0xc1",
            "name": "orders-b54f99dcf-n2pqj",
            "downstream|active": {
              "0": true
            "downstream|reserve": true,
            "downstream|count_l7": {
              "1": 1,
              "2": 1,
              "3": 1,
              "4": 1
            "uid": "0xc9",
            "downstream|since": "2022-09-14T13:42:01.235293866Z",
            "downstream|active": {
              "3": true
            "downstream|sum_latency_ms": 154.48845


Why do these non-object types become object types, and what do the keys (eg. β€œ1”, β€œ2”, β€œ4”) in them mean?

How can I avoid this situation and keep the original type when querying recursively?

Other Information

The information on each edge is re-written many times.

When a facet is written, both nodes of an edge may be the starting point.

The edges are all bidirectional, , and it looks like this:


1 Like

I wonder if your rewrites are actually rewriting and not just concatenating.

This lead me to the above notion. I wonder if the keys indicate the version of the value. 2 should have overwritten 1 but instead now you have 1 and 2, just a theory.

Can you post your mutations? I haven’t actually used facets, but if my above theory is correct, then the problem might be how you are mutating your facets.

1 Like

Thank you for your attention to this issue.

This is the relevant code that I write facets as follow:

edge := model.Pod{
		Uid: upUID,  //  //  a uid of a node (already created), like "0xc1"
		DownStream: []model.Pod{
				Uid:          downUID,  //  a uid of a node (already created), like "0xc2"
				CountL4:      info.CountL4,  // these fields are not directly associated with existing facets, I just want to replace the existing facets with these new fields
				CountL7:      info.CountL7,
				SumLatencyMs: info.SumLatencyMs,
				Since:        info.Since,
				Active:       info.Active,
				Reserve:      info.TwoWay,

	err := dg.UpdateNode(edge)

And the UpdateNode() as follow:

func (dg *DGO) UpdateNode(pod model.Pod) error {
	mu := &api.Mutation{
		CommitNow: true,
	pb, err := json.Marshal(pod)
	if err != nil {
		dg.Logger.Error("error marshal pod")
		return err

	mu.SetJson = pb
	_, err = dg.DClient.NewTxn().Mutate(context.Background(), mu)
	if err != nil {
		dg.Logger.Error("error mutate update pod node")
		return err

	return nil
1 Like