[BUGFIX] Create optimistic cache generate recordGqlFields from prefilled record (#10493)

# Introduction
The record does not appear in the table because the optimistic record
input cached does not fulfill the mutation response fields, which result
in it being considered as invalid response
close #10199 
close https://github.com/twentyhq/twenty/issues/10153
This commit is contained in:
Paul Rastoin
2025-02-26 11:11:01 +01:00
committed by GitHub
parent 26ea465862
commit 611e89e5c9
2 changed files with 6 additions and 6 deletions

View File

@ -24,9 +24,13 @@ export const useCreateOneRecordInCache = <T extends ObjectRecord>({
const apolloClient = useApolloClient();
return (record: ObjectRecord) => {
const prefilledRecord = prefillRecord({
objectMetadataItem,
input: record,
});
const recordGqlFields = generateDepthOneRecordGqlFields({
objectMetadataItem,
record,
record: prefilledRecord,
});
const fragment = gql`
fragment Create${capitalize(
@ -41,11 +45,6 @@ export const useCreateOneRecordInCache = <T extends ObjectRecord>({
})}
`;
const prefilledRecord = prefillRecord({
objectMetadataItem,
input: record,
});
const recordToCreateWithNestedConnections = getRecordNodeFromRecord({
record: prefilledRecord,
objectMetadataItem,

View File

@ -102,6 +102,7 @@ export const useCreateOneRecord = <
recordInput: {
...baseOptimisticRecordInputCreatedBy,
...recordInput,
position: Number.NEGATIVE_INFINITY,
id: idForCreation,
},
});