Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not expose trigger functions in GQL #432

Merged
merged 2 commits into from
Oct 9, 2023
Merged
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
2 changes: 2 additions & 0 deletions src/sql_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ impl Function {
if let Some(return_type) = types.get(&self.type_oid) {
return_type.category != TypeCategory::Pseudo
&& return_type.name != "record"
&& return_type.name != "trigger"
&& return_type.name != "event_trigger"
&& !self.type_name.ends_with("[]")
} else {
false
Expand Down
40 changes: 40 additions & 0 deletions test/expected/function_calls.out
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,12 @@ begin;
)
returns smallint language sql immutable
as $$ select 0; $$;
create function returns_trigger()
returns trigger language plpgsql immutable
as $$ begin return null; end; $$;
create function returns_event_trigger()
returns event_trigger language plpgsql immutable
as $$ begin end; $$;
select jsonb_pretty(
graphql.resolve($$
query IntrospectionQuery {
Expand Down Expand Up @@ -2155,4 +2161,38 @@ begin;
}
(1 row)

select jsonb_pretty(graphql.resolve($$
query {
returnsTrigger
}
$$));
jsonb_pretty
-------------------------------------------------------------------------
{ +
"data": null, +
"errors": [ +
{ +
"message": "Unknown field \"returnsTrigger\" on type Query"+
} +
] +
}
(1 row)

select jsonb_pretty(graphql.resolve($$
query {
returnsEventTrigger
}
$$));
jsonb_pretty
------------------------------------------------------------------------------
{ +
"data": null, +
"errors": [ +
{ +
"message": "Unknown field \"returnsEventTrigger\" on type Query"+
} +
] +
}
(1 row)

rollback;
20 changes: 20 additions & 0 deletions test/sql/function_calls.sql
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@ begin;
returns smallint language sql immutable
as $$ select 0; $$;

create function returns_trigger()
returns trigger language plpgsql immutable
as $$ begin return null; end; $$;

create function returns_event_trigger()
returns event_trigger language plpgsql immutable
as $$ begin end; $$;

select jsonb_pretty(
graphql.resolve($$
query IntrospectionQuery {
Expand Down Expand Up @@ -762,4 +770,16 @@ begin;
concatText(a: "hello ")
}
$$));

select jsonb_pretty(graphql.resolve($$
query {
returnsTrigger
}
$$));

select jsonb_pretty(graphql.resolve($$
query {
returnsEventTrigger
}
$$));
rollback;
Loading