hasura / hasura/graphql-engine

Array of UUID's as function input failing to generate valid GraphQL

Open
#10,232 1 comment 1 reaction 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

This issue was originally surfaced in Discord [here](https://discord.com/channels/407792526867693568/1238828153452101703/1238828153452101703).

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.