Array of UUID's as function input failing to generate valid GraphQL
TristenHarr opened this issue · comments
This issue was originally surfaced in Discord here.
When creating a function and tracking it such as follows:
CREATE
OR REPLACE FUNCTION public.select_from_tmp(uuids uuid []) RETURNS SETOF tmp LANGUAGE plpgsql STABLE AS $ function $ BEGIN RETURN QUERY
SELECT
*
FROM
tmp
WHERE
id = ANY(uuids);
END;
$ function $
The GraphQL engine does not allow queries or calling this function.
query Q($uuids: _uuid = ["2f03ebf9-2005-42e5-b1c4-9661c5643948"]) {
select_from_tmp(args: {uuids: $uuids}) {
id
}
}
Yields the following:
{
"errors": [
{
"message": "A string is expected for type: _uuid",
"extensions": {
"path": "$.selectionSet.select_from_tmp.args.args.uuids",
"code": "parse-failed"
}
}
]
}
Yet changing things to a string also fails:
query Q($uuids: _uuid = "2f03ebf9-2005-42e5-b1c4-9661c5643948") {
select_from_tmp(args: {uuids: $uuids}) {
id
}
}
yields:
{
"errors": [
{
"message": "malformed array literal: \"2f03ebf9-2005-42e5-b1c4-9661c5643948\"",
"extensions": {
"path": "$",
"code": "data-exception"
}
}
]
}
What should be possible via:
query Q($uuids: [_uuid!]!) {
select_from_tmp(args: {uuids: $uuids}) {
id
}
}
Is not possible and yields an error.
{
"errors": [
{
"message": "variable 'uuids' is declared as '[_uuid!]!', but used where '_uuid' is expected",
"extensions": {
"path": "$.selectionSet.select_from_tmp.args.args.uuids",
"code": "validation-failed"
}
}
]
}
It should be possible to create a function that needs an array of UUID's as the input and call that function!