File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
website/pages/en/developing Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,33 @@ if (transfer == null) {
298
298
299
299
> Note: If there is no entity created in the given block, ` loadInBlock ` will return ` null ` even if there is an entity with the given ID in the store.
300
300
301
+ #### Looking up derived entities
302
+
303
+ As of ` graph-node ` v0.31.0, ` @graphprotocol/graph-ts ` v0.31.0 and ` @graphprotocol/graph-cli ` v0.51.0 the ` loadRelated ` method is available.
304
+
305
+ This enables loading derived entity fields from within an event handler. For example, given the following schema:
306
+
307
+ ``` graphql
308
+ type Token @entity {
309
+ id : ID !
310
+ holder : Holder !
311
+ color : String
312
+ }
313
+
314
+ type Holder @entity {
315
+ id : ID !
316
+ tokens : [Token ! ]! @derivedFrom (field : " holder" )
317
+ }
318
+ ```
319
+
320
+ The following code will load the `Token ` entity that the `Holder ` entity was derived from :
321
+
322
+ ```typescript
323
+ let holder = Holder .load ('test-id')
324
+ // Load the Token entity that the Holder entity was derived from
325
+ let token = holder .tokens .load ()
326
+ ```
327
+
301
328
#### Updating existing entities
302
329
303
330
There are two ways to update an existing entity:
You can’t perform that action at this time.
0 commit comments