twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
Other
17.48k stars 2.06k forks source link

Make REST API use Twenty ORM direclty #3644

Open FelixMalfait opened 8 months ago

FelixMalfait commented 8 months ago

Objective: Enhance the reliability and performance of the REST API.

Technical Context

Currently, our REST API (documentation here) is exposed via two dynamic endpoint sets:

The RestApiCoreService currently parses REST payloads, converts them into GraphQL payloads, and calls the GraphQL API—an inefficient process. This approach was initially necessary because querying workspaceSchemas in Twenty required pg_graphql.

However, we recently introduced TwentyORM (soon to be renamed WorkspaceORM), a lightweight layer on top of TypeORM, which can directly query workspaceSchemas.

Goal: Refactor the REST API to leverage TwentyORM directly.

Note: The GraphQL API is also being migrated to TwentyORM (replacing pg_graphql), so you can draw inspiration from the GraphqlQueryRunnerService.

Key Goals:

Refactor the REST API to use TwentyORM directly. Ensure the REST API is fully covered by integration tests.

Technical inputs

We should take a lot of inspiration from what has been done in the new GraphqlQueryRunnerService. Advices: 1) split the code in services / utils to keep small and well scoped functional pieces 2) Overall logic: a) parse REST payload into TypeORM format, b) send TypeORM query, c) parse result back into REST response 3) All the pieces are already there: the current code is able to parse REST into graphql and Graphql into twentyORM, we "only" need to skip one step. It will likely mean to write everything from scratch but this should still speed a lot the process

charlesBochet commented 1 month ago

Yes please!

If any experienced contributor wants to tackle this task, I'm happy to give a hand here. There is a lot of work but the engineering and the product is very well defined so it should be doable by the community

charlesBochet commented 1 month ago

@FelixMalfait It's not that difficult anymore I think as most of the complexity is within twenty-orm and we have quite good example of parsing in the current rest api and in our graphql implementation (we know how to parse rest input to graphql and graphql to orm already, we need to do rest input to orm direclty)

charlesBochet commented 1 month ago

I'm editing the description to add more details

Faisal-imtiyaz123 commented 1 month ago

@charlesBochet I am ready to work. You may please assign me.

FelixMalfait commented 1 week ago

@Faisal-imtiyaz123 let me know if we should unassign you. Thanks!

Faisal-imtiyaz123 commented 1 week ago

@FelixMalfait Yes you may unassign me. I talked to @charlesBochet regarding this.

charlesBochet commented 1 week ago

/oss.gg 3000

oss-gg[bot] commented 1 week ago

Thanks for opening an issue! It's live on oss.gg!

DeepaPrasanna commented 1 week ago

I have working experience in nestjs, May I work on this? @charlesBochet

charlesBochet commented 1 week ago

sure, thank you @DeepaPrasanna! You can type: /assign to get assigned to it

charlesBochet commented 1 week ago

It's not an easy one, feel free to ping me if you need help!

DeepaPrasanna commented 1 week ago

sure! Thank you

DeepaPrasanna commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

Assigned to @DeepaPrasanna! Please open a draft PR linking this issue within 48h ⚠️ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹️ Excited to have you ship this 🚀

Tanmayshi commented 1 week ago

/assign

oss-gg[bot] commented 1 week ago

This issue is already assigned to another person. Please find more issues here.

oss-gg[bot] commented 5 days ago

@DeepaPrasanna, Just a little reminder: Please open a draft PR linking this issue within 12 hours. If we can't detect a PR in 12h, you will be unassigned automatically.

charlesBochet commented 5 days ago

/unassign

oss-gg[bot] commented 5 days ago

Issue unassigned.

DeepaPrasanna commented 5 days ago

hello @charlesBochet , I am working on this. I have an interview scheduled for today, that is why I paused for some time. I plan to resume my work again tomorrow.

DeepaPrasanna commented 5 days ago

/assign

oss-gg[bot] commented 5 days ago

Assigned to @DeepaPrasanna! Please open a draft PR linking this issue within 48h ⚠️ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹️ Excited to have you ship this 🚀

devhiteshk commented 4 days ago

/assign

oss-gg[bot] commented 4 days ago

This issue is already assigned to another person. Please find more issues here.

DeepaPrasanna commented 16 hours ago

I will be creating a draft PR today. Pls don't unassign me.

FelixMalfait commented 12 hours ago

Thanks @DeepaPrasanna, great to create a PR to get intermediate feedback and make sure you go in the right direction since this is a big PR, thanks a lot!