Skip to content

Commit 42154fb

Browse files
authored
Ng/fix create entity (#121)
closes #105
1 parent 6babbbf commit 42154fb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/plain-hats-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphprotocol/grc-20": patch
3+
---
4+
5+
properly handle all relation fields (`fromSpace`, `fromVersion`, `toVersion`, `verified`) for relations in createEntity

src/graph/create-entity.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { createRelation } from './create-relation.js';
2525
* ],
2626
* relations: {
2727
* [relationPropertyId]: {
28-
* to: 'id of the entity',
28+
* toEntity: 'id of the entity',
2929
* id: 'id of the relation', // optional
3030
* toSpace: 'id of the to space', // optional
3131
* fromSpace: 'id of the from space', // optional
@@ -40,13 +40,14 @@ import { createRelation } from './create-relation.js';
4040
* entityValues: [ // optional values for the relation entity
4141
* { property: propertyId, value: 'value of the property' },
4242
* ],
43-
* entityRelations: {
43+
* entityRelations: { // same structure as `relations` and can be nested
4444
* [relationPropertyId]: {
45-
* to: 'id of the entity',
45+
* toEntity: 'id of the entity',
4646
* id: 'id of the relation', // optional
4747
* position: positionString, // optional
4848
* },
4949
* },
50+
* entityTypes: [typeEntityId1, typeEntityId2], // optional
5051
* },
5152
* },
5253
* });
@@ -212,7 +213,11 @@ export const createEntity = ({
212213
toEntity: relation.toEntity,
213214
type: Id(typeId),
214215
position: relation.position,
216+
fromSpace: relation.fromSpace,
215217
toSpace: relation.toSpace,
218+
fromVersion: relation.fromVersion,
219+
toVersion: relation.toVersion,
220+
verified: relation.verified,
216221
entityId: relationEntityId,
217222
entityName: relation.entityName,
218223
entityDescription: relation.entityDescription,

0 commit comments

Comments
 (0)