porsche
(porscheme)
January 15, 2022, 3:35am
1
I’m getting below error, what am I doing wrong?
{
"name": "t",
"url": "http://127.0.0.1:8080/mutate?commitNow=true",
"errors": [
{
"message": "Input for predicate \"PersonalDetail.codeId\" of type uid is scalar. Edge: entity:55 attr:\"\\000\\000\\000\\000\\000\\000\\000\\000PersonalDetail.codeId\" value:\"10\" ",
"extensions": {
"code": "ErrorInvalidRequest"
}
}
]
}
Below is my upsert code snippetupsert {
query {
var(func: eq(Tcode.codeConceptId, "10")){
ConceptId as uid
}
var(func: eq(Tcode.codeConceptId, "30")){
EthnicityId as uid
}
var(func: eq(Tcode.codeConceptId, "40")){
GenderId as uid
}
var(func: eq(Tcode.codeConceptId, "50")){
MaritalId as uid
}
}
mutation {
set {
uid(ConceptId) <PersonalDetail.codeId> "10" .
uid(ConceptId) <PersonalDetail.timestamp> "344578" .
uid(ConceptId) <dgraph.type> "PersonalDetail" .
uid(EthnicityId) <PersonalDetail.hasEthnicityId> "30" .
uid(GenderId) <PersonalDetail.hasGenderId> "40" .
uid(MaritalId) <PersonalDetail.hasMaritalStatusId> "50" .
}
}
}
Below are my types type Tcode {
codeConceptId: Int! @id
domain: String!
}
type PersonalDetail {
codeId: Tcode!
hasEthnicityId: Tcode!
hasGenderId: Tcode!
hasMaritalStatusId: Tcode!
hasRaceIds: [Tcode]!
timestamp: Int! @search
}
jdgamble555
(Jonathan Gamble)
January 15, 2022, 4:59am
2
I’m not sure what you’re trying to do here, but
PersonalDetail.codeId
is value TCode
type, and your settings it to the value “10”. You also seem like your trying to set some nested value to itself. I am not sure if this is on purpose.
When you want to link Node1 to Node2, use:
uid(Node1) <Node1.Field1> uid(Node2) .
where Field1 is a nested type Node2.
Also of note, you can get the uid with just one line of code if you like:
MaritalId as var(func: eq(Tcode.codeConceptId, "50"))
Hope this helps,
J