Maton
Guide

Querying graph

You can query the graph in three ways:

  • Console: Best for getting started and browsing your graph.
  • API: Programmatically query the graph using the Context API.
  • AI agent: Ask your AI to query the graph for you with the Maton Skill.

Browsing graph

Open Context in the Console sidebar to browse nodes without code.

Querying with GraphQL

Schema

Save the schema as SDL:

npx gql-sdl https://api.maton.ai/context/graphql \
  -H "Authorization: Bearer $MATON_API_KEY" \
  -o schema.graphql

List an app's node types such as GoogleMail:

curl -s https://api.maton.ai/context/graphql \
  -H "Authorization: Bearer $MATON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ __type(name: \"Node\") { possibleTypes { name } } }"}' \
  | jq -r '.data.__type.possibleTypes[].name | select(startswith("GoogleMail"))'

Nodes

node returns one node by ID, or null if it was never observed:

{
  node(id: "google-mail/users/{userId}/messages/{messageId}") {
    __typename
    observedAt
    tags
  }
}

nodes returns up to 100 in order:

{
  nodes(ids: [
    "google-mail/users/{userId}/messages/{messageId}"
    "google-mail/users/{userId}/threads/{threadId}"
  ]) {
    __typename
    id
  }
}

Each node type has a top-level field such as googleMailMessages or stripeCustomers. It returns typed nodes, and its filter includes the type's typed relations.

{
  googleMailMessages(
    filter: {
      from: { id: { endsWith: "@acme.com" } }
      createdAt: { gte: "-P7D" }
    }
    first: 20
  ) {
    nodes { id createdAt }
    pageInfo { hasNextPage endCursor }
  }
}

search matches nodes of any type. query is case-insensitive text matched against node IDs, such as an email address or domain. Omit it to match every node. Narrow by type with types, such as types: [GoogleMailMessage].

{
  search(query: "jane@acme.com", first: 20) {
    nodes { __typename id updatedAt }
    pageInfo { hasNextPage endCursor }
  }
}

Relations

relations works on any node and needs no fragment. direction: out returns relations from the node, direction: in returns relations pointing to it.

{
  node(id: "google-mail/users/{userId}/messages/{messageId}") {
    relations(direction: out, first: 20) {
      nodes { property targetId target { __typename } }
    }
  }
}

Typed nodes expose relations as named fields:

  • To-one, such as thread, returns the node or null, even if deleted.
  • To-many, such as labels, returns a list to filter, sort, and paginate.
{
  node(id: "google-mail/users/{userId}/messages/{messageId}") {
    ... on GoogleMailMessage {
      thread { id }
      from { id }
      labels(first: 10) { nodes { id } }
    }
  }
}

Observations

Select observations on a node to see which requests touched it in the last 30 days:

{
  node(id: "google-mail/users/{userId}/messages/{messageId}") {
    observations(first: 5) {
      nodes { observedAt requestId }
    }
  }
}

Filtering

All fields set in one filter object must match. Combine objects with and and or:

{
  googleMailMessages(
    filter: {
      or: [
        { tags: { some: { eq: "needs-reply" } } }
        { from: { id: { endsWith: "@acme.com" } } }
      ]
    }
  ) {
    nodes { id }
  }
}
FilterExample
Stringid: { startsWith: "google-mail/users/{userId}/labels/" }
TimestampupdatedAt: { gte: "2026-11-01T00:00:00Z" }
Relative timecreatedAt: { gte: "-P2W" }
One relationthread: { id: { eq: "google-mail/users/{userId}/threads/{threadId}" } }
Many relationslabels: { some: { id: { endsWith: "/labels/INBOX" } } }
Tagstags: { some: { eq: "needs-reply" } }
Metadatametadata: { some: { key: "priority", number: { gte: 2 } } }

Relative times are ISO 8601 durations from now. -P2W is two weeks ago, P1D is one day ahead.

String comparators: eq, neq, in, nin, contains, notContains, startsWith, notStartsWith, endsWith, notEndsWith. eq, neq, contains, notContains, and startsWith have IgnoreCase variants, such as eqIgnoreCase.

Timestamp and number comparators: eq, neq, in, nin, gt, gte, lt, lte. deletedAt also takes null: true or null: false.

To-one relations take null: thread: { null: true } matches messages with no thread.

tags and to-many relations take some, every, none, and length. metadata takes some and none. Each metadata condition sets key plus one of string, number, date, boolean, or null.

every matches nodes with no items. Add length: { gte: 1 } to exclude them.

Sorting

sort takes one entry. Lists and search sort by createdAt, updatedAt, or observedAt. The default is newest createdAt first.

{
  search(sort: [{ updatedAt: { order: desc } }], first: 20) {
    nodes { id updatedAt }
  }
}

To-many relations and relations sort only by updatedAt, newest first by default.

Pagination

Lists are cursor-paginated connections:

  • first and after page forward. first defaults to 50, at most 100.
  • last and before page backward.
  • Select nodes for items, or edges { cursor node } for per-item cursors.
  • pageInfo returns hasNextPage, hasPreviousPage, startCursor, endCursor.

To poll for changes, sort by updatedAt ascending and pass the last endCursor as after:

{
  search(
    sort: [{ updatedAt: { order: asc } }]
    filter: { updatedAt: { gte: "2026-11-21T09:00:00Z" } }
    includeDeleted: true
    after: "{endCursor}"
  ) {
    nodes { __typename id updatedAt deletedAt }
    pageInfo { hasNextPage endCursor }
  }
}

Limits

LimitValue
Rate10 requests per second per account
Query complexity50,000
Query depth12
Page size100
IDs per nodes call100
Filter nesting10 levels, 200 conditions
Request body512 KB
query text256 characters
Query timeout15 seconds

Complexity grows with page size and nested lists. Lower first on nested fields if a query is rejected.

Errors

Query errors use the standard GraphQL errors array. Auth and rate-limit errors return HTTP 401 and 429 with {"error": {"message", "code"}}.

Next

On this page