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:
Jérémy M
2023-09-28 16:27:34 +02:00
committed by GitHub
parent 485bc64b4f
commit 629bdbbf50
35 changed files with 1860 additions and 124 deletions

View File

@ -6,6 +6,7 @@
"private": true,
"license": "UNLICENSED",
"scripts": {
"postinstall": "patch-package",
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
@ -35,11 +36,12 @@
"@aws-sdk/credential-providers": "^3.363.0",
"@casl/ability": "^6.5.0",
"@casl/prisma": "1.4.0",
"@graphql-yoga/nestjs": "^2.1.0",
"@nestjs/apollo": "^11.0.5",
"@nestjs/common": "^9.0.0",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.0.0",
"@nestjs/graphql": "^11.0.6",
"@nestjs/graphql": "^12.0.8",
"@nestjs/jwt": "^10.0.3",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.0.0",
@ -62,12 +64,15 @@
"class-validator": "^0.14.0",
"date-fns": "^2.30.0",
"file-type": "16.5.4",
"graphql": "^16.7.1",
"graphql": "^16.8.0",
"graphql-fields": "^2.0.3",
"graphql-type-json": "^0.3.2",
"graphql-upload": "^13.0.0",
"graphql-yoga": "^4.0.4",
"jest-mock-extended": "^3.0.4",
"jsonwebtoken": "^9.0.0",
"lodash.camelcase": "^4.3.0",
"lodash.isempty": "^4.4.0",
"lodash.isobject": "^3.0.2",
"lodash.kebabcase": "^4.1.1",
"lodash.merge": "^4.6.2",
@ -77,7 +82,9 @@
"passport-google-oauth20": "^2.0.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"patch-package": "^8.0.0",
"pg": "^8.11.3",
"postinstall-postinstall": "^2.1.0",
"prisma-graphql-type-decimal": "^3.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
@ -96,8 +103,10 @@
"@types/bytes": "^3.1.1",
"@types/date-fns": "^2.6.0",
"@types/express": "^4.17.13",
"@types/graphql-fields": "^1.3.6",
"@types/graphql-upload": "^8.0.12",
"@types/jest": "28.1.8",
"@types/lodash.isempty": "^4.4.7",
"@types/lodash.isobject": "^3.0.7",
"@types/lodash.kebabcase": "^4.1.7",
"@types/lodash.snakecase": "^4.1.7",
@ -127,6 +136,9 @@
"tsconfig-paths": "4.1.0",
"typescript": "^4.9.4"
},
"resolutions": {
"graphql": "16.8.0"
},
"prisma": {
"schema": "src/database/schema.prisma",
"seed": "ts-node src/database/seeds/index.ts"