Function returning table from non `search_path` schema

Open
#455 3 comments 0 reactions 1 assignee View on GitHub

@olirice is already working on this.

Since Nov 29, 2023.

Assessment

This issue has not been assessed yet.

Description

enhancement good first issue

Describe the bug
Seems a function returning a table from another schema is not exposed.

To Reproduce
Steps to reproduce the behavior:

begin;

create schema if not exists a1; grant usage on schema a1 to public;
create table a1.foo(id int); grant select on table a1.foo to public;
create or replace function a1.the_foo() returns a1.foo stable return (select f from a1.foo f where f.id = 1);
grant execute on function a1.the_foo() to public;

create schema if not exists a2; grant usage on schema a2 to public;
create or replace function a2.get_the_foo() returns a1.foo stable as $$ select * from a1.the_foo() $$ language sql;
grant execute on function a2.get_the_foo() to public;

set local search_path to 'a1';
select graphql.resolve($${__type(name: "Query") {fields(includeDeprecated: false) {name args {name type {kind name ofType {kind name}}}}}}$$)->'data'->'__type'->'fields'->1;
-- {"args": [], "name": "the_foo"}

set local search_path to 'a2';
select graphql.resolve($${__type(name: "Query") {fields(includeDeprecated: false) {name args {name type {kind name ofType {kind name}}}}}}$$)->'data'->'__type'->'fields'->1;
-- null

rollback;

Expected behavior
I would expect fully-typed return values to be exposed based on permissions and regardless of search_path.

Versions:

  • PostgreSQL: 16.1
  • pg_graphql commit ref: ee8ef69
Dominant language
Rust
Stars
3.4k
Forks
141
Avg merge
19m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/pg_graphql

All issues in supabase/pg_graphql

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.