[BUG][PROD] Fix ViewGroup creation optimistic cache (#10014)

# Introduction
When we create a new `view` from record table that has relation such as
opportunities.
Encountered invariant conditions:

## Unknown fiel `__typename`
`Should never occur, encountered unknown fields __typename in
objectMetadaItem viewGroup`,

### Fixed by ignoring unknown internal fields


## Provided both relation `view` and `viewId`
`Should never provide relation mutation through anything else than the
fieldId e.g companyId and not company, encountered: view`

### Fixed by sending only `viewId` to `createManyRecords` in
`usePersistViewGroupRecords.ts`
This commit is contained in:
Paul Rastoin
2025-02-05 12:22:45 +01:00
committed by GitHub
parent 736b845c98
commit 3e05c3743e
6 changed files with 95 additions and 72 deletions

View File

@ -26,14 +26,12 @@ export const usePersistViewGroupRecords = () => {
const createViewGroupRecords = useCallback(
(viewGroupsToCreate: ViewGroup[], view: GraphQLView) => {
if (!viewGroupsToCreate.length) return;
if (viewGroupsToCreate.length === 0) return;
return createManyRecords(
viewGroupsToCreate.map((viewGroup) => ({
...viewGroup,
view: {
id: view.id,
},
viewId: view.id,
})),
);
},