I have a task that gets called when a json file is uploaded.
When that task runs, it does a createMany
mutation
after the createMany
is done. It loops over all the “items” that was created and does an update
to add missing relationships.
When running this locally with an exact mock of the event.data it receives when it’s called. It works perfectly fine. It creates the new records and then updates them 1 by 1 to add the missing relationships.
However when it’s deployed and it runs with the exact same event.data
it does the createMany
correctly, and it does run the individual updates afterwards. But the items never gets updated with the relationships.
I’ve just spent the whole day adding this feature to almost all of my tables and then it doesn’t work serverside… Any idea what’s going on here?
Here’s the relevant code:
const ADD_SIGNAL_RELATIONSHIPS = `
mutation ADD_SIGNAL_RELATIONSHIPS($id: ID, $ticker: String, $planName: String) {
signalUpdate(data: {
id: $id,
plan: { connect: { planID: $planName } },
report: { connect: { ticker: $ticker } },
stock: { connect: { ticker: $ticker } }
}) {
id
}
}
`;
if (newSignals.length) {
const { signalCreateMany } = await graphQLClient.request(
CREATE_MANY_SIGNALS_MUTATION,
{
...signalAdvancedDataVariables
}
);
signalCreateMany.items.forEach(async signal => {
// update to add relationships.
await graphQLClient.request(ADD_SIGNAL_RELATIONSHIPS, {
id: signal.id,
ticker: signal.ticker,
planName
});
});
I do have a signal.create before trigger which makes sure the stock
it’s connecting to exists. But that all seems to work as expected.
Why is this task working locally but not working as expected on the server?
I tried adding a 1 second wait before it does the updates in case it was a weird race-condition or something. But it still didn’t work when deployed.
Please help… I can’t launch without working relationships, which has been quite problematic from the start.