Problem with saving edge in same direction

Hello guys, I have an issue. I need to save part of the graph in another db.

I have this view of the data:

[
  {
	"uid": "0xb",
	"dgraph.type": [
	  "Device"
	],
	"Name": "Device"
	"~is_parent_of": [
	{
		"uid": "0xd",
		"dgraph.type": [
		"Device"
		],
		"Name": "ChildDevice",
	}]
  }
]

No problems when I loading this data by query, but when I try to save there is problem with ~is_parent_of closely with ~. Is there a possibility to save data with edges in same directions?

Not sure what you mean by this, and also the context of the other DB.

If you wanna remove the tilde sign. Just use an alias.
see Aliases - Query language

Thank you for replay. I have connection from A to B, when I loaded data it is connected correctly. When I try to save this data, it connection as B to A (if sign ~ would be removed, without ~ it would give an error). Different direction of Nodes. The main problem that queries with recursion etc would not work correctly

Sorry, but I don’t get it.

Save this data how?

What kind of error and where?

Can you share examples?

Trying to save those objects =>

[
  {
	"uid": "1",
	"Name": "Parent",
	"~is_parent_of": [
	{
		"uid": "2",
		"Name": "Child",
		"~is_parent_of": [
		{
			"uid": "3",
			"Name": "ChildChild",
		}]
	}]
  }
]

Obtaining this error =>

Grpc.Core.RpcException: 'Status(StatusCode="Unknown", Detail="key error: subject:"13" predicate:"~is_parent_of" object_id:"123" : predicate "~is_parent_of": Has invalid characters")'

ChildChild has edge to Child
Child has edge to Parent

This is how it saving in code

using (var transaction = client.NewTransaction()) {
  var result = await transaction.Mutate(setJson: database, commitNow: true);
  if (result.IsSuccess) {
        return true;
  } else {
      throw new Exception(result.Reasons[0].Message);
  }
}
It is c#.

Problem with tilda, if I saving edges without tilda it is working. But edge directions goes backward.
Like from Parent to Child instead of from Child to Parent
from Child to ChildChild instead of from ChildChild to Child.

Try to write your mutation in reverse, so you don’t need to use the reverse edge (~). Something like that:

[
  {
	"uid": "2",
	"Name": "Child",
	"is_parent_of": [
	{
		"uid": "1",
		"Name": "Parent",
	}]
  }
]

instead of

[
  {
	"uid": "1",
	"Name": "Parent",
	"~is_parent_of": [
	{
		"uid": "2",
		"Name": "Child",
	}]
  }
]

Well, are you trying to mutate this JSON object as it is? And you expect that the reverse direction to be obtained? Well, that’s not how it works if it is what I see.

Change the order of your objects

[
   {
      "uid": "3",
      "Name": "ChildChild ",
      "is_parent_of": [
         {
            "uid": "2",
            "Name": "Child",
            "is_parent_of": [
               {
                  "uid": "1",
                  "Name": "Parent"
               }
            ]
         }
      ]
   }
]

Or do this

[
   {
      "uid": "_:1",
      "Name": "Parent"
   },
   {
      "uid": "_:2",
      "Name": "Child",
      "is_parent_of": [
         {
            "uid": "_:1"
         }
      ]
   },
   {
      "uid": "_:3",
      "Name": "ChildChild ",
      "is_parent_of": [
         {
            "uid": "_:2"
         }
      ]
   }
]

Also, avoid using the UID key. Use it only if you know the UID exists or with a Blank Node.