twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
14.99k stars 1.47k forks source link

Upsert endpoints for GraphQL and Rest API #4656

Open FelixMalfait opened 3 months ago

FelixMalfait commented 3 months ago

Context: working on CSV import or import from an external CRM.

We don't have any equivalent of "upsert". So right now, we have to 2 two queries:

It would be nice to introduce a new endpoint that leverages the duplicate method to do an upsert. We could improve the existing CSV import and it would be easier to build the CRM import feature.

input UpsertOptions {
  checkDuplicate: Boolean
  additionalKeys: [String]
}

type Mutation {
  upsertCompany(company: CompanyInput!, options: UpsertOptions): Company
}

REST:

{
  "company": {
    "id": "123",
    "externalId": "ext-456",
    "name": "Company Name",
    "email": "company@example.com",
    "phoneNumber": "123-456-7890",
    "address": "123 Main St"
    # Add other fields as needed
  },
  "options": {
    "checkDuplicate": true,
    "additionalKeys": ["email", "phoneNumber"]
  }
}
Kanav-Arora commented 3 months ago

Hi @FelixMalfait I was thinking of working on a core backend issue. I'm not much aware of dir structure. Could you please tell me the file or dir in which change is required and assign me this issue. I'll explore it a bit

FelixMalfait commented 3 months ago

@Kanav-Arora this is fairly difficult and would required touching many files I think. Because of the abstraction layers we've created on the backend (to support custom objects), it's more complex than a traditional CRUD codebase

arnavsaxena17 commented 3 months ago

I want to explore how to do this - Could you point us in which direction to go about/ any documentation I should read?

Kanav-Arora commented 3 months ago

@Kanav-Arora this is fairly difficult and would required touching many files I think. Because of the abstraction layers we've created on the backend (to support custom objects), it's more complex than a traditional CRUD codebase

Then I think I should get understanding of the backend structure first and work on smaller issue