twentyhq / twenty

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

Use depth=0 in REST API #6101

Closed FelixMalfait closed 2 months ago

FelixMalfait commented 3 months ago

A customer reported that it wasn't possible to use depth=0 as a parameter in the REST API (it returns depth=1). It would be nice to fix it.

greptile-apps[bot] commented 3 months ago

To fix the issue with depth=0 in the REST API, follow these steps:

  1. Locate the Query Parameter Handling: Identify where the query parameters are processed in the REST API. This is likely in the controller or service handling the API requests.

  2. Modify Depth Parameter Handling: Ensure that the depth parameter is correctly parsed and handled. If depth=0 is passed, it should be respected and not default to depth=1.

  3. Update the Controller: In the relevant controller file, update the method handling the API request to correctly process depth=0.

Example:

@Get('your-endpoint')
async getYourData(@Query('depth') depth: number) {
  const effectiveDepth = depth === 0 ? 0 : (depth || 1);
  return this.yourService.getData(effectiveDepth);
}
  1. Update the Service: Ensure the service method respects the depth parameter.

Example:

async getData(depth: number) {
  if (depth === 0) {
    // Handle depth=0 logic
  } else {
    // Handle other depths
  }
}

Files to check:

Ensure that all relevant parts of the codebase respect the depth parameter.

References

/packages/twenty-server/src/modules/calendar-messaging-participant/jobs /packages/twenty-server/src/modules/calendar/listeners/calendar-blocklist.listener.ts /packages/twenty-server/src/modules/messaging/blocklist-manager/listeners/messaging-blocklist.listener.ts /packages/twenty-server/src/modules/messaging/message-import-manager/crons/commands/messaging-messages-import.cron.command.ts /packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/messaging-gmail-messages-import.service.ts /packages/twenty-server/src/modules/calendar/services/google-calendar-sync/google-calendar-sync.service.ts /packages/twenty-server/src/modules/messaging/message-import-manager/crons/commands/messaging-message-list-fetch.cron.command.ts /packages/twenty-server/src/database/typeorm/core/migrations/1711557405330-addMissingMigration.ts

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)