2023-09-28 14:27:34 +00:00
|
|
|
-- Inflect names for pg_graphql
|
|
|
|
|
COMMENT ON SCHEMA "public" IS '@graphql({"inflect_names": true})';
|
2023-09-21 00:24:13 +00:00
|
|
|
|
|
|
|
|
-- Connect to the "default" database
|
|
|
|
|
\c "default";
|
|
|
|
|
|
2023-09-28 14:27:34 +00:00
|
|
|
-- Create extension
|
|
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_graphql;
|
|
|
|
|
|
2023-09-21 00:24:13 +00:00
|
|
|
-- Create the metadata schema if it doesn't exist
|
|
|
|
|
CREATE SCHEMA IF NOT EXISTS "metadata";
|
2023-09-21 02:11:21 +00:00
|
|
|
GRANT ALL ON SCHEMA metadata TO twenty;
|
2023-09-28 14:27:34 +00:00
|
|
|
|
|
|
|
|
-- Create extension uuid-ossp
|
2023-09-21 02:11:21 +00:00
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
|
|
|
|
2023-09-28 14:27:34 +00:00
|
|
|
-- Create GraphQL Entrypoint
|
|
|
|
|
create function graphql(
|
|
|
|
|
"operationName" text default null,
|
|
|
|
|
query text default null,
|
|
|
|
|
variables jsonb default null,
|
|
|
|
|
extensions jsonb default null
|
|
|
|
|
)
|
|
|
|
|
returns jsonb
|
|
|
|
|
language sql
|
|
|
|
|
as $$
|
|
|
|
|
select graphql.resolve(
|
|
|
|
|
query := query,
|
|
|
|
|
variables := coalesce(variables, '{}'),
|
|
|
|
|
"operationName" := "operationName",
|
|
|
|
|
extensions := extensions
|
|
|
|
|
);
|
|
|
|
|
$$;
|
|
|
|
|
|
|
|
|
|
-- Create the tests database for e2e testing
|
|
|
|
|
CREATE DATABASE "test";
|
|
|
|
|
|
|
|
|
|
-- Connect to the "test" database for e2e testing
|
2023-09-21 02:11:21 +00:00
|
|
|
\c "test";
|
|
|
|
|
|
|
|
|
|
-- Create the metadata schema if it doesn't exist
|
|
|
|
|
CREATE SCHEMA IF NOT EXISTS "metadata";
|
|
|
|
|
GRANT ALL ON SCHEMA metadata TO twenty;
|
2023-09-28 14:27:34 +00:00
|
|
|
|
|
|
|
|
-- Create extension uuid-ossp
|
2023-09-21 02:11:21 +00:00
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|