Then, use it as the argument for a custom function:
CREATE OR REPLACE FUNCTION public.list_authors_random (seed seed_float DEFAULT 0 ::seed_float)
RETURNS SETOF public.authors
AS $$
SELECT SETSEED(seed);
SELECT * FROM public.authors ORDER BY random();
$$
LANGUAGE sql
STABLE;
Now do the following queries:
# working, but expected not to work
query ExpectNotToWork0 {
list_authors_random(args: {seed: "0"}) {
name
}
}
# the validation works too
# error message:
# "Check constraint violation. value for domain seed_float violates check constraint \"seed_float_check\""
query ExpectNotToWork1 {
list_authors_random(args: {seed: "2"}) {
name
}
}
# not working, but expected to work
# error message: "A string is expected for type: seed_float"
query ExpectToWork {
list_authors_random(args: {seed: 0}) {
name
}
}
Concerns
Currently, I need to pass a string as input where the expected type should be a float. If in the future this is fixed, will it be backward compatible? I mean, support both string and the actual type?
Summary
When using domains as argument type for a custom function, hasura always expect a string, even for number domains.
Steps to reproduce
Create a domain:
Then, use it as the argument for a custom function:
Now do the following queries:
Concerns
Currently, I need to pass a string as input where the expected type should be a float. If in the future this is fixed, will it be backward compatible? I mean, support both string and the actual type?