BUG: Hasura v1.4alpha volatile functions not showing in the GraphQL Schema
See original GitHub issueWhen tracking a volatile function, the function is not showing in the GraphQL schema.
Hasura version: v1.4.0-alpha.1, deployed to Heroku. https://bug-volatile-function-hasura.herokuapp.com/console
Steps to reproduce:
- create table
CREATE TABLE article
(
id serial primary key,
title TEXT not null,
content TEXT not null
);
- create function
CREATE OR REPLACE FUNCTION public.add_article(title text, content text)
RETURNS SETOF article
LANGUAGE plpgsql
AS $function$
DECLARE inserted_article_id integer;
BEGIN
IF LENGTH(content) < 10 THEN
INSERT into article (title, content) values (title, content) RETURNING id INTO inserted_article_id;
ELSE
RAISE EXCEPTION 'article is too large';
END IF;
RETURN QUERY SELECT * from article where id = inserted_article_id;
END;
$function$
- In the data tab track the table
- In the data tab track the function as a mutation
add_article does not show in the GraphQL schema.
I tried with and without the x-hasura-admin-secret in the server flags Different functions Adding permission to the role user and trying the role applied as user.
I wasn’t able to make it work at all.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Troubleshooting Hasura GraphQL engine errors
This section provides references that can help in troubleshooting errors when developing with Hasura. Logs. In order to find out about the origins...
Read more >GraphQL Engine server config reference - Hasura
For the graphql-engine command these are the available flags and environment ... Volatile functions are not exposed to any of the roles in...
Read more >Top GraphQL Errors and How to fix them
Technically this error came out of using a field which doesn't exist (either due to Auth or schema not really having the field)....
Read more >Metadata API Reference: Custom Functions - Hasura
pg_track_function is used to add a custom SQL function to the GraphQL schema. It supports more configuration options than v1, and also supports...
Read more >Postgres: Extend schema with SQL functions - Hasura
Hasura GraphQL engine lets you expose certain types of custom functions as top level fields in the GraphQL API to allow querying them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

2.1.1 We also had same problem. Admin is accessable but other role can not see the function at mutation. We added HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS=false to config and allow permission to our role.
This is not a bug, per the documentation:
Therefore, unless the
HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONSenv var is set tofalse, we expect volatile functions to be exposed as mutations and only available to the admin role.However it seems the actual behavior when an existing function is tracked (as opposed to tracking the function during creation) is slightly different, and the resulting metadata does allow users to set permissions for the function. This may be a bug.