expose a postgres Function to `pg_graphql`

I created a postgres Function but I don't see it in the graphql schema. Here's my function:

CREATE
OR REPLACE FUNCTION get_followers (target_address VARCHAR(42)) RETURNS TABLE (
  actor_address VARCHAR(42),
  action_timestamp TIMESTAMP WITH TIME ZONE,
  created_at TIMESTAMP WITH TIME ZONE
) AS $$
BEGIN
RETURN QUERY 
SELECT t.actor_address, t.action_timestamp, t.created_at
FROM (
    SELECT a.actor_address, a.action_timestamp, a.created_at, a.action,
           ROW_NUMBER() OVER (PARTITION BY a.actor_address ORDER BY a.action_timestamp DESC) as rn
    FROM activity a
    WHERE a.target_address = get_followers.target_address
    AND a.action IN ('follow', 'unfollow')
) t
WHERE t.rn = 1 AND t.action = 'follow';
END; $$ LANGUAGE plpgsql STABLE;


I initially didn't have the STABLE part. I later added it and re-created the function
Was this page helpful?