Skip to content

Commit

Permalink
chore(front): comment about RecordObject reflexion
Browse files Browse the repository at this point in the history
  • Loading branch information
prastoin committed Jan 24, 2025
1 parent 398966d commit 7bc75ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { triggerUpdateRelationsOptimisticEffect } from '@/apollo/optimistic-effe
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
import { isDefined } from '~/utils/isDefined';

export const triggerDestroyRecordsOptimisticEffect = ({
Expand All @@ -16,7 +16,7 @@ export const triggerDestroyRecordsOptimisticEffect = ({
cache: ApolloCache<unknown>;
objectMetadataItem: ObjectMetadataItem;
// TODO refactor this should consume RecordObject[]
recordsToDestroy: ObjectRecord[];
recordsToDestroy: RecordGqlNode[];
objectMetadataItems: ObjectMetadataItem[];
}) => {
cache.modify<StoreObject>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const triggerUpdateRelationsOptimisticEffect = ({
updatedSourceRecord,
objectMetadataItems,
}: triggerUpdateRelationsOptimisticEffectArgs) => {
console.log({currentSourceRecord, updatedSourceRecord})
return sourceObjectMetadataItem.fields.forEach(
(fieldMetadataItemOnSourceRecord) => {
const notARelationField =
Expand Down Expand Up @@ -95,9 +96,11 @@ export const triggerUpdateRelationsOptimisticEffect = ({
}

if (isObjectRecordConnection(relationDefinition, value)) {
// Might not be a good idea to return RecordObject here as they might be written in cache later
return getRecordsFromRecordConnection({recordConnection: value})
}

// Might not be a good idea to return RecordObject here as they might be written in cache later
return [getRecordFromRecordNode({recordNode: value})];
};
const targetRecordsToDetachFrom = extractTargetRecordsFromRelation(
Expand Down

0 comments on commit 7bc75ce

Please sign in to comment.