Cant insert data via relation

Hi, im trying to insert data via relations in my table “Maker”, it has a one-to-many relation, so a maker can have multiple Models, but i cant insert because it says
“Cannot add or update a child row: a foreign key constraint fails”, why is it happening?, it wasn’t happening before, am i doing something wrong?

Hey @jetixsolorzano! It’s Igor from 8base

As I understand, you are trying to connect one record while creating another, right? There are 2 ways to resolve this:

  1. Make fields “not required” by unchecking Mandatory checkbox in schema builder
  2. Move connect to separate update mutation:
const { id: createdRecordId } = await api.gqlRequest(MAKER_CREATE_MUTATION);

const { id: updatedRecordId } = await api.gqlRequest(MAKER_UPDATE_MUTATION, { variables: { id: createdRecordId, modelId: modelId }});

Hope that helps,
Igor

thanks igor, it worked, but i have a doubt, why do i have to change to “not required”, i have done this process before, and it worked as expected, now with the recent 8base’s changes it is failing, why is it happening?, i have some CF that have the same logic and the fields are required, do I have to worry about it?

@jetixsolorzano Nothing to worry about. We are adding new features and improving performance, so some operations should be separated for mandatory fields.

We are working on the solution for supporting Mandatory fields

Igor