Skip to content
Merged
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions website/pages/en/developing/assemblyscript-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,33 @@ if (transfer == null) {

> 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.

#### Looking up derived entities

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.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

based on this comment it is available graphprotocol/graph-tooling#1190 (comment) in graph-node


Given a derived entity type, yuo can load the entity field was derived from. For example, given the following schema:

```graphql
type Token @entity {
id: ID!
holder: Holder!
color: String
}

type Holder @entity {
id: ID!
tokens: [Token!]! @derivedFrom(field: "holder")
}
```

The following code will load the `Token` entity that the `Holder` entity was derived from:

```typescript
let holder = Holder.load('test-id')
// Load the Token entity that the Holder entity was derived from
let token = holder.tokens.load()
```

#### Updating existing entities

There are two ways to update an existing entity:
Expand Down