I’m running a local standalone dgraph instance using the latest docker container.
Then I upload a GraphQL schema using
❯ curl -X POST localhost:8080/admin/schema --data-binary '@schema.graphqls'
The schema looks like:
interface IdentifiedObject {
id: ID!
iri: String! @id @dgraph(pred: "xid")
description: String
name: String
}
type BaseVoltage implements IdentifiedObject {
id: ID!
iri: String! @id @dgraph(pred: "xid")
description: String
name: String
nominalVoltage: Voltage
}
type ACLineSegment implements IdentifiedObject {
id: ID!
iri: String! @id @dgraph(pred: "xid")
BaseVoltage: BaseVoltage
Terminals: [Terminal!]
description: String
name: String
}
Then I use live upload command
❯ docker exec dgraph dgraph live --alpha localhost:9080 --format=json -f /tmp/lines_500.json --upsertPredicate xid
The content of the json file looks like:
[
{
"dgraph.type": "ACLineSegment",
"IdentifiedObject.iri": "urn:uuid:0043d68c-2d4c-4965-9c8a-e1fca6ecd178",
"xid": "urn:uuid:0043d68c-2d4c-4965-9c8a-e1fca6ecd178",
"IdentifiedObject.name": "110 kV C.D. Tamaya-Salar",
"ACLineSegment.BaseVoltage": {
"dgraph.type": "BaseVoltage",
"IdentifiedObject.iri": "urn:uuid:01bb6a99-59af-7681-acb7-5a157aa705aa",
"xid": "urn:uuid:01bb6a99-59af-7681-acb7-5a157aa705aa",
"IdentifiedObject.name": "110.00 kV",
"BaseVoltage.nominalVoltage": null
},
},
{
"dgraph.type": "ACLineSegment",
"IdentifiedObject.iri": "urn:uuid:0084d6fc-e131-432d-92bb-1e0a12dc95db",
"xid": "urn:uuid:0084d6fc-e131-432d-92bb-1e0a12dc95db",
"IdentifiedObject.name": "EST.67 - EST.74 110KV C1",
"ACLineSegment.BaseVoltage": {
"dgraph.type": "BaseVoltage",
"IdentifiedObject.iri": "urn:uuid:01bb6a99-59af-7681-acb7-5a157aa705aa",
"xid": "urn:uuid:01bb6a99-59af-7681-acb7-5a157aa705aa",
"IdentifiedObject.name": "110.00 kV",
"BaseVoltage.nominalVoltage": null
},
},
]
Command executes successfully and I’m making a request:
{
lines(func: type(BaseVoltage)) {
uid
xid
}
}
It returns me 2 BaseVoltage
’s instead of one which is my expectation.
It seems for me that the --upsertPredicate
flag doesn’t work properly - please explain what am I doing wrong. The expected behaivour is having 2 different lines referencing a single voltage object.
Thank you.