Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/connect/src/hooks/use-private-spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const usePrivateSpaces = (): UseQueryResult<PrivateSpaceData[], Error> =>
...space,
apps: Array.from(spaceAppIds).map((appId) => {
return {
// @ts-expect-error - need to improve appInfo typing
name: appInfo[appId]?.name ?? 'Unknown',
id: appId,
};
Expand Down
31 changes: 30 additions & 1 deletion packages/hypergraph-react/src/prepare-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ query entityToPublish($entityId: String!, $spaceId: String!) {
entity(id: $entityId, spaceId: $spaceId) {
values {
propertyId
value
}
relations {
id
Expand All @@ -33,6 +34,7 @@ type EntityToPublishQueryResult = {
entity: {
values: {
propertyId: string;
value: string;
}[];
relations: {
id: string;
Expand Down Expand Up @@ -97,7 +99,34 @@ export const preparePublish = async <S extends Entity.AnyNoContext>({
return { ops };
}

// TODO: implement updating an existing entity
if (data?.entity) {
for (const [key, propertyId] of Object.entries(mappingEntry.properties || {})) {
let serializedValue: string = entity[key];
if (fields[key] === Type.Checkbox) {
serializedValue = Graph.serializeCheckbox(entity[key]);
} else if (fields[key] === Type.Date) {
serializedValue = Graph.serializeDate(entity[key]);
} else if (fields[key] === Type.Point) {
serializedValue = Graph.serializePoint(entity[key]);
} else if (fields[key] === Type.Number) {
serializedValue = Graph.serializeNumber(entity[key]);
}

const existingValue = data.entity.values.find((value) => value.propertyId === propertyId);

if (serializedValue !== existingValue?.value) {
values.push({ property: propertyId, value: serializedValue });
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key 'property' used in the update object is inconsistent with the established schema which uses 'propertyId'. Update this to 'propertyId' to ensure consistency with the GraphQL query and type definitions.

Suggested change
values.push({ property: propertyId, value: serializedValue });
values.push({ propertyId: propertyId, value: serializedValue });

Copilot uses AI. Check for mistakes.

}
}

// TODO: handle added or removed relations
// TODO: handle updated relations
// TODO: handle added or removed types
if (values.length > 0) {
const { ops: updateEntityOps } = Graph.updateEntity({ id: entity.id, values });
ops.push(...updateEntityOps);
}
}

return { ops };
};
Loading