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
7 changes: 7 additions & 0 deletions .changeset/bright-planes-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@graphprotocol/hypergraph": patch
"@graphprotocol/hypergraph-react": patch
---

- Rename `time` field to `datetime` in GraphQL valuesList queries
- Add `ScheduleString` type for querying schedule fields
8 changes: 5 additions & 3 deletions packages/hypergraph-react/src/prepare-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ query entityToPublish($entityId: UUID!, $spaceId: UUID!) {
text
boolean
float
time
datetime
point
schedule
}
relationsList(filter: {spaceId: {is: $spaceId}}) {
id
Expand All @@ -42,8 +43,9 @@ type EntityToPublishQueryResult = {
text: string;
boolean: boolean;
float: number;
time: string;
datetime: string;
point: string;
schedule: string;
}[];
relationsList: {
id: string;
Expand Down Expand Up @@ -155,7 +157,7 @@ export const preparePublish = async <S extends Schema.Schema.AnyNoContext>({
} else if (propertyType.value === 'date') {
const dateValue = entity[prop.name] as Date;
const newValue = dateValue.toISOString().split('T')[0];
hasChanged = existingValueEntry?.time !== newValue;
hasChanged = existingValueEntry?.datetime !== newValue;
typedValue = { property: propertyId.value, type: 'date', value: newValue };
} else if (propertyType.value === 'point') {
const [lon, lat] = entity[prop.name] as [number, number];
Expand Down
4 changes: 2 additions & 2 deletions packages/hypergraph-react/test/prepare-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe('preparePublish', () => {
{ propertyId: 'ed49ed7b17b34df6b0b511f78d82e151', text: 'Same Name' },
{ propertyId: 'a427183d35194c96b80a5a0c64daed41', float: 30 },
{ propertyId: 'e425955442b146e484c3f8681987770f', boolean: true },
{ propertyId: 'b5c0e2c79ac9415e8ffe34f8b530f126', time: '1993-01-01' },
{ propertyId: 'b5c0e2c79ac9415e8ffe34f8b530f126', datetime: '1993-01-01' },
{ propertyId: '45e707a5436442fbbb0b927a5a8bc061', point: '0,0' },
],
relationsList: [],
Expand Down Expand Up @@ -630,7 +630,7 @@ describe('preparePublish', () => {
valuesList: [
{ propertyId: '2a8b9c7d4e5f6a7b8c9d0e1f2a3b4c5d', text: 'Existing Entity' },
{ propertyId: 'eaf9f4f856474228aff58725368fc87c', float: 75 },
{ propertyId: '9b53690fea6d4bd8b4d39ea01e7f837f', time: '2023-01-01' },
{ propertyId: '9b53690fea6d4bd8b4d39ea01e7f837f', datetime: '2023-01-01' },
],
relationsList: [],
},
Expand Down
6 changes: 4 additions & 2 deletions packages/hypergraph/src/entity/find-many-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ query ${queryName}(${variableDefinitions}) {
text
boolean
float
time
datetime
point
schedule
}
${level1Relations}
}
Expand All @@ -102,8 +103,9 @@ type ValuesList = {
text: string;
boolean: boolean;
float: number;
time: string;
datetime: string;
point: string;
schedule: string;
}[];

type RawEntity = Record<string, string | boolean | number | unknown[] | Date | string[]>;
Expand Down
3 changes: 2 additions & 1 deletion packages/hypergraph/src/entity/find-one-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ query entity($id: UUID!, $spaceId: UUID!) {
text
boolean
float
time
datetime
point
schedule
}${relationsSelectionBlock}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/hypergraph/src/entity/search-many-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ query searchEntities($query: String!, $spaceId: UUID!, $typeIds: [UUID!]!, $firs
text
boolean
float
time
datetime
point
schedule
}
${relationsSelection}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/hypergraph/src/type/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export const Date = (propertyId: string) => {
return Schema.Date.pipe(Schema.annotations({ [PropertyIdSymbol]: propertyId, [PropertyTypeSymbol]: 'date' }));
};

/**
* Creates a ScheduleString schema with the specified GRC-20 property ID
*/
export const ScheduleString = (propertyId: string) => {
return Schema.String.pipe(Schema.annotations({ [PropertyIdSymbol]: propertyId, [PropertyTypeSymbol]: 'schedule' }));
};
Comment on lines +141 to +143
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The new ScheduleString type lacks test coverage. While other property types like Date, Point, Number, Boolean, and String are tested in the test suite, there are no tests demonstrating how to use ScheduleString or verifying its behavior. Consider adding test cases that use the ScheduleString type in an entity schema, similar to how other property types are tested.

Copilot uses AI. Check for mistakes.

export const Point = (propertyId: string) =>
Schema.transform(Schema.String, Schema.Array(Schema.Number), {
strict: true,
Expand Down
23 changes: 20 additions & 3 deletions packages/hypergraph/src/utils/convert-property-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import * as Option from 'effect/Option';
import * as SchemaAST from 'effect/SchemaAST';

export const convertPropertyValue = (
property: { propertyId: string; text: string; boolean: boolean; float: number; time: string; point: string },
property: {
propertyId: string;
text: string;
boolean: boolean;
float: number;
datetime: string;
point: string;
schedule: string;
},
type: SchemaAST.AST,
) => {
const propertyType = SchemaAST.getAnnotation<string>(Constants.PropertyTypeSymbol)(type);
Expand Down Expand Up @@ -43,8 +51,17 @@ export const convertPropertyValue = (
}
if (propertyType.value === 'date') {
// Handle case where date is stored as string in the API
if (property.time != null) {
return property.time;
if (property.datetime != null) {
return property.datetime;
}
if (property.text != null) {
return property.text;
}
return undefined;
}
if (propertyType.value === 'schedule') {
if (property.schedule != null) {
return property.schedule;
}
if (property.text != null) {
return property.text;
Expand Down
3 changes: 2 additions & 1 deletion packages/hypergraph/src/utils/convert-relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ type ValueList = {
text: string;
boolean: boolean;
float: number;
time: string;
datetime: string;
point: string;
schedule: string;
}[];

type RelationsListItem = {
Expand Down
6 changes: 4 additions & 2 deletions packages/hypergraph/src/utils/relation-query-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ const buildRelationsListFragment = (info: RelationTypeIdInfo, level: 1 | 2, spac
text
boolean
float
time
datetime
point
schedule
}
}
${toEntitySelectionHeader} {
Expand All @@ -124,8 +125,9 @@ const buildRelationsListFragment = (info: RelationTypeIdInfo, level: 1 | 2, spac
text
boolean
float
time
datetime
point
schedule
}
${nestedPlaceholder}
}
Expand Down
12 changes: 10 additions & 2 deletions packages/hypergraph/test/entity/find-many-public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ const Parent = Entity.Schema(

const buildValueEntry = (
propertyId: string,
value: Partial<{ text: string; boolean: boolean; float: number; time: string; point: string }> = {},
value: Partial<{
text: string;
boolean: boolean;
float: number;
datetime: string;
point: string;
schedule: string;
}> = {},
) => ({
propertyId,
text: value.text ?? '',
boolean: value.boolean ?? false,
float: value.float ?? 0,
time: value.time ?? new Date(0).toISOString(),
datetime: value.datetime ?? new Date(0).toISOString(),
point: value.point ?? '0,0',
schedule: value.schedule ?? '',
});

describe('findManyPublic parseResult', () => {
Expand Down
12 changes: 10 additions & 2 deletions packages/hypergraph/test/entity/find-one-public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@ const Parent = Entity.Schema(

const buildValueEntry = (
propertyId: string,
value: Partial<{ text: string; boolean: boolean; float: number; time: string; point: string }> = {},
value: Partial<{
text: string;
boolean: boolean;
float: number;
datetime: string;
point: string;
schedule: string;
}> = {},
) => ({
propertyId,
text: value.text ?? '',
boolean: value.boolean ?? false,
float: value.float ?? 0,
time: value.time ?? new Date(0).toISOString(),
datetime: value.datetime ?? new Date(0).toISOString(),
point: value.point ?? '0,0',
schedule: value.schedule ?? '',
});

describe('findOnePublic', () => {
Expand Down
Loading