protofire/subgraph-toolkit

Improve the entity creation workflow

Piquinikis opened this issue · 0 comments

When we need to create a new schema instance, there is a lot of repetitive tasks that sometimes it's finished in a copy/paste action.

For example:

export function getOrCreateOrder(id: string): Order {
	let entity = Order.load(id)
	if (entity == null) {
		entity = new Order(id)
		entity.cancelled = false
	}
	return entity as Order
}