# Mutation RDF format erroring

**URL:** <https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521>\
**Category:** GraphQL\
**Tags:** dgraph\
**Created:** [January 12, 2022, 5:25pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521 "2022-01-12T17:25:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 12, 2022, 5:25pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/1 "2022-01-12T17:25:15Z")

</div>

I’m new to dgraph. I’m getting below when trying add a mution.  
What am I doing wrong

```auto
{
  "name": "t",
  "url": "https://blue-surf-560034.us-east-1.aws.cloud.dgraph.io/mutate?commitNow=true",
  "errors": [
    {
      "message": "while lexing _:x codeId 1234 . at line 1 column 3: Invalid input: c at lexText",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

```

My type is below

```auto
type PersonDetail
{
  codeId: Int! @id
  timestamp: Int!
  ethnicity: Int!
  raceId: [Int]!
  maritalStatusId: Int!
}

```

Tring to add mutation using RDF format

```auto
{
 set {
  _:x codeId 1234 .
  _:x ethnicity 3.
  _:x maritalStatusId 1 .
  _:x timestamp 4567898223 .
  _:x <dgraph.type> "PersonDetail" .
 }
}

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 12, 2022, 5:45pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/2 "2022-01-12T17:45:18Z")

</div>

> [@porsche](#):
>
> ```auto
> {
> set {
> _:x codeId 1234 .
> _:x ethnicity 3.
> _:x maritalStatusId 1 .
> _:x timestamp 4567898223 .
> _:x <dgraph.type> "PersonDetail" .
> }
> }
> 
> ```

This should be like this

```auto
{
 set {
  _:x <PersonDetail.codeId> "1234" .
  _:x <PersonDetail.ethnicity> "3" .
  _:x <PersonDetail.maritalStatusId> "1" .
  _:x <PersonDetail.timestamp> "4567898223" .
  _:x <dgraph.type> "PersonDetail" .
 }
}
```

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [January 12, 2022, 5:58pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/3 "2022-01-12T17:58:29Z")

</div>

If you are using GraphQL and DQL together, you also need to correctly map your predicates.

Edit: @MichelDiz maps them correctly above.

This is not clear in any of the beginner docs. Let me know if you need direction on this further.

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 12, 2022, 6:05pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/4 "2022-01-12T18:05:30Z")

</div>

Why am I using double quotes around “1234” (int data type)?

Infact doc are very confusing…  
For example in this link [https://dgraph.io/docs/mutations/blank-nodes/](https://dgraph.io/docs/mutations/blank-nodes/)

```auto
{
 set {
    _:class <student> _:x .
    _:class <student> _:y .
    _:class <name> "awesome class" .
    _:class <dgraph.type> "Class" .
    _:x <name> "Alice" .
    _:x <dgraph.type> "Person" .
    _:x <dgraph.type> "Student" .
    _:x <planet> "Mars" .
    _:x <friend> _:y .
    _:y <name> "Bob" .
    _:y <dgraph.type> "Person" .
    _:y <dgraph.type> "Student" .
 }
}

```

What does it mean by these two statements?

```auto
_:y <dgraph.type> "Person" .
_:y <dgraph.type> "Student" .

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 12, 2022, 6:25pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/5 "2022-01-12T18:25:06Z")

</div>

> [@porsche](#):
>
> Why am I using double quotes around “1234” (int data type)?

Thats part of RDF spec.

> [@porsche](#):
>
> What does it mean by these two statements?

Dgraph has Types(nodes, entities) that need to be explicitly pointed in your data. All entities you have should have this predicate.

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 12, 2022, 7:16pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/6 "2022-01-12T19:16:13Z")

</div>

Thanks for the replay @MichelDiz and @amaster507 .

What’s wrong with my query? sorry newbie quetions.

```auto
query {
  queryPersonDetail() {
  PersonDetail.timestamp  
	PersonDetail.codeId (filter: Tcode.codeConceptId: eq: "1234")
 }
}

```

- I’m getting below error when querying

```auto
{
"name": "t",
"url": "https://blue-surf-560034.us-east-1.aws.cloud.dgraph.io/query?timeout=20s&debug=true",
"errors": [
  {
    "message": "line 4 column 1: Only aggregation/math functions allowed inside empty blocks. Got: persondetail.timestamp",
    "extensions": {
      "code": "ErrorInvalidRequest"
    }
  }
]
}

```

- I changed my schema like below

```auto
type Tcode
{
  codeConceptId: Int! @id  
}

type PersonDetail
{
  id: ID!
  codeId: Tcode!
  timestamp: Int!
  ethnicity: Tcode!
  raceIds: [Tcode]!
  maritalStatusId: Tcode!
}

```

- Added mutation using RDF format like below

```auto
{
 set {
  _:c <Tcode.codeConceptId> "1234" .
  _:e <Tcode.codeConceptId> "3" .
  _:m <Tcode.codeConceptId> "1" .
  _:x <PersonDetail.codeId> _:c .
  _:x <PersonDetail.ethnicity> _:e .
  _:x <PersonDetail.maritalStatusId> _:m .
  _:x <PersonDetail.timestamp> "4567898223" .
 }
}

```

```auto

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 12, 2022, 7:23pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/7 "2022-01-12T19:23:46Z")

</div>

You seem to be skipping a lot of steps in your studies. Take it easy.

The kind of “prefix” we have in RDF and DQL is just for DQL/Dgraph context. In GraphQL you can use the normal naming.

e.g:

```auto
query {
	queryPersonDetail() {
         timestamp  
         codeId (filter: {
              codeConceptId: {
              eq: "GraphQL"
      }
    })

}

```

You are mixing DQL syntax with GraphQL. If you are studying GraphQL, ignore DQL’s syntax and docs.

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 12, 2022, 7:41pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/8 "2022-01-12T19:41:01Z")

</div>

@MichelDiz thanks for the reply. Sorry for newbie question again.

I used your sample still get the same error.

```auto
query {
	queryPersonDetail() {
   timestamp  
	 codeId (filter: {
    codeConceptId: {
      eq: "1234"
    }
  })
 }
}

```

Then, I modified like below and new error.

```auto
query {
	queryPersonDetail() {
   timestamp  
	 codeId (filter: codeConceptId: eq: "1234")
  }
}

```

The above query erroring out…

```auto
{
  "name": "t",
  "url": "https://blue-surf-560034.us-east-1.aws.cloud.dgraph.io/query?timeout=20s&debug=true",
  "errors": [
    {
      "message": "line 4 column 2: Only aggregation/math functions allowed inside empty blocks. Got: timestamp",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 12, 2022, 7:52pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/9 "2022-01-12T19:52:01Z")

</div>

I just gave you an example of syntax. You should check your schema and check the Dgraph’s GraphQL docs.

Also, you can use some GraphQL IDE to get the GraphQL Schema. For example GraphiQL [GitHub - graphql/graphiql: GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.](https://github.com/graphql/graphiql)

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/4/435e1f90f4fea5d45f81e4c1dfa5daccd7e841c0.jpeg)

It shows the Schema and following the documented schema in the right panel or by using the autocomplete. You can build a valid query. Is that easy.

GraphQL can be confusing for newcomers. So I would recommend that you study GraphQL vanilla first and then go back to Dgraph’s GraphQL. Most of the functions that Dgraph uses are customized on top of GraphQL Spec. But it’s critical to learn the basics of GraphQL first.

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 13, 2022, 10:44pm UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/10 "2022-01-13T22:44:33Z")

</div>

Thanks for your reply. I’m having issues with delete.

Using Ratel I executed below two mutation command variants…both succeeded in Ratel. But the node wasn’t deleted. Any idea what’s happening?

- Varitation 1

```auto
{
    delete {
			<0x7aec3d502> * * .
    }
}

```

- Variation 2

```auto
{
    delete {
			<0x7aec3d502> <Tcode.udi> * .
    }
}

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 14, 2022, 12:32am UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/11 "2022-01-14T00:32:02Z")

</div>

> [@porsche](#):
>
> But the node wasn’t deleted.

If you are talking about that the uid `0x7aec3d502` still there, but with no data/predicates in it. It is pretty normal. That’s how Dgraph is designed. The creation (leasing) of UIDs is a continued range. It is not possible to delete an already created number(UID). You can reuse them tho - for other purpose(but not really necessary). If you don’t understand this, just ignore it. Understand that Node has indeed been deleted. Do not worry about it.

Now, if you are saying that the data still there. Is that your data wasn’t added with the predicate “dgraph.type”. It have to have that predicate with the according Entity Type.

e.g:

```auto
{
    set {
			<0x7aec3d502> <Person.name> "Bob" .
			<0x7aec3d502> <age> "22" .
			<0x7aec3d502> <dgraph.type> "Person" .
    }
}

```

If the dataset doesn’t have the type Person, and also the Type Schema doesn’t have the corresponding predicates. It won’t delete enything.

Cheers.

---

<div class="post-metadata">

**Author:** ![porsche](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/porsche/32/9579_2.png) [@porsche](https://discuss.dgraph.io/u/porsche)\
**Post date:** [January 14, 2022, 1:20am UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/12 "2022-01-14T01:20:20Z")

</div>

Thanks for details explanation and I verified it too.

Interesting enough, I noticed something weird…

- By accident I executed below mutation two times in Cloud Ratel. To my surprise, it created two nodes?

- So, I wanted switch to upsert block. Tried to follow instructions from this link [https://dgraph.io/docs/mutations/external-ids-upsert-block](https://dgraph.io/docs/mutations/external-ids-upsert-block) . But, they are too hard to comprehend for newbie like me. Can some help me here, below is my type definition.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [January 14, 2022, 1:32am UTC](https://discuss.dgraph.io/t/mutation-rdf-format-erroring/16521/13 "2022-01-14T01:32:58Z")

</div>

> [@porsche](#):
>
> it created two nodes?

You are using a Blank Node (`_:x`). Everytime you send a mutation with a Blank Node it will create a new node. No matter what.

A way to avoid this is using Upsert Block Mutation. Or use UID instead of Blank Node.

> [@porsche](#):
>
> Can some help me here, below is my type definition.

You have to pick the “source of truth” to use as a param. In your case I will pick codeConceptId.

In the mutation panel run this

```auto
   upsert {
      query {
        var(func: eq(Tcode.codeConceptId, "1234")) {
          ConceptId as uid
        }
      }
      mutation {
          set {
           uid(ConceptId) <Tcode.codeConceptId> "1234" .
           uid(ConceptId) <Tcode.domain> "Generic domain" .
           uid(ConceptId) <dgraph.type> "Tcode" .
          }
      }
    }

```
