Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TristenHarr opened this issue May 13, 2024 · 0 comments
Open
Labels
k/bug Something isn't working

Comments

@TristenHarr
Copy link
Contributor

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!

@TristenHarr TristenHarr added the k/bug Something isn't working label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant