graphile / graphile.github.io

PostGraphile (PostGraphQL) and Graphile-Build website - contributions very welcome!
https://www.graphile.org/
25 stars 128 forks source link

Add Database Function Restriction to Docs #333

Closed johndanek closed 2 years ago

johndanek commented 2 years ago

I ran into an issue where a plpgsql function I wrote was not being exposed to GraphQL via Postgraphile. The issue is that the function returned a RECORD whereas it needs to return a defined TYPE which is consistent across function calls. When I changed to a defined type (via CREATE TYPE example_type AS (value text, id int); Postgraphile was able to detect it and it was exposed via GraphQL.

https://www.graphile.org/postgraphile/function-restrictions/ could add the following not so that future users don't get confused:

We do not support functions which return the type RECORD, as GraphQL must know a predictable set of values to return.

benjie commented 2 years ago

Thanks: https://github.com/graphile/graphile.github.io/blob/8568e485a02cd1d3859d73c2c10eda61cef02631/src/pages/postgraphile/function-restrictions.md