API Endpoint
Once Graph Node is running, the GraphQL HTTP server is available at:Schema-Based Type Generation
Graph Node automatically generates GraphQL query types from your subgraph schema. For each entity type in your schema, the API provides:- Single entity query:
entityName(id: ID!): EntityType - Collection query:
entityNames(first, skip, orderBy, orderDirection, where): [EntityType!]!
Example Schema
schema.graphql
Generated Query Types
From the schema above, Graph Node generates:Generated API
Entity Types and Fields
Supported GraphQL Types
Graph Node supports the following scalar types in entity definitions:String
Unique identifier for entities. Stored as
text or bytea in PostgreSQL.String
UTF-8 encoded text strings.
Bytes
Byte arrays, typically for Ethereum addresses and hashes. Must be prefixed with
0x.Int
32-bit signed integer.
Int8
64-bit signed integer.
BigInt
Arbitrary precision integer, stored as PostgreSQL
numeric.BigDecimal
Arbitrary precision decimal, stored as PostgreSQL
numeric.Boolean
Boolean value (
true or false).Timestamp
Unix timestamp in microseconds since epoch. Available from spec version 1.1.0.
Entity Attributes
@entity Directive
@entity Directive
Marks a GraphQL type as a storable entity.Options:
immutable: true- Entity versions are never updated (optimized storage)timeseries: true- Entity is a timeseries data point (immutable with timestamp)
@derivedFrom Directive
@derivedFrom Directive
Creates reverse lookups for entity relationships.The
transfers field on Token is automatically populated from Transfer entities.Immutable Entities
Immutable Entities
Immutable entities are write-once and never updated, enabling storage optimizations.Storage Optimization:
- Uses
block$column instead ofblock_range - Simple BTree indexes instead of GiST indexes
- Enforces
unique(id)constraint
Query Arguments
All collection queries support these arguments:Int
default:"100"
Number of entities to return. Maximum value is configurable per Graph Node instance.
Int
default:"0"
Number of entities to skip. Useful for pagination.
Enum
Field to sort results by. Can be any field in the entity or nested field (e.g.,
token__symbol).Enum
Sort direction:
asc (ascending) or desc (descending). Default is asc.Filter
Filter conditions for entities. See Query Filters for details.
Block_height
Query historical state at a specific block. See Time-Travel Queries.
Basic Query Examples
Response Format
Graph Node returns responses in standard GraphQL format:Error Handling
Errors are returned in theerrors array:
Interfaces
Graph Node supports GraphQL interfaces for polymorphic entities:Performance Considerations
Pagination
Pagination
Always use
first and skip for pagination to avoid loading excessive data:Field Selection
Field Selection
Only query fields you need. Large text fields and arrays can be expensive:
Nested Queries
Nested Queries
Be cautious with nested queries that can multiply data fetched:
Next Steps
- Learn about advanced query filters and operators
- Explore aggregation queries for timeseries data
- Understand time-travel queries for historical state

