One is to many relation in RDF: "predicate of type uid is scalar" issue

In my schema, Characters can have one or more works. I represented this with an array works: [Work] field for the Character type.

type Character {
    charId: String! @id
    works: [Work]
}

type Work {
    workId: String! @id
    characters: [Character] @hasInverse(field: works)
}

When I try to feed data in RDF format, I get an error:

Input for predicate "Character.works" of type uid is scalar. Edge: entity:650005 attr:"Character.works" value:"muchado"

Here’s the sample RDF data:

_:Character.leonato <Character.abbrev> "LEONATO" .
_:Character.leonato <Character.works> "muchado" .

_:Work.muchado <Work.workId> "muchado" .

I need an array of works [Work] because some characters have multiple works:

_:Character.antony <Character.works> "juliuscaesar" .
_:Character.antony <Character.works> "antonycleo" .

What’s gone wrong here?

_:Character.leonato <Character.abbrev> "LEONATO" .
_:Character.leonato <Character.works> _:Work.muchado .

_:Work.muchado <Work.workId> "muchado" .

Should do the trick. Don’t forget to add the reverse edge. Inserting in RDF/DQL does not auto matically do anything with the hasInverse directive outside of the graphql endpoint

2 Likes

Thanks, that was a silly mistake