hasura / hasura/graphql-engine
support custom SQL functions having composite type (rowtype) input arguments
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
via https://github.com/hasura/graphql-engine/issues/3232#issuecomment-576796667
Tracking an SQL function which returns `SETOF ` and type of any one of input arguments is a table row (already tracked) gives the exception described in above referred comment. User creates such functions for [computed fields](https://docs.hasura.io/1.0/graphql/manual/schema/computed-fields.html#computed-fields) and tracks them as [custom SQL functions](https://docs.hasura.io/1.0/graphql/manual/schema/custom-functions.html#).
Solution:-
1. Allow table row type as scalars for function arguments in "args" input field. The name of such scalar types will conflict with the names of object types generated for the table. The possible solution I think as of now is to append `_input` for scalars generated for composite types. Input value for those row type scalars can be constructed as String literals (See [Postgres docs](https://www.postgresql.org/docs/12/rowtypes.html#id-1.5.7.24.6)).
~2. The "args" input for computed field should be named as `__input_args` and not `_input_args`~ We can't change the generated type name as it breaks the schema. So, we can support solution `1` by restricting tracking an SQL function as either a custom SQL function (in queries) or a computed field of a table but not both.
- [ ] Update docs with appropriate example
Contributor guide
Assessment
This issue has not been assessed yet.