It looks like the when running the my trigger type as “after” i am getting a write loop where my query keeps running over and over then timing out at 20s and starting again.
when i run it as a trigger type of “before” i am getting this graphql error.
Code and error below.
Thoughts?
{
"data": null,
"errors": [
{
"message": "Remote function time out",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"projectUpdate"
],
"code": "IllegalOperationError",
"details": {
"remoteFunction": "Remote function time out"
}
}
]
}
// 8base invoke-local generateGraphs -p src/triggers/generateGraphs/mocks/request.json
const mathjs = require('mathjs');
const gql = require('graphql-tag');
const { spawn } = require('child_process');
const MUTATION = gql`
mutation MyMutation($id: ID, $computed: JSON) {
projectUpdate(data: { id: $id, computed: $computed }) {
computed
id
}
}
`;
module.exports = async (event, ctx) => {
const { id, projectHorizon } = event.data;
console.log(event.data);
console.log(id);
console.log(projectHorizon);
let project = [];
for (let year = 0; year < projectHorizon; year++) {
const mathTest = mathjs.evaluate(`${projectHorizon} * (${year} + 5.5)`);
const result = {
year: year,
test: mathTest,
};
console.log(result);
project.push(result);
}
await ctx.api.gqlRequest(
MUTATION,
{ id, computed: JSON.stringify(project) },
{
waitForResponse: true,
}
);
return {
data: event.data,
error: [],
};
};