Tailflow
Skip to article
Browse documentation

The Graph · Action

Query a subgraph

Sends a GraphQL query you write to a subgraph on The Graph's network and hands its answer to the steps below.

When to use it

Anything a subgraph knows that the event does not carry: the pool's total value locked, the voter's past votes, the vault's share price.

At a glance

IntegrationThe Graph
Credits1
ConnectionThe Graph, by pasting a key

Settings

subgraphRequired
Subgraph. The subgraph's id, as Graph Explorer shows it.
queryRequiredAccepts event fields
Query. Sent exactly as written. Use variables for values from the event.
variablesOptionalAccepts event fields
Variables. One row per variable the query declares, without the $. Values can come from the event. One row per name and value.

What it hands on

Actions run in order, and each one can read what the actions above it produced. This one writes the fields below; a later action reaches them as {{ actions.graph_query_1.data }} — the action’s key, then which one it is if you use more than one of the same kind.

data
The query's answer, shaped as the query asked.
truncated
True when the answer was too large and lists in it were shortened.

Good to know

  • Values from the event go under Variables, never into the query. Declare each one in the query, such as query ($id: ID!), and add a row named id.
  • Variables are sent as text, which is what ids, addresses and big numbers are in a subgraph. Write a whole number such as first: 10 into the query itself.
  • A query the subgraph cannot answer, such as one that names a field it does not have, stops the flow, because every event would fail the same way.
  • Very large answers have their lists shortened. Ask for what the steps below use.
  • Each query is billed to your key by The Graph.