Skip to content

Schemas and queries

Understand Subgraph GraphQL schemas, entity queries, pagination, and pruning behavior.

Write queries that keep working as your data grows. Every Subgraph has its own GraphQL schema, and GraphOps serves it through the standard Subgraph query interface, so the entity names, filters, and ordering fields you can use come from the Subgraph, not from GraphOps.

Schema model

A Subgraph schema defines entities and relationships. For example, a decentralized exchange Subgraph may expose entities such as pool, token, swap, position, or factory. A governance Subgraph may expose proposals, votes, delegates, and token holders.

Use introspection or the schema published with the Subgraph to discover the exact entity names, fields, filters, and relationships for the Subgraph you query.

Query features

GraphOps supports standard Subgraph GraphQL query behavior for the Subgraphs it serves:

FeatureBehavior
Entity selectionQuery entity collections and single entities exposed by the Subgraph schema.
FilteringUse standard generated where filters for fields supported by the schema.
OrderingUse orderBy and orderDirection when generated for the entity.
PaginationUse first and skip; prefer cursor-like pagination by stable fields for large scans.
MetadataQuery _meta for deployment, block, and indexing-error metadata.
IntrospectionUse GraphQL introspection when enabled for the Subgraph endpoint.

Pruning and historical queries

Historical block queries are not supported

GraphOps Subgraphs are pruned. Query the current indexed view and use _meta for the indexed block. Do not rely on historical block query constraints for production workflows.

Pruning keeps query serving efficient, but it means applications should not assume arbitrary historical entity snapshots are available. If you need historical replay or block-by-block pipelines, use Substreams or another purpose-built indexing workflow.

Design production queries

Good production queries:

  • Request only the fields the application needs.
  • Page through large entity sets.
  • Use stable ordering.
  • Include _meta when the application needs to display freshness or diagnose indexing lag.
  • Treat GraphQL errors as partial or failed application responses, not transport success.

Next steps