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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
-- migrate:up

CREATE OR REPLACE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger
LANGUAGE plpgsql
SET search_path TO pg_catalog, pg_temp
AS $_$
DECLARE
graphql_is_dropped bool;
BEGIN
graphql_is_dropped = (
SELECT ev.schema_name = 'graphql_public'
FROM pg_event_trigger_dropped_objects() AS ev
WHERE ev.schema_name = 'graphql_public'
);

IF graphql_is_dropped
THEN
create or replace function graphql_public.graphql(
"operationName" text default null,
query text default null,
variables jsonb default null,
extensions jsonb default null
)
returns jsonb
language plpgsql
set search_path to ''
as $$
DECLARE
server_version float;
BEGIN
server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float);

IF server_version >= 14 THEN
RETURN jsonb_build_object(
'errors', jsonb_build_array(
jsonb_build_object(
'message', 'pg_graphql extension is not enabled.'
)
)
);
ELSE
RETURN jsonb_build_object(
'errors', jsonb_build_array(
jsonb_build_object(
'message', 'pg_graphql is only available on projects running Postgres 14 onwards.'
)
)
);
END IF;
END;
$$;
END IF;

END;
$_$;

-- migrate:down
1 change: 1 addition & 0 deletions migrations/schema-15.sql
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ CREATE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger
)
returns jsonb
language plpgsql
set search_path to ''
as $$
DECLARE
server_version float;
Expand Down
1 change: 1 addition & 0 deletions migrations/schema-17.sql
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ CREATE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger
)
returns jsonb
language plpgsql
set search_path to ''
as $$
DECLARE
server_version float;
Expand Down
1 change: 1 addition & 0 deletions migrations/schema-orioledb-17.sql
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ CREATE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger
)
returns jsonb
language plpgsql
set search_path to ''
as $$
DECLARE
server_version float;
Expand Down