-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graph, runtime: Support subgraph entity operation detection in compos…
…ed subgraphs
- Loading branch information
1 parent
b1d0bfa
commit 3b26d20
Showing
9 changed files
with
135 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
tests/integration-tests/subgraph-data-sources/src/mapping.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
import { Entity, log } from '@graphprotocol/graph-ts'; | ||
|
||
export function handleBlock(content: Entity): void { | ||
let stringContent = content.getString('val'); | ||
export const SubgraphEntityOpCreate: u32 = 0; | ||
export const SubgraphEntityOpModify: u32 = 1; | ||
export const SubgraphEntityOpDelete: u32 = 2; | ||
|
||
export class EntityTrigger { | ||
constructor( | ||
public entityOp: u32, | ||
public entityType: string, | ||
public entity: Entity, | ||
public vid: i64, | ||
) {} | ||
} | ||
|
||
export function handleBlock(content: EntityTrigger): void { | ||
let stringContent = content.entity.getString('val'); | ||
log.info('Content: {}', [stringContent]); | ||
log.info('EntityOp: {}', [content.entityOp.toString()]); | ||
|
||
switch (content.entityOp) { | ||
case SubgraphEntityOpCreate: { | ||
log.info('Entity created: {}', [content.entityType]); | ||
break | ||
} | ||
case SubgraphEntityOpModify: { | ||
log.info('Entity modified: {}', [content.entityType]); | ||
break; | ||
} | ||
case SubgraphEntityOpDelete: { | ||
log.info('Entity deleted: {}', [content.entityType]); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters