# GraphQL id=null yet Neo4J \<id\> exists

**URL:** <https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728>\
**Category:** GraphQL & GRANDstack\
**Created:** [November 8, 2019, 3:45pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728 "2019-11-08T15:45:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.chevalier335](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/r.chevalier335/32/6868_2.png) [@r.chevalier335](https://community.neo4j.com/u/r.chevalier335)\
**Post date:** [November 8, 2019, 3:45pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/1 "2019-11-08T15:45:51Z")

</div>

When mutating using graphql playground id=null is returned, yet the Neo4j browser shows a value for "id". What am I missing here?

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [November 8, 2019, 4:18pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/2 "2019-11-08T16:18:26Z")

</div>

Hi @r.chevalier335 - what does your GraphQL typedef look like for the type in question? And the GraphQL query?

Are you referring to the Neo4j internal node id, or a property named `id` that you are setting the value of explicitly? Neo4j internal node ids are exposed in the GraphQL integration as field `_id` and show up in Neo4j browser as `<id>`.

---

<div class="post-metadata">

**Author:** ![r.chevalier335](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/r.chevalier335/32/6868_2.png) [@r.chevalier335](https://community.neo4j.com/u/r.chevalier335)\
**Post date:** [November 8, 2019, 4:31pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/3 "2019-11-08T16:31:15Z")

</div>

Thanks for responding Will.

No, I didn't explicitly set an id value. I was expecting the Neo4j id to be returned. I've done a bit of reading and understand that the Neo4j id might not be reliable, and it's better to explicitly make my own. Is that true?

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [November 8, 2019, 4:38pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/4 "2019-11-08T16:38:25Z")

</div>

Yes, Neo4j internal ids should not be used in external systems as the internal ids can be reclaimed and reused later on.

So in general yes better to create a UUID or something and set it explicitly. If you're using `neo4j-graphql.js` a UUID will be generated and set automatically for any `ID!` field if not specified in the create mutation.

You can also use `apoc.create.uuid` to generate a UUID when creating nodes.

---

<div class="post-metadata">

**Author:** ![r.chevalier335](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/r.chevalier335/32/6868_2.png) [@r.chevalier335](https://community.neo4j.com/u/r.chevalier335)\
**Post date:** [November 8, 2019, 5:03pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/5 "2019-11-08T17:03:49Z")

</div>

Awesome. This is very helpful. Thanks William.

---

<div class="post-metadata">

**Author:** ![r.chevalier335](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/r.chevalier335/32/6868_2.png) [@r.chevalier335](https://community.neo4j.com/u/r.chevalier335)\
**Post date:** [November 18, 2019, 12:14pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/6 "2019-11-18T12:14:07Z")

</div>

I've had partial success. Still unable to delete and update. Any help is appreciated.

Here is my schema:  
type Thing {  
\_id: ID!  
name: String  
}

type Query {  
things: [Thing]!  
thing(\_id: ID!): Thing  
}

type Mutation {  
createThing(name: String): Thing  
updateThing(\_id: ID!, name: String!): Thing  
deleteThing(\_id: ID!): Thing  
}

Here are my queries/mutations and results:

* * *

ALL THINGS - Works

* * *

query{things{  
\_id  
name  
}  
}  
RETURNS:  
{  
"data": {  
"things": [  
{  
"\_id": "4",  
"name": "Thing 1"  
},  
{  
"\_id": "67",  
"name": "Thing 2"  
},  
{  
"\_id": "68",  
"name": "Thing 3"  
},  
{  
"\_id": "69",  
"name": "Thing 3"  
},  
{  
"\_id": "70",  
"name": "Thing 3"  
},

* * *

ONE THING - Works

* * *

query{thing(\_id:"4"){  
\_id  
name  
}  
}  
RETURNS:  
{  
"data": {  
"thing": {  
"\_id": "4",  
"name": "Thing 1"  
}  
}  
}

* * *

CREATE A THING - Works

* * *

mutation{createThing(  
name: "Thing 99993"  
)  
{  
\_id  
name  
}  
}  
RETURNS:  
{  
"data": {  
"createThing": {  
"\_id": "77",  
"name": "Thing 99993"  
}  
}  
}

* * *

UPDATE A THING - Nope

* * *

mutation{updateThing(  
\_id: "4"  
name: "Update Node 1"  
){  
\_id  
name  
}  
}  
RETURNS:  
{  
"data": {  
"updateThing": null  
}  
}

* * *

DELETE A THING - Nope It says the parameter is missing but I provided it.???

* * *

mutation {deleteThing(\_id: "4"){  
\_id  
name  
}  
}  
RETURNS:  
{  
"errors": [  
{  
"message": "Expected parameter(s): \_id",  
"locations": [  
{  
"line": 2,  
"column": 3  
}  
],  
"path": [  
"deleteThing"  
],  
"extensions": {  
"code": "INTERNAL\_SERVER\_ERROR",  
"exception": {  
"code": "Neo.ClientError.Statement.ParameterMissing",  
"name": "Neo4jError",  
"stacktrace": [  
"Neo4jError: Expected parameter(s): \_id",  
"",  
" at captureStacktrace (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/result.js:199:15)",  
" at new Result (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/result.js:65:19)",  
" at \_newRunResult (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/transaction.js:354:10)",  
" at Object.run (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/transaction.js:238:14)",  
" at Transaction.run (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/transaction.js:104:26)",  
" at /home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-graphql-js/dist/index.js:91:25",  
" at TransactionExecutor.\_safeExecuteTransactionWork (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/internal/transaction-executor.js:134:22)",  
" at TransactionExecutor.\_executeTransactionInsidePromise (/home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/internal/transaction-executor.js:122:32)",  
" at /home/rchevalier/dev/grand-stack/api/node\_modules/neo4j-driver/lib/v1/internal/transaction-executor.js:61:15",  
" at new Promise ()"  
]  
}  
}  
}  
],  
"data": {  
"deleteThing": null  
}  
}

---

<div class="post-metadata">

**Author:** ![mckenzma](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mckenzma/32/78_2.png) [@mckenzma](https://community.neo4j.com/u/mckenzma)\
**Post date:** [February 16, 2020, 2:39pm UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/8 "2020-02-16T14:39:47Z")

</div>

I posted a question and then immediately realized my error.

---

<div class="post-metadata">

**Author:** ![mckenzma](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mckenzma/32/78_2.png) [@mckenzma](https://community.neo4j.com/u/mckenzma)\
**Post date:** [February 17, 2020, 2:28am UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/9 "2020-02-17T02:28:47Z")

</div>

How is it supposed to work when you want to set the `id` using `apoc.create.uuid` using a mutation?

I am getting the following type of error message in my GRANDstack app:  
 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/a/a851e81a5b22ff0626cf212cf027a0f2d673835c.png)

Should I use the `apoc.create.uuid` or should I set `id`?

---

<div class="post-metadata">

**Author:** ![ahmedhosny](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ahmedhosny/32/12764_2.png) [@ahmedhosny](https://community.neo4j.com/u/ahmedhosny)\
**Post date:** [July 21, 2020, 2:53am UTC](https://community.neo4j.com/t/graphql-id-null-yet-neo4j-id-exists/11728/10 "2020-07-21T02:53:24Z")

</div>

Hello William -

> If you're using `neo4j-graphql.js` a UUID will be generated and set automatically for any `ID!` field if not specified in the create mutation.

I noticed this behavior when creating new nodes. However, I noticed this is not happening in the case of creating new relationships. I am using the community edition, and thought to add an ID! to the relationship type. In this case, it seems I am expected to provide the ID myself. I guess I am also wondering if I ever need to select a relationship by ID rather than simply match to its nodes.

My schema looks something like this.

```auto
# For company and product, Id's are generated automatically when not provided at creation time.
type Company {
  companyId: ID! 
  name: String!
  makes: [Makes]
}
type Product {
  productId: ID! 
  name: String!
  madeBy: [Makes]
}

# Here, ID is required (in addition to from and to)
type Makes @relation(name: "MAKES") {
  makesId: ID!
  from: Company
  to: Product
  source: String!
}

```

I call it like so

```auto
mutation AddCompanyMakes($companyId: ID!, $productId: ID!) {
  AddCompanyMakes(
    from: { companyId: $companyId }
    to: { productId: $productId }
    data: { source: "test" } # makesId REQUIRED HERE
  ) {
    from {
      companyId
    }
    to {
      productId
    }
    source
  }
}

```
