Input for "predicate" of type uid is scalar


(Juan Rendon) #1

Im taking the tour https://tour.dgraph.io/schema/1/, and run:

industry: string @index(term) .
boss_of: uid .

and then :

{
        "set": [
            {
                "uid": "_:company1",
                "industry": "Machinery",
                "name": "CompanyABC"
            },
            {
                "uid": "_:company2",
                "industry": "High Tech",
                "name": "The other company"
            },
            {
                "uid": "_:jack",
                "works_for": "_:company1",
                "name": "Jack"
            },
            {
                "uid": "_:ivy",
                "works_for": "_:company1",
                "boss_of": "_:jack",
                "name": "Ivy"
            },
            {
                "uid": "_:zoe",
                "works_for": "_:company1",
                "name": "Zoe"
            },
            {
                "uid": "_:jose",
                "works_for": "_:company2",
                "name": "Jose"
            },
            {
                "uid": "_:alexei",
                "works_for": "_:company2",
                "boss_of": "_:jose",
                "name": "Alexei"
            }
        ]
    }

and is done. But then i delete all the schema

and run:

use_tool: uid .
name: string @index(term) .

and then run:

{
        "set": [
            {
                "uid": "_:tool1",
                "name": "dgraph"
            },
            {
                "uid": "_:tool2",
                "name": "Mysql"
            },
            {
                "uid": "_:juanbits",
                "use_tool": "_:tool1",
                "name": "Juanbits"
            }
        ]
    }

and i get the next error:

Input for predicate use_tool of type uid is scalar

i dont know what is wrong, if i replicate the example :sleepy: . i check the other similar questions, but i dont understand


(Daniel Mai) #2

Check out this part of the Mutations documentation: https://docs.dgraph.io/mutations/#edges-between-nodes

Note

A common mistake is to attempt to use {"uid":"0x123","link":"0x456"} . This will result in an error. Dgraph interprets this JSON object as setting the link predicate to the string "0x456" , which is usually not intended.

You’ll have to explicitly state the uid field for uses_tool.

Instead of this:

"use_tool": "_:tool1",

It should look something like this:

"use_tool": {
    "uid": "_:tool1"
},

(Ami Pandat) #3

Hello,
I am facing this same error but I have loaded my data by using live loader.
This is my schema file Rdf_lodSchema.schema (487 Bytes)
and this is my dataset file dataset.rdf (23.2 KB)

Can you help me with this?


(Michel Conrado) #4

Hey Ami, your RDF is wrong. All of your values are set as Blank Nodes. Take a read https://tour.dgraph.io/intro/5/ - In our last conversation I said to you do that, but I guess you din’t get it right about the values. Blank Nodes are for relational node usage. That’s Why you get this error about the Schema. As you schema is set as value for a particular predicate and your RDF is set to UID type (blank nodes are to UID type) you have a collision of type. It gives an error.


(Ami Pandat) #5

Okay I will clean my dataset and will try to run it again.


(Ami Pandat) #6

Yes its working fine now.Thanks!