mirror of
https://github.com/lingble/twenty.git
synced 2025-11-25 18:34:56 +00:00
feat: dynamic graphQL schema generation based on user workspace (#1725)
* wip: refacto and start creating custom resolver * feat: findMany & findUnique of a custom entity * feat: wip pagination * feat: initial metadata migration * feat: universal findAll with pagination * fix: clean small stuff in pagination * fix: test * fix: miss file * feat: rename custom into universal * feat: create metadata schema in default database * Multi-tenant db schemas POC fix tests and use query builders remove synchronize restore updatedAt remove unnecessary import use queryRunner fix camelcase add migrations for standard objects Multi-tenant db schemas POC fix tests and use query builders remove synchronize restore updatedAt remove unnecessary import use queryRunner fix camelcase add migrations for standard objects poc: conditional schema at runtime wip: try to create resolver in Nest.JS context fix * feat: wip add pg_graphql * feat: setup pg_graphql during database init * wip: dynamic resolver * poc: dynamic resolver and query using pg_graphql * feat: pg_graphql use ARG in Dockerfile * feat: clean findMany & findOne dynamic resolver * feat: get correct schema based on access token * fix: remove old file * fix: tests * fix: better comment * fix: e2e test not working, error format change due to yoga * remove typeorm entity generation + fix jwt + fix search_path + remove anon * fix conflict --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: corentin <corentin@twenty.com>
This commit is contained in:
@@ -1,25 +1,46 @@
|
||||
-- Create the default database for development
|
||||
CREATE DATABASE "default";
|
||||
|
||||
-- Create the tests database for e2e testing
|
||||
CREATE DATABASE "test";
|
||||
|
||||
-- Create a twenty user
|
||||
CREATE USER twenty PASSWORD 'twenty';
|
||||
ALTER USER twenty CREATEDB;
|
||||
-- Inflect names for pg_graphql
|
||||
COMMENT ON SCHEMA "public" IS '@graphql({"inflect_names": true})';
|
||||
|
||||
-- Connect to the "default" database
|
||||
\c "default";
|
||||
|
||||
-- Create extension
|
||||
CREATE EXTENSION IF NOT EXISTS pg_graphql;
|
||||
|
||||
-- Create the metadata schema if it doesn't exist
|
||||
CREATE SCHEMA IF NOT EXISTS "metadata";
|
||||
GRANT ALL ON SCHEMA metadata TO twenty;
|
||||
|
||||
-- Create extension uuid-ossp
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
-- Connect to the "default" database
|
||||
-- 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
|
||||
\c "test";
|
||||
|
||||
-- Create the metadata schema if it doesn't exist
|
||||
CREATE SCHEMA IF NOT EXISTS "metadata";
|
||||
GRANT ALL ON SCHEMA metadata TO twenty;
|
||||
|
||||
-- Create extension uuid-ossp
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
Reference in New Issue
Block a user