Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sql/load_sql_context.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ schemas_(oid, name) as (
select
jsonb_build_object(
'config', jsonb_build_object(
'search_path', (select array_agg(schema_oid) from search_path_oids),
-- array_agg returns null when the search path is empty. Coalesce so
-- the context still deserializes into a (empty) sequence. Issue #650
'search_path', coalesce(
(select array_agg(schema_oid) from search_path_oids),
'{}'::oid[]
),
'role', current_role,
'schema_version', graphql.get_schema_version()
),
Expand Down
24 changes: 24 additions & 0 deletions test/expected/issue_650.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
begin;
create table test_table (
id serial primary key,
name text not null,
description text
);
comment on schema public is e'@graphql({"introspection": true})';
-- baseline: a non-empty search_path resolves fine
set local search_path to public;
select graphql.resolve('{ __typename }');
resolve
-----------------------------------
{"data": {"__typename": "Query"}}
(1 row)

-- an empty search_path should also resolve, with no visible schemas
set local search_path to '';
select graphql.resolve('{ __typename }');
resolve
-----------------------------------
{"data": {"__typename": "Query"}}
(1 row)

rollback;
19 changes: 19 additions & 0 deletions test/sql/issue_650.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
begin;

create table test_table (
id serial primary key,
name text not null,
description text
);

comment on schema public is e'@graphql({"introspection": true})';

-- baseline: a non-empty search_path resolves fine
set local search_path to public;
select graphql.resolve('{ __typename }');

-- an empty search_path should also resolve, with no visible schemas
set local search_path to '';
select graphql.resolve('{ __typename }');

rollback;