JSON file mutation + query help

Hey guys,

I got all data converted from CSV format to JSON format and I tried to begin loading. When i use this command, it seems like nothing works:
curl -H "Content-Type: application/rdf" "localhost:8080/mutate?commitNow=true" -XPOST --data-binary @jsonfile.json
But if i copy-paste a portion of the file into ratel and run it as a mutation on there, it works fine???

Here is a sample object in the file:

  "set": [
      "Commentid": 1236950581249,
      "creationDate": "2011-08-17T14:26:59.961+0000",
      "locationIP": "",
      "browserUsed": "Chrome",
      "content": "yes",
      "length": 3,
      "dgraph.type": "Comment"

After I successfully mutate the graph using ratel, I’m unable to even query for the data points I just created. I’ve tried adding a Comment type and querying for all Comment types, and also querying for has “Commentid”, which should have been loaded since I was returned with a success message.

Query is simple enough:

  q(func: type(Comment) {

TLDR; 1. Am i loading the json files correctly?
2. Is creating types a must?


I don’t think it’s adding a type at all. If you look at your Schemas , then click Type in Ratel, you will find that Comment was not added.

Yeah, it’s not adding it a type.

If i add the type manually myself, I still cannot query for it :frowning:

Why this is set RDF when you are sending JSON?

BTW, You have to add Type Definition on the Schema itself, not wait that Dgraph would infer your data and create the Type Def for you.

To be able to use expand All and Delete, you have to have a well-defined Schema Type along with the “dgraph.type” on your dataset.


1 Like