Is it possible to track a function's dependencies in Postgres? When there is a function that is dependent on another object, is there any way to track that dependency?

For example, is there a way to tell that test2() relies on test1?:

create table test1 (id int);
create function test2() returns int language sql as 
   $$ select id from test1 limit 1 $$;


Context: I have a system of materialized views, with a "refresh all" procedure implemented using the logic from https://wiki.postgresql.org/wiki/Refresh_All_Materialized_Views. Unfortunately, the database has evolved such that one of the matviews must call another matview through an intermediary function. The only workaround I can think of is to either scrap this system and define the refresh order manually, or introduce false dependencies on the function's source matview whenever the function is used. Neither option is appealing; is there any alternative?
Since functions are stored as strings in PostgreSQL, and there is no limit to the languages a function could be written in, PostgreSQL cannot analyze the code to add dependencies.

The best option you have is to manually figure out the dependencies.

If you store that information in a database table, you could make sure that all REFRESH MATERIALIZED VIEW statements are executed in the correct order.