Disconnect - fix disconnect false (#13439)

Context: {disconnect: false} disconnects relation > fix in this PR + add
integration test
This commit is contained in:
Etienne
2025-07-25 14:26:05 +02:00
committed by GitHub
parent fecac68760
commit e386303fd3
2 changed files with 30 additions and 1 deletions

View File

@ -243,7 +243,7 @@ export class RelationNestedQueries {
)) {
entity = {
...entity,
[disconnectFieldName]: null,
[disconnectFieldName]: undefined,
...(disconnectObject[RELATION_NESTED_QUERY_KEYWORDS.DISCONNECT] ===
true
? { [getAssociatedRelationFieldName(disconnectFieldName)]: null }

View File

@ -455,6 +455,35 @@ describe('relation connect in workspace createOne/createMany resolvers (e2e)',
expect(response.body.data.updatePerson).toBeDefined();
expect(response.body.data.updatePerson.company?.id).toBeUndefined();
});
it('should not disconnect a record from a MANY-TO-ONE relation - update One', async () => {
const createPersonToUpdateOperation = createOneOperationFactory({
objectMetadataSingularName: 'person',
gqlFields: PERSON_GQL_FIELDS_WITH_COMPANY,
data: {
id: TEST_PERSON_1_ID,
companyId: TEST_COMPANY_1_ID,
},
});
await makeGraphqlAPIRequest(createPersonToUpdateOperation);
const graphqlOperation = updateOneOperationFactory({
objectMetadataSingularName: 'person',
gqlFields: PERSON_GQL_FIELDS_WITH_COMPANY,
recordId: TEST_PERSON_1_ID,
data: {
company: {
disconnect: false,
},
},
});
const response = await makeGraphqlAPIRequest(graphqlOperation);
expect(response.body.data.updatePerson).toBeDefined();
expect(response.body.data.updatePerson.company?.id).toBe(TEST_COMPANY_1_ID);
});
it('should disconnect a record from a MANY-TO-ONE relation - update Many', async () => {
const createPeopleToUpdateOperation = createManyOperationFactory({
objectMetadataSingularName: 'person',