Writing Helpful GraphQL Schema Comments
Upon adding a SubQuery GraphQL Agent to your AI Agent, we will ingest the GraphQL schema from the provided IPFS CID to understand:
What data is available in your indexer project
What the data means
How different entities relate to each-other
Which questions can we answer based on the indexer project
A properly formatted, logically named, and well commented GraphQL Schema is necessary to get the most out of your AI Agent.
Example GraphQL Schema
Principles for Writing Helpful GraphQL Schema Comments
Think like onboarding a new teammate:
Write comments as if explaining to someone who just joined the project and needs to maintain or extend it.
Assume they know GraphQL syntax but not your domain or design choices.
Be concise: Keep explanations short and to the point. Avoid unnecessary verbosity to reduce token usage and make parsing easier for AI.
Define terminology clearly: If you use domain-specific terms or abbreviations, explain them. This avoids ambiguity for both humans and AI.
Explain the purpose of each entity: Describe why the entity exists, what real-world or business concept it represents, and how it differs from other related entities.
If multiple entities look similar, explain why they are separate and when to use each one.
Field-level documentation: For every field, explain its meaning, expected format, and constraints. For IDs, document the generation/derivation rule (e.g. prefix conventions, hashing strategy, compound keys).
Describe relationships and usage: If a field links to another type or is part of a broader workflow, note the connection. Mention if the relationship is one-to-one, one-to-many, or derived.
Indicate business rules and edge cases: If certain fields are only present in specific conditions, or have business logic attached, note it.
Document evolution intent: If a field or type is temporary, deprecated, or reserved for future extension, make it clear.
Clarify query performance considerations: Highlight fields that are expensive to resolve, require joins, or should be queried sparingly.
Consistency in style: Use consistent phrasing, formatting, and tense in comments to reduce noise and make parsing easier for both humans and AI.
Updating your SubQuery GraphQL Agent’s Schema
After updating your GraphQL Schema, deploy it to IPFS to obtain a new CID.
Replace the SubQuery GraphQL Agent’s CID to see the changes.
Your AI Agent does not need to be rebuilt after modifying SubQuery GraphQL Agents.