This results in an error:
mutation {
update_smth_by_pk(pk_columns: { id: 1 }, _set: ...) {
id
rel {
id
}
}
}
Update: the errors appears only for update_by_pk mutations,
update(where..) { returning { ... } } works
@webdeb I am not able to reproduce this with a simple example.
Could you share the sample table definitions (for the 2 tables involved in your example) ? Are you executing this as a role? Can you also share Hasura metadata like relationship definitions and permissions?
@tirumaraiselvan I'm seeing the same error suddenly after upgrading to the latest version. My query is like this:
mutation UpdateOrder {
update_orders_by_pk(pk_columns: {id: "..."}, _set: {assigned_to_id: "..."}) {
id
customer {
id
orders_aggregate(where: { status: {_neq: CANCELED}}) {
aggregate {
count
}
}
}
}
}
Looks like what makes it crash is the status: {_neq: CANCELED} piece.
If I use status: {_nin: [CANCELED]} instead it works without issues.
The error message is database query error but there's more info in a nested error:
{
"exec_status": "FatalError",
"hint": null,
"message": "could not determine data type of parameter $1",
"status_code": "42P18",
"description": null
}
@tirumaraiselvan I've just setup a demo on heroku to demonstrate the bug:
URL
http://hasura-issue-6255.herokuapp.com/v1/graphql
HEADERS
x-hasura-user-id = 1
x-hasura-role = user
QUERIES
mutation works_when_not_by_pk {
update_post(where: {id: {_eq: 2}}, _set: {content: "Hello"}) {
returning {
id
title
content
image {
url
}
}
}
}
mutation by_pk_works_without_relation {
update_post_by_pk(pk_columns: {id: 2}, _set: {content: "Hello"}) {
id
title
content
}
}
mutation by_pk_with_rel_does_not_work {
update_post_by_pk(pk_columns: {id: 2}, _set: {content: "Hello"}) {
id
title
content
image {
url
}
}
}
Tiru, you'll also find the metadata and migrations here:
https://github.com/webdeb/graphql-engine-heroku/tree/bug-6255
Found the issue! This was caused by an error in the way we construct our internal representation of "by pk" mutations (the error was also present in delete_by_pk). For the issue to arise, however, two conditions needed to be met:
I've opened a PR on our internal repo that fixes this bug, it'll be included in 1.3.4.
@nicuveo great job!
Most helpful comment
Found the issue! This was caused by an error in the way we construct our internal representation of "by pk" mutations (the error was also present in
delete_by_pk). For the issue to arise, however, two conditions needed to be met:I've opened a PR on our internal repo that fixes this bug, it'll be included in 1.3.4.