I’m trying to use aliases to update many records at once.
Unfortunately I get the following error:
{
"data": null,
"errors": [
{
"message": "The request is invalid.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"FLWS_alias"
],
"code": "ValidationError",
"details": {
"id": "id should be specified"
}
}
]
}
I don’t know the id’s ahead of time and I don’t want to waste a request to fetch all the ids and then loop over what will be around ~3k records. To find the intersections or map it. It’s wasteful.
The ticker
column in this Table is unique. So it should be able to find the record to update based on that. Just like it does in a normal update without having to know the ID as well.
The test mutation I’m trying to run:
mutation {
FLWS_alias: aIReportUpdate(data: {
ticker: "FLWS",
scores: "{\"ai_soundness\":1,\"ai_stewardship\":1,\"ai_profitability\":0.428571,\"ai_growth\":0.5,\"ai_value\":-0.818182,\"ai_reward\":0.212867,\"ai_safety\":0.241133,\"ai_score\":-0.0871333}",
price: 13.74,
date: "2019-10-29",
aIScore: -0.0871333
}) { id }
XXII_alias: aIReportUpdate(data: {
ticker: "XXII",
scores: "{\"ai_soundness\":0.272727,\"ai_stewardship\":0,\"ai_profitability\":-0.714286,\"ai_growth\":-0.25,\"ai_value\":-0.818182,\"ai_reward\":-0.724533,\"ai_safety\":-0.949633,\"ai_score\":-1}",
price: 2.03,
date: "2019-10-29",
aIScore: -1
}) { id }
DDD_alias: aIReportUpdate(data: {
ticker: "DDD",
scores: "{\"ai_soundness\":0.636364,\"ai_stewardship\":0.25,\"ai_profitability\":-0.714286,\"ai_growth\":-0.5,\"ai_value\":-0.818182,\"ai_reward\":-0.1454,\"ai_safety\":-0.371667,\"ai_score\":-0.7954}",
price: 8.93,
date: "2019-10-29",
aIScore: -0.7954
}) { ticker }
}
This is my schema:
Ticker should be unique and searchable for a single record, so ID shouldn’t be needed.
I tried using filter to get around this, but looks like that doesn’t work with update?
FLWS_alias: aIReportUpdate(filter: { ticker: { equals: "FLWS" }}, data: { ... }) { ticker }
PS. Also when using aliases in mutation. I would expect there to be multiple errors. This is only throwing 1 error for the first thing that goes wrong. I would expect it to throw 1 error for each mutation.
Looks like the other mutations weren’t even attempted.