subgraph-patterns

Implement The Graph subgraph patterns for manifest, schema, and mappings.

120|12|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ccashwell/evm-cortex --skill subgraph-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: subgraph-patterns
Source: https://github.com/ccashwell/evm-cortex/tree/main/skills/subgraph-patterns
Command: npx skills add https://github.com/ccashwell/evm-cortex --skill subgraph-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Graph developers need a cohesive blueprint to design, test, and deploy subgraphs across networks with consistent data sources, schemas, and mappings.

Core Features & Use Cases

  • Subgraph Manifest design: define subgraph.yaml with sources, mappings, and templates.
  • Schema design and data modeling: craft schema.graphql to express entities and relationships.
  • AssemblyScript mappings and event handlers: implement handlers in src/mappings.ts to process events.
  • Data source templates, deployment and testing: reuse patterns for contracts, templates, and matchstick tests.
  • Performance tips: apply indexing optimizations and pruning strategies for scalable indexing.

Quick Start

Create a new subgraph project using the provided skeleton and begin by wiring a manifest, schema, and mappings for a sample contract.

Frequently Asked Questions about subgraph-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a subgraph manifest for multiple contracts on The Graph?

To structure a subgraph manifest, define subgraph.yaml with data sources, mappings, and templates. Applying established subgraph patterns standardizes manifest configuration across networks, ensuring consistent data ingestion and deterministic indexing for typical contracts.

What is the best way to model entities in schema.graphql for subgraph indexing?

Modeling entities in schema.graphql involves crafting schemas that express entities and relationships clearly. Using proven subgraph patterns for schema design ensures reliable data access and optimizes how mapping handlers process and store blockchain events.

How do I test subgraph mappings with matchstick before deploying?

Testing subgraph mappings with matchstick involves writing unit tests for AssemblyScript event handlers. The subgraph patterns provide testing blueprints that verify handler logic against simulated contract events, ensuring your mappings process data correctly before deployment.

Can I use data source templates to handle dynamically created contracts in a subgraph?

Yes, you can use data source templates to handle dynamically created contracts. Subgraph patterns define how to wire templates in your manifest and mappings, allowing your subgraph to automatically index new contracts generated by factory patterns across networks.

How can I optimize subgraph indexing performance and apply pruning strategies?

Optimizing subgraph indexing performance requires applying indexing optimizations and pruning strategies. Subgraph patterns include performance tips that ensure scalable indexing, reducing redundant data processing and maintaining deterministic data access as your subgraph grows.

Why does my AssemblyScript subgraph mapping fail to compile or process events?

AssemblyScript subgraph mappings may fail to compile due to schema mismatches or incorrect event handler signatures. Following standardized subgraph patterns for mappings ensures proper entity handling, correct event binding, and deterministic indexing behavior.