Problems inserting null values

Hi, i have been trying to insert null values in my relational field and i could’t do it beacuse it throws me an error

My field is not mandatory, so it should accept null values, but it doesn’t let me do it

Hello!

Could you send the all code text of your mutation, please? In additional to this, can you send your workspaceID, please? These questions will help me find a more personalized solution to your issue.

Lada Kokotova | Technical Support Engineer

here it is, i can’t insert null values from my mutation and it says that i have to filter

It lets me insert data when there’s no null values, but when it is a null values i cant

workspaceID: ckuelivgr03u208mgeczf73e5

I’ll check what’s wrong. I’ll let you know as soon as possible.

Lada Kokotova | Technical Support Engineer

Thanks.
it always happen when i want to insert null values with a mutation
look at this:


that field is not mandatory

Hi, I believe it’s because you’re trying to run a mutation that connects a record with ID of null which didn’t exist.

Instead of passing the ID as the argument, pass the relation connect type as the argument.

Sorry, i didn’t understand that, can you explain how?

Sure. Right now your passing the ID as the argument; like:

userID arg = "847dgw74g8gw80dg086qgw086f08"

Instead, pass in the relation filter as the argument; like:

userID arg = { 
  connect: { 
    id: "847dgw74g8gw80dg086qgw086f08"
  } 
}  

What do you mean by “relation filter as the argument”, i can’t put any filter in my mutation, can you explain me with more datils?

Look in your API Explorer and you’ll see all the argument Types for your mutations/queries.

Based on your data-model (as seen in the mutation), your reviewCreate mutation should have a type called ReviewsUserIDRelationInput or something along those lines. That type value could look like:

{ 
  connect: { 
    id: "847dgw74g8gw80dg086qgw086f08"
  } 
}

So instead of passing ONLY the ID, try passing the full ReviewsUserIDRelationInput. That way when it receives a null value the whole chunk will be omitted, rather than the API try to connect a record using an empty object.

Thanks it worked,this is the way that i did it if anyone needs it:

1 Like