Fix graphql query createMany resolver with nested relations (#7061)

Looks like insert() does not return foreign keys. We could eventually
call findMany after but it seems that's what save() is doing so I'm
replacing insert with save.
```typescript
/**
 * Flag to determine whether the entity that is being persisted
 * should be reloaded during the persistence operation.
 *
 * It will work only on databases which does not support RETURNING / OUTPUT statement.
 * Enabled by default.
 */
reload?: boolean;
```

Note: save() also does an upsert by default with no way to configure
that so if we want to keep that behaviour we will need to add a check
before
```typescript
if (args.upsert) {
    const existingRecords = await repository.findBy({
      id: Any(args.data.map((record) => record.id)),
    });
    ...
```

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Weiko
2024-09-18 18:43:45 +02:00
committed by Charles Bochet
parent 147eaaa5b0
commit 02618b3e6a
13 changed files with 347 additions and 121 deletions

View File

@ -1,8 +1,11 @@
import { Module } from '@nestjs/common';
import { GraphqlQueryRunnerService } from 'src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service';
import { WorkspaceQueryHookModule } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/workspace-query-hook.module';
import { WorkspaceQueryRunnerModule } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-runner.module';
@Module({
imports: [WorkspaceQueryHookModule, WorkspaceQueryRunnerModule],
providers: [GraphqlQueryRunnerService],
exports: [GraphqlQueryRunnerService],
})