Dgraph live loader using JSON files reverse edges

Hi

We are testing a data load process using dgraph live loader and JSON format files.

We can see that reverse edges are not being updated automatically.

After loading, we can see attachments links from items, but not items connections from attachment.

We had the same issue using DQL with dgraph-js client, so we had to set explicity the reverse edges.

Do we need to do the same ? Adding the items connections to the attachment file ?

We are updating the schema always using GraphQL and making use of @hasInverse directive.

Is there any way that dgraph live loader and DQL mutations to set the reverse edges automatically as when using GraphQL API ?

Attachment JSON file:

[
    {
        "Attachment.url": "https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vneck-tee-2.jpg",
        "Attachment.description": "V-Neck T-Shirt",
	...
        "dgraph.type": "Attachment",
        "uid": "_:ATTACHMENT_HTTPS://WOOCOMMERCECORE.MYSTAGINGWEBSITE.COM/WP-CONTENT/UPLOADS/2017/12/VNECK-TEE-2.JPG"
    },
    ...
]

Item JSON file:

[
    {
        "Item.itemNo": "abc-vneck-tee",
        "Item.title": "V-Neck T-Shirt",
        "Item.description": "V-Neck T-Shirt",
        "Item.keywords": "t-shirt, cotton",
        "Item.brand": "ABC",
        "Item.upc": "72527273070",
        "Item.attributeValues": [
            {
                "uid": "_:ATTRIBUTEVALUE_VERY LOW"
            },
            {
                "uid": "_:ATTRIBUTEVALUE_R"
            }
        ],
        "Item.attachments": [
            {
                "uid": "_:ATTACHMENT_HTTPS://WOOCOMMERCECORE.MYSTAGINGWEBSITE.COM/WP-CONTENT/UPLOADS/2017/12/VNECK-TEE-2.JPG"
            },
            {
                "uid": "_:ATTACHMENT_HTTPS://WOOCOMMERCECORE.MYSTAGINGWEBSITE.COM/WP-CONTENT/UPLOADS/2017/12/VNECH-TEE-GREEN-1.JPG"
            },
            {
                "uid": "_:ATTACHMENT_HTTPS://WOOCOMMERCECORE.MYSTAGINGWEBSITE.COM/WP-CONTENT/UPLOADS/2017/12/VNECH-TEE-BLUE-1.JPG"
            }
        ],
        ...
   }
]

GraphQL schema:


type Attachment {
  id: ID!
  url: String! @search(by: [term])
  uploadDatetime: DateTime @search
  description: String @search(by: [term])
  ...
  # Item
  items: [Item] @hasInverse(field: "attachments")
  ...
}

type Item {
  id: ID!
  uuid: String
  # Code
  itemNo: String! @search(by:[trigram])
  ...

  # A list of attachments of an item
  attachments: [Attachment] @hasInverse(field: "items")
  ...
}

Pay attention that hasInverse and reverse aren’t the same things. They are completely different things. You can try to mix them, but I think it will be hard to maintain.

If you reflect the structure of hasInverse, yes, but it is not “automatically” - It is structurally based. The hasInverse feature has its own structuring, when you export data with hasInverse you can see that structure. Live Loader, Bulkloader, or any DQL client will never do anything automatically. Everything is made by hand.

1 Like